mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-06 11:54:26 -08:00
make bids for lowest rather than highest
This commit is contained in:
@@ -74,7 +74,7 @@ func (b *bidDB) AddBid(auctionId string, bid *types.Bid) error {
|
||||
}
|
||||
|
||||
// Get the highest bid in the list under specified auction key.
|
||||
func (b *bidDB) GetHighestBid(auctionId string) (*types.Bid, error) {
|
||||
func (b *bidDB) GetLowestBid(auctionId string) (*types.Bid, error) {
|
||||
k := []byte(auctionId)
|
||||
|
||||
var bid *types.Bid
|
||||
@@ -108,7 +108,7 @@ func (b *bidDB) GetHighestBid(auctionId string) (*types.Bid, error) {
|
||||
amt.SetString(rBid.Amount, 10)
|
||||
} else {
|
||||
rAmt.SetString(rBid.Amount, 10)
|
||||
if rAmt.Cmp(amt) == 1 {
|
||||
if rAmt.Cmp(amt) == -1 {
|
||||
bid = rBid
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func TestBasicFlow(t *testing.T) {
|
||||
}
|
||||
|
||||
// check highest bid
|
||||
if bid, err := BidDB.GetHighestBid("0"); err != nil {
|
||||
if bid, err := BidDB.GetLowestBid("0"); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
if bid.Owner != "cosmos456" || bid.Amount != "200" {
|
||||
|
||||
Reference in New Issue
Block a user