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

Consider only OkPoolProposal blocks of ProposedBlocks #210

Merged
merged 1 commit into from
Jan 9, 2024
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
21 changes: 14 additions & 7 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,19 @@ func (m *ApiService) handleMemoryStatistics(w http.ResponseWriter, req *http.Req
// are missed we can have less. If blocks are missed we will take into account a time window
// slightly higher than 30 days.

for _, block := range m.oracle.State().ProposedBlocks {
totalRewardsSentWei.Add(totalRewardsSentWei, block.Reward)
totalOkPoolProposalBlocks := uint64(0)

// Filter blocks in the last 30 days
if block.Slot > limitSlot {
totalRewardsSent30DaysWei.Add(totalRewardsSent30DaysWei, block.Reward)
for _, block := range m.oracle.State().ProposedBlocks {
// only consider ok pool proposals, since these are the only type of blocks that are shared
// across all validators
if block.BlockType == oracle.OkPoolProposal {
totalRewardsSentWei.Add(totalRewardsSentWei, block.Reward)
totalOkPoolProposalBlocks++

// Filter blocks in the last 30 days
if block.Slot > limitSlot {
totalRewardsSent30DaysWei.Add(totalRewardsSent30DaysWei, block.Reward)
}
}
}

Expand All @@ -349,8 +356,8 @@ func (m *ApiService) handleMemoryStatistics(w http.ResponseWriter, req *http.Req
avgBlockRewardWei := big.NewInt(0)

// Avoid division by zero
if totalProposedBlocks != 0 {
avgBlockRewardWei = big.NewInt(0).Div(totalRewardsSentWei, big.NewInt(0).SetUint64(uint64(len(m.oracle.State().ProposedBlocks))))
if totalOkPoolProposalBlocks != 0 {
avgBlockRewardWei = big.NewInt(0).Div(totalRewardsSentWei, big.NewInt(0).SetUint64(totalOkPoolProposalBlocks))
}

m.respondOK(w, httpOkMemoryStatistics{
Expand Down
Loading