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

Paginate Next Reward Payment #185

Merged
merged 5 commits into from
Apr 20, 2020
Merged

Conversation

jholdstock
Copy link
Member

Pagination for "Next Reward Payment" on the homepage.

gui/cache.go Outdated

// Sort list so the largest percentages will be shown first.
sort.Slice(quotas, func(i, j int) bool {
larger := quotas[i].Percentage.Cmp(quotas[j].Percentage) > 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simpler to do return quotas[i].Percentage.Cmp(quotas[j].Percentage) > 0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

gui/cache.go Outdated
@@ -48,8 +48,8 @@ type Cache struct {
blockExplorerURL string
minedWork []minedWork
minedWorkMtx sync.RWMutex
workQuotas []workQuota
workQuotasMtx sync.RWMutex
dividends []dividend
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not sure about this change considering the values being reported here are not actual amounts being paid to participating accounts but percentages of the work contributed so far towards finding the next block. Maybe work quota is also not descriptive or simple enough, but using dividend here is misleading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to RewardQuota as discussed on Matrix

@@ -42,6 +41,12 @@ func (ui *GUI) renderIndex(w http.ResponseWriter, r *http.Request, modalError st
}
}

// Get the next reward payment percentages (max 10).
rewardQuotas := ui.cache.getRewardQuotas()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be concerned about how many results are returned here now that pagination has been implemented for reward quotas?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the initial render. When the page is first loaded we only want to display the top ten (ie. the first page).

When the pagination Javascript loads, clickable buttons are displayed which allow the user to load additional data on the next pages. If the Javascript does not load, only the first 10 results will be visible (hence #181).

If this is not limited, it is a potential DoS vector. We had a similar problem with VSP where information about 100s of tickets was passed into a template which caused the templating engine to take 10+ seconds to render.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks.

@jholdstock jholdstock merged commit dc26621 into decred:master Apr 20, 2020
@dnldd dnldd mentioned this pull request Apr 22, 2020
@jholdstock jholdstock deleted the paginate-dividends branch October 6, 2020 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants