Skip to content

Commit

Permalink
rate limit snapshot creation
Browse files Browse the repository at this point in the history
  • Loading branch information
akremstudy committed Dec 4, 2024
1 parent 3c1aac9 commit e21ac0f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion x/bridge/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,11 @@ func (k Keeper) GetValidatorDidSignCheckpoint(ctx context.Context, operatorAddr
func (k Keeper) CreateNewReportSnapshots(ctx context.Context) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)
blockHeight := sdkCtx.BlockHeight()

snapshotlimit, err := k.SnapshotLimit.Get(ctx)
if err != nil {
k.Logger(ctx).Info("Error getting snapshot limit", "error", err)
return err
}
reports := k.oracleKeeper.GetAggregatedReportsByHeight(ctx, uint64(blockHeight))
for _, report := range reports {
queryId := report.QueryId
Expand All @@ -795,6 +799,10 @@ func (k Keeper) CreateNewReportSnapshots(ctx context.Context) error {
if err != nil {
return err
}
if snapshotlimit.Limit == 0 {
break
}
snapshotlimit.Limit--
}
return nil
}
Expand Down

0 comments on commit e21ac0f

Please sign in to comment.