mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 00:35:18 +00:00
24 lines
634 B
Go
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?
|
||
|
}
|
||
|
}
|
||
|
}
|