gui, accrual: Implement accrual limit warning #2636
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #2635.
The design of this PR implements a NearRewardLimit, or AccrualNearLimit, which has to be propagated several layers through the architecture. Note that this method provides a CAmount threshold which represents a value that is less than the MaxReward of 16384 by two days of accrual at the current magnitude, or 1/2 of the MaxReward, whichever is greater. The first condition is motivated by the notion of giving someone 2 days notice to do an MRC before they start losing GRC to the accrual cap. The second deals with the corner case where a person's mag is so high that 2 days of accrual subtracted from the MaxReward would yield a nonsensical alerting value. The maximum magnitude is 32767, so the maximum per day GRC accrual is 8191.75. 2x that value is 16383.5, which means the alerting value would be 0.5 GRC, or essentially immediate. So the 1/2 of the MaxReward condition starts to constrain the warning time at approximately one half of the max magnitude. At max magnitude the alerting time will only be approximately one day.
The "out parameter" for the boolean in FormatAccrual is so that the Accrual() method does not have to be called more than once for the GUI update. This update is on a timer loop and is called repeatedly. Accrual is much heavier than AccrualNearLimit.