mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-06 09:44:25 -08:00
link up bid txs and memdb storage + key fixes
lfg it works
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"reflect"
|
||||
|
||||
"cosmos-test/x/cosmostest/memdb"
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
@@ -30,17 +31,21 @@ func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.M
|
||||
}
|
||||
|
||||
highestBid, err := memdb.BidDB.GetHighestBid(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", err)
|
||||
}
|
||||
amtPrev := new(big.Int)
|
||||
amtPrev, ok = amtPrev.SetString(highestBid.Amount, 10)
|
||||
if !ok { // this should have been checked before, but whatever
|
||||
return nil, fmt.Errorf("failed to convert max bid (%s) to a large integer", msg.Amount)
|
||||
return nil, fmt.Errorf("failed to get highest bid: %s", reflect.TypeOf(err))
|
||||
}
|
||||
|
||||
if amt.Cmp(amtPrev) < 1 {
|
||||
return nil, fmt.Errorf("bid amount must be greater than largest bid")
|
||||
if highestBid != nil {
|
||||
amtPrev := new(big.Int)
|
||||
amtPrev, ok = amtPrev.SetString(highestBid.Amount, 10)
|
||||
if !ok { // this should have been checked before, but whatever
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
bid := &types.Bid{
|
||||
|
||||
Reference in New Issue
Block a user