-
Notifications
You must be signed in to change notification settings - Fork 714
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
[RPC] Cache money supply on memory. Introduce getsupplyinfo #1906
[RPC] Cache money supply on memory. Introduce getsupplyinfo #1906
Conversation
fbbda68
to
b91eef0
Compare
Rebased on master. Ready for review. |
Concept ACK. However, something that isn't quite sitting right with me (and is strictly a convention/semantic issue) is the name of the new RPC command: In our other We do have a few existing outliers though: Proposing to use Additionally, most 3rd party services simply use "Supply" and not "Money Supply" when referencing the amount of available and/or eventual number of coins. In hindsight, probably should have brought this up way back when the So, now, do we continue the use of a somewhat unique term ("moneysupply"), or do we move forward with a more universal term in the new command ("supply")? |
I've no particular preference, as long as it's clear that we are talking about the "spendable" supply (sum of utxo values). |
yeah certainly wouldn't change the output field in As for ensuring that the return value is known to be the "spendable" supply, you've already stated as much in the new command's description, which I think is sufficient enough. |
Needs a rebase after #1909 merge. |
Dumb storage class. This will be used to cache the sum of spendable transaction outputs (and the height of the chain when this sum was last updated).
which returns the current cached MoneySupply contents (total amount and height) after optional flush/recalculation.
b91eef0
to
ae4069e
Compare
Rebased on master and renamed new rpc |
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.
The new RPC command will need to be added to the release notes, other than that ACK ae4069e. Nice improvement
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.
ACK ae4069e
With #1878 the RPC call
getinfo
becomes awfully slow (it triggers a flush of the chainstate to disk and recalculates the amount).In this PR we introduce a in-memory global object (instance of a dumb storage class) to cache the money supply, as well as the height of the chain when it was last updated.
The cache is updated in 3 cases:
A new RPC
getsupplyinfo
is introduced. It returns the contents of the cached object, after an optional flush/recalculation (if theforceupdate
argument is set to true).The money supply is still part of
getinfo
output, for backward compatibility, but the fetching is redirected to the newgetsupplyinfo
(with default value, false, for theforceupdate
argument, thus without flush/recalculation).Examples:
Based on top of
Starts with
[Core] Introduce CMoneySupply class
(6554757)