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 ) {
2019-12-21 01:04:04 +00:00
var expiredAuctions [ ] ID
k . IterateAuctionsByTime ( ctx , ctx . BlockTime ( ) , func ( id ID ) bool {
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
}
}
}