2019-11-25 19:46:02 +00:00
|
|
|
package auction
|
|
|
|
|
|
|
|
import (
|
2020-06-17 09:09:44 +00:00
|
|
|
"errors"
|
2023-08-25 22:14:35 +00:00
|
|
|
"time"
|
2020-06-17 09:09:44 +00:00
|
|
|
|
2023-08-25 22:14:35 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/telemetry"
|
2019-11-25 19:46:02 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2022-01-08 00:39:27 +00:00
|
|
|
|
|
|
|
"github.com/kava-labs/kava/x/auction/keeper"
|
2020-06-17 09:09:44 +00:00
|
|
|
"github.com/kava-labs/kava/x/auction/types"
|
2019-11-25 19:46:02 +00:00
|
|
|
)
|
|
|
|
|
2020-06-17 09:09:44 +00:00
|
|
|
// BeginBlocker closes all expired auctions at the end of each block. It panics if
|
|
|
|
// there's an error other than ErrAuctionNotFound.
|
2022-01-08 00:39:27 +00:00
|
|
|
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
|
2023-08-25 22:14:35 +00:00
|
|
|
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
|
|
|
|
|
2020-01-12 15:12:22 +00:00
|
|
|
err := k.CloseExpiredAuctions(ctx)
|
2020-06-17 09:09:44 +00:00
|
|
|
if err != nil && !errors.Is(err, types.ErrAuctionNotFound) {
|
2020-01-12 15:12:22 +00:00
|
|
|
panic(err)
|
2019-11-25 19:46:02 +00:00
|
|
|
}
|
|
|
|
}
|