-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Chainparams: Remove redundant getter CChainParams::SubsidyHalvingInterval() #5996
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
Conversation
|
Looks OK from quick glance. Test plan? |
|
utACK. One way to test this would be creating a unit test with the old GetBlockValue() implementation, and calling it for some arbitrary heights/fees, and comparing with the new. It looks trivially correct to me, though. |
f3a0734 to
af6f6bf
Compare
|
Needed rebase. In any case, the current main_tests.cpp (which just tests this function) could be improved, it only checks that the subsidy is always <= 50 * COIN. Probably a dataset with pairs height -> subsidy would be better. We could also test for other subsidy halving intervals (now that Consensus::Params it's passed, it's trivial to set another Consensus::Params::nSubsidyHalvingInterval in the tests, even without calling Params()). |
|
Needed rebase again. ...were part of Consensus::Params, we could easily adapt my tests to test different values for them. |
…renamed GetBlockSubsidy] Remove redundant getter CChainParams::SubsidyHalvingInterval()
|
Rebased |
If you had done that, this would have already been merged. I'm a bit wary as this changes the fee computation code and is not simple substitution like the other "Remove redundant getter" pulls. |
|
That's fine. This doesn't "change the way fees are computed": fees are computed outside of this function. The only difference is that the subsidy and the fees were added together inside the function and now they will be added outside it. If the previous function had a more descriptive declaration like Calculating the initial subsidy to then ignore when halvings >= 64 it's stupid, so I would have also felt bad if I had touched this function without fixing that. I can always remove that tiny optimization if people insist on keep doing the wrong thing. Maybe I should have done this in 3 commits and only squash them after people have seen this as the obviously equivalent-but-clearer thing I see. If someone else wants to do a version without the optimization and keeping the addition inside the function (because somehow they thing |
|
@jjtimon I didn't intend to argue, or demand that you have to change this code now after all that time, just tried to explain why this one requires more thorough scrutiny than those other mentioned pulls. That said, the change looks good to me. utACK |
|
I understood that and that's why this one got tests. |
935bd0a Chainparams: Refactor: Decouple main::GetBlockValue() from Params() [renamed GetBlockSubsidy] (Jorge Timón)
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.
Nit: You could have added a comment explaining the function AFAIK all main.h functions should include a comment.
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.
That can still be done as an independent PR. Documentation is good, but there's no reason why it has to be added when a function is touched. For example, should I complete the documentation of all functions touched in #6163 ? Seems orthogonal to me...
Also I don't see how functions declared main.h should be special in that regard.
Decouple main::GetBlockValue() from Params() and rename it GetBlockSubsidy.
Then remove redundant the getter CChainParams::SubsidyHalvingInterval().