Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(uibc): quota reset event #2264

Merged
merged 4 commits into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions x/uibc/module/abci.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
package uibc

import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/umee-network/umee/v6/x/uibc/quota/keeper"
)

// BeginBlock implements BeginBlock for the x/uibc module.
func BeginBlock(ctx sdk.Context, k keeper.Keeper) {
logger := ctx.Logger().With("module", "uibc")
quotaExpires, err := k.GetExpire()
if err != nil {
// TODO, use logger as argument
ctx.Logger().Error("can't get quota exipre", "error", err)
logger.Error("can't get quota exipre", "error", err)
return
}

// reset quotas
if quotaExpires == nil || quotaExpires.Before(ctx.BlockTime()) {
if err = k.ResetAllQuotas(); err != nil {
ctx.Logger().Error("can't get quota exipre", "error", err)
logger.Error("can't get quota exipre", "error", err)
} else {
logger.Info("IBC Quota Reset")
ctx.EventManager().EmitEvent(
sdk.NewEvent("/umee/uibc/v1/EventQuotaReset",
sdk.NewAttribute("next_expire", quotaExpires.UTC().Format(time.RFC3339))))
}
}
}
Expand Down
Loading