-
Notifications
You must be signed in to change notification settings - Fork 492
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
ledger: refactor the ledger Totals #2846
ledger: refactor the ledger Totals #2846
Conversation
…tabase refactoring.
@tolikzinovyev - this change would impact the indexer due to the change in |
Codecov Report
@@ Coverage Diff @@
## master #2846 +/- ##
==========================================
- Coverage 47.63% 47.61% -0.02%
==========================================
Files 358 358
Lines 57887 57906 +19
==========================================
- Hits 27573 27572 -1
- Misses 27190 27209 +19
- Partials 3124 3125 +1
Continue to review full report at Codecov.
|
func (au *accountUpdates) latestTotalsImpl() (basics.Round, ledgercore.AccountTotals, error) { | ||
offset := len(au.deltas) | ||
rnd := au.dbRound + basics.Round(len(au.deltas)) | ||
return rnd, au.roundTotals[offset], nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be more straight-forward to do au.roundTotals[len(au.roundTotals) - 1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you wrote is correct; but it's less consistent with the rest of the code that is using the len(au.deltas)
.
There is also the theoretical risk of having a negative value that doesn't apply here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to merge
Summary
The plan to change the tracker database to maintain the latest 320 rounds for the online accounts only have some other required modification; one of them is the semantics of the
Totals
method:AccountTotals
for any of the recent 320 rounds.AccountTotals
for the latest round only, as well as provide the circulating supply for latest-320 rounds ( i.e. the circulating supply is a subset of theAccountTotals
).Once the database implementation is complete, the database would contain the
AccountTotals
information for the latest round only, plus the online circulation for the past 320 rounds.In order to support that, I've broken up the interface into:
LatestTotals
, which would return the latest totals as well as the latest round associated with these totals.OnlineTotals
, which receive a round number and return the online totals associated with that round.This change is focused around the Ledger interface. Further changes would be required in the accounts update before the high-level goals could be achieved.
Test Plan
Unit tests updated.