0g-chain/x/auction/abci.go

23 lines
605 B
Go
Raw Normal View History

2019-11-25 19:46:02 +00:00
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) {
2020-01-01 14:11:19 +00:00
var expiredAuctions []uint64
k.IterateAuctionsByTime(ctx, ctx.BlockTime(), func(id uint64) bool {
2019-12-21 01:04:04 +00:00
expiredAuctions = append(expiredAuctions, id)
return false
})
// Note: iteration and auction closing are in separate loops as db should not be modified during iteration // TODO is this correct? gov modifies during iteration
for _, id := range expiredAuctions {
err := k.CloseAuction(ctx, id)
2019-11-25 19:46:02 +00:00
if err != nil {
2019-12-21 01:04:04 +00:00
panic(err)
2019-11-25 19:46:02 +00:00
}
}
}