Skip to content

Commit

Permalink
handle error for ExecuteParamUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed Oct 23, 2023
1 parent 90646aa commit 2d53c86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion x/oracle/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) error {
plans := k.GetParamUpdatePlans(ctx)
for _, plan := range plans {
if plan.ShouldExecute(ctx) {
k.ExecuteParamUpdatePlan(ctx, plan)
if err := k.ExecuteParamUpdatePlan(ctx, plan); err != nil {
return err
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions x/oracle/keeper/param_update_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (k Keeper) ValidateParamChanges(ctx sdk.Context, keys []string, changes typ

// ExecuteParamUpdatePlan will execute a given param update plan and emit a param
// update event.
func (k Keeper) ExecuteParamUpdatePlan(ctx sdk.Context, plan types.ParamUpdatePlan) {
func (k Keeper) ExecuteParamUpdatePlan(ctx sdk.Context, plan types.ParamUpdatePlan) error {
for _, key := range plan.Keys {
switch key {
case string(types.KeyVotePeriod):
Expand Down Expand Up @@ -181,12 +181,12 @@ func (k Keeper) ExecuteParamUpdatePlan(ctx sdk.Context, plan types.ParamUpdatePl
}
}

// clear plan from store after executing it
k.ClearParamUpdatePlan(ctx, uint64(plan.Height))

event := sdk.NewEvent(
types.EventParamUpdate,
sdk.NewAttribute(types.AttributeKeyNotifyPriceFeeder, "1"),
)
ctx.EventManager().EmitEvent(event)

// clear plan from store after executing it
return k.ClearParamUpdatePlan(ctx, uint64(plan.Height))
}

0 comments on commit 2d53c86

Please sign in to comment.