Skip to content

Commit

Permalink
refactor: avoid repeatelly call
Browse files Browse the repository at this point in the history
  • Loading branch information
leonz789 committed Dec 11, 2024
1 parent 366d54f commit 83ed4bd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions x/oracle/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
continue
}

index := uint64(reportedInfo.IndexOffset % am.keeper.GetReportedRoundsWindow(ctx))
reportedRoundsWindow := am.keeper.GetReportedRoundsWindow(ctx)
index := uint64(reportedInfo.IndexOffset % reportedRoundsWindow)
reportedInfo.IndexOffset++
// Update reported round bit array & counter
// This counter just tracks the sum of the bit array
Expand Down Expand Up @@ -306,8 +307,8 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
)
}

minHeight := reportedInfo.StartHeight + am.keeper.GetReportedRoundsWindow(ctx)
maxMissed := am.keeper.GetReportedRoundsWindow(ctx) - minReportedPerWindow
minHeight := reportedInfo.StartHeight + reportedRoundsWindow
maxMissed := reportedRoundsWindow - minReportedPerWindow
// if we are past the minimum height and the validator has missed too many rounds reporting prices, punish them
if height > minHeight && reportedInfo.MissedRoundsCounter > maxMissed {

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
consAddr, err := sdk.ConsAddressFromBech32(validator)
Expand Down

0 comments on commit 83ed4bd

Please sign in to comment.