0g-chain/x/auction/spec/06_begin_block.md
2020-01-07 12:17:27 -05:00

432 B

At the beginning of each block, auctions that have reached EndTime are closed. The logic to close auctions is as follows:

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)
		}
  }