fix bugs with memdb + vprovider setting

- wasn't setting list of verified providers
- was looping through multilevel keys, not auctionid
master
michael 2022-09-14 00:01:06 +00:00
parent 11829e1017
commit c08c827b4e
3 changed files with 17 additions and 6 deletions

View File

@ -41,14 +41,17 @@ func (k Keeper) FinalizeExpiredAuctions(ctx sdk.Context) {
// Remaining Unpaid: Full bid amount
auction.Remaining = auction.Best.Amount
// clear auction
// clear auction bids
if err := memdb.AuctionDB.ClearAuctionBids(auctionId); err != nil {
return errors.Errorf("failed to clear auction from memcache: %s", err)
}
if err := memdb.AuctionDB.ClearVerifiedProviders(auctionId); err != nil {
return errors.Errorf("failed to clear verified providers for auction %s: %s", auctionId, err)
}
// clear verified provider list; swallow error since this isn't critical for now
_ = memdb.AuctionDB.ClearVerifiedProviders(auctionId)
// if err := memdb.AuctionDB.ClearVerifiedProviders(auctionId); err != nil {
// return errors.Errorf("failed to clear verified providers for auction %s: %s", auctionId, err)
// }
// pay out unpaid remainder to auction creator
ceiling := new(big.Int)

View File

@ -8,6 +8,7 @@ import (
"strconv"
"colinear/x/colinearcore/auctionconfig"
"colinear/x/colinearcore/memdb"
"colinear/x/colinearcore/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -65,6 +66,12 @@ found:
}
}
if msg.VerifiedProviders != nil {
memdb.AuctionDB.SetVerifiedProviders(index, msg.VerifiedProviders)
} else {
memdb.AuctionDB.SetVerifiedProviders(index, []string{})
}
auction := types.Auction{
Index: index,
Name: msg.Name,

View File

@ -170,8 +170,9 @@ func (b *auctionDB) ForEachAuctionBidList(viewFunc func(string) error) error {
item := iter.Item()
key := string(item.Key())
// require that this be an auction bids key
if len(key) > 5 && key[len(key)-5:len(key)-1] == "_bids" {
err := viewFunc(key)
if len(key) > 5 && key[len(key)-5:] == "_bids" {
auctionId := key[:len(key)-5]
err := viewFunc(auctionId)
if err != nil {
return err
}