0g-chain/x/auction/spec/06_end_block.md

19 lines
420 B
Markdown
Raw Normal View History

2020-01-09 16:14:55 +00:00
# End Block
2020-01-09 16:14:55 +00:00
At the end of each block, auctions that have reached `EndTime` are closed. The logic to close auctions is as follows:
```go
var expiredAuctions []uint64
k.IterateAuctionsByTime(ctx, ctx.BlockTime(), func(id uint64) bool {
expiredAuctions = append(expiredAuctions, id)
return false
})
for _, id := range expiredAuctions {
err := k.CloseAuction(ctx, id)
if err != nil {
panic(err)
}
}
```