mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-06 11:14:26 -08:00
make bids for lowest rather than highest
This commit is contained in:
@@ -29,7 +29,7 @@ func (k *Keeper) EndExpiredAuctions(ctx types.Context) {
|
||||
|
||||
if uint64(ctx.BlockHeight()) >= auction.Deadline-auctionconfig.AuctionTime {
|
||||
var err error
|
||||
auction.TopBid, err = memdb.BidDB.GetHighestBid(auctionId)
|
||||
auction.Best, err = memdb.BidDB.GetLowestBid(auctionId)
|
||||
if err != nil {
|
||||
return errors.Errorf("could not get highest bid for auction %s: %s", auctionId, err)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func (k msgServer) NewAuction(goCtx context.Context, msg *types.MsgNewAuction) (
|
||||
Index: index,
|
||||
Name: msg.Name,
|
||||
Description: msg.Description,
|
||||
TopBid: new(types.Bid),
|
||||
Best: new(types.Bid),
|
||||
Deadline: uint64(ctx.BlockHeight()) + auctionconfig.AuctionTime,
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.M
|
||||
return nil, fmt.Errorf("bid amount must be greater than 0")
|
||||
}
|
||||
|
||||
highestBid, err := memdb.BidDB.GetHighestBid(msg.AuctionIndex)
|
||||
highestBid, err := memdb.BidDB.GetLowestBid(msg.AuctionIndex)
|
||||
// we manually handle KeyNotFound in GetHighestBid, so should return (nil, nil) if not found
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get highest bid: %s", reflect.TypeOf(err))
|
||||
@@ -51,8 +51,8 @@ func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.M
|
||||
return nil, fmt.Errorf("failed to convert max bid (%s) to a large integer", msg.Amount)
|
||||
}
|
||||
|
||||
if amt.Cmp(amtPrev) < 1 {
|
||||
return nil, fmt.Errorf("bid amount must be greater than largest bid")
|
||||
if amt.Cmp(amtPrev) != -1 {
|
||||
return nil, fmt.Errorf("bid amount must be less than current lowest bid (%s)", amtPrev)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user