0g-chain/x/auction/abci.go
2019-11-25 14:46:02 -05:00

24 lines
634 B
Go

package auction
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// EndBlocker runs at the end of every block.
func EndBlocker(ctx sdk.Context, k Keeper) {
// get an iterator of expired auctions
expiredAuctions := k.GetQueueIterator(ctx, EndTime(ctx.BlockHeight()))
defer expiredAuctions.Close()
// loop through and close them - distribute funds, delete from store (and queue)
for ; expiredAuctions.Valid(); expiredAuctions.Next() {
auctionID := k.DecodeAuctionID(ctx, expiredAuctions.Value())
err := k.CloseAuction(ctx, auctionID)
if err != nil {
panic(err) // TODO how should errors be handled here?
}
}
}