-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: new function GetBlockSubsidyPrev for simplification of usage #5524
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
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.
Please refer to the subsidy_cleanup branch (current tip, 3185dae)
commit 1: kwvg@3fc0fe5 IMHO, better to do replacing Params() along backport bitcoin#25168 - out of scope of this tiny refactoring commit 2: kwvg@812d63c This commit is very similar to my changes, but there're 2 functions GetBlockSubsidy that are both public but different only in argument name. as doc/developer-nodes.md says:
commit 3: kwvg@f4180b1 I don't see a point to do it, because this underlying function is not used anywhere and just make implementation longer. So, commit-2 - duplicate with this PR, commit 3 - to drop. Commit 1 and Commit 4 -> dedicated PR along with backport bitcoin#25168 (and may be some more backports) |
|
|
Sorry, I quoted wrong part of doc/developer-notes when I tried to find it. This function is public interface from header even if it is not in virtual class. Anyway, it's 100% applied... But I'd prefer to use different name for this case, because logic is not same. doc/developer-notes:
About refactoring of Params(). I just double-checked with current master of bitcoin - even if some parts are refactored, There's exactly same line in current master of bitcoin that still uses I'd prefer to keep this PR as it is. |
|
imo |
…pindexPrev)->GetBlockSubsidy(pindex)
|
Sorry, I didn't understand this part. I open same line in the bitcoin code (master): So, if this refactoring will be done, any backports in future would be more difficult to be done. Btw, if some code is dash-specific, let's consider changes without changing common code with bitcoin. UPD: do you mean this particular call and only it? |
Pretty much why I bothered with changing to |
|
In defense of src/wallet/external_signer_scriptpubkeyman.cpp: ExternalSigner::Enumerate(command, signers, Params().GetChainTypeString());
src/torcontrol.cpp: service = LookupNumeric(std::string(service_id+".onion"), Params().GetDefaultPort());
src/net.cpp: return static_cast<uint16_t>(gArgs.GetIntArg("-port", Params().GetDefaultPort()));
src/rpc/mempool.cpp: if (!Params().IsMockableChain()) {Note, that /* Return the currently selected parameters. This won't change after app
* startup, except for unit tests.
*/
const CChainParams &Params()so, it doesn't actually critical to get-rid-of that call. |
updated comments Co-authored-by: UdjinM6 <[email protected]>
UdjinM6
left 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.
LGTM, utACK
ogabrielides
left 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.
LGTM
kwvg
left 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.
LGTM
PastaPastaPasta
left 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.
utACK for squash merge
Issue being fixed or feature implemented
Unlike bitcoin we are using PREVIOUS block in
GetBlockSubsidy().That creates special case for genesis block, because it doesn't have previous block. In this special case instead of calling
GetBlockSubsidyshould be used pre-calculated value. To avoid confusion for new code and simplify implementation, there's introduced a new methodGetBlockSubsidyPrevthat has other interface: it takes pointerCBlockIndex* previn agruments instead pair of height + nbits.These changes are follow-up for #5501
What was done?
Implemented new method
GetBlockSubsidyPrev()and used instead ofGetBlockSubsidywhen it is more convenient.How Has This Been Tested?
Run unit/functional tests.
Breaking Changes
N/A
Checklist: