Skip to content

Commit

Permalink
feat: Add isCheaperOrOlder matching helper
Browse files Browse the repository at this point in the history
  • Loading branch information
bgins committed Jan 27, 2025
1 parent 789270a commit 64805d3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/solver/matcher/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ func GetMatchingDeals(
return deals, nil
}

// Returns true if first offer is cheaper, or has same price but is older
func isCheaperOrOlder(a, b data.ResourceOffer) bool {
priceA := a.DefaultPricing.InstructionPrice
priceB := b.DefaultPricing.InstructionPrice

if priceA != priceB {
return priceA < priceB // Choose cheaper price
}
return a.CreatedAt < b.CreatedAt // Choose older offer
}

// See if our jobOffer targets a specific address. If so, we will create a deal automatically
// with the matcing resourceOffer.
func getTargetedDeal(
Expand Down

0 comments on commit 64805d3

Please sign in to comment.