Skip to content

Commit

Permalink
refactor(oracle): simplify window progress query
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewozniak committed Aug 26, 2022
1 parent 4bdbf52 commit 7380af6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
11 changes: 2 additions & 9 deletions x/oracle/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,9 @@ func (q querier) SlashWindow(
ctx := sdk.UnwrapSDKContext(goCtx)
params := q.GetParams(ctx)

slashWindow := params.SlashWindow
votePeriod := params.VotePeriod
currentBlock := uint64(ctx.BlockHeight())
votePeriodsPerSlashWindow := slashWindow / votePeriod

currentSlashWindow := currentBlock / votePeriodsPerSlashWindow
blocksIntoSlashWindow := currentBlock - (currentSlashWindow * slashWindow)

return &types.QuerySlashWindowResponse{
WindowProgress: blocksIntoSlashWindow / votePeriod,
WindowProgress: (uint64(ctx.BlockHeight()) / params.VotePeriod) %
params.SlashWindow,
}, nil
}

Expand Down
20 changes: 10 additions & 10 deletions x/oracle/types/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7380af6

Please sign in to comment.