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] getblockchaininfo: Loop through the bip9 soft fork deployments instead of hard coding #10874
Conversation
src/rpc/blockchain.cpp
Outdated
@@ -1185,8 +1185,11 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) | |||
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); | |||
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); | |||
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); | |||
BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV); | |||
BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT); | |||
for (int BIP9SoftFork = Consensus::DEPLOYMENT_CSV; BIP9SoftFork != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++BIP9SoftFork) { |
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.
Why convert to int and back to Nevermind, enums don't suport DeploymentPos
?++
.
utACK 4048d77fb462268f374edd420a827d91be8af11f |
I'm not sure this change is worth it when there are just two bip9 softforks. This is a net +ve LOC change for the same functionality. Perhaps worth revisiting if we get more bip9 softforks in future, or am I missing some benefit? |
It's fine to do this in the future when we have more soft forks. I had only made the change since I needed to add stats about BIP 91 to one of my branches and the fact that the forks needed to be hard coded in to be displayed with |
ACK 4048d77. Nit, make it so that the name is accessed in for (int pos = Consensus::DEPLOYMENT_CSV; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) {
BIP9SoftForkDescPushBack(bip9_softforks, consensusParams, static_cast<Consensus::DeploymentPos>(pos));
} |
I also prefer that to casting to int and back in the loop header. |
Ping @achow101 |
pong @laanwj |
4048d77
to
8cf8b06
Compare
Done. |
src/rpc/blockchain.cpp
Outdated
BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT); | ||
for (int pos = Consensus::DEPLOYMENT_CSV; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) { | ||
BIP9SoftForkDescPushBack(bip9_softforks, consensusParams, static_cast<Consensus::DeploymentPos>(pos)); | ||
|
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 don't add an empty line 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.
Oops, removed.
Thanks, much better. utACK 8cf8b06. |
8cf8b06
to
e4d0af4
Compare
utACK e4d0af4 |
…k deployments instead of hard coding e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow) Pull request description: Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info. Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
…oft fork deployments instead of hard coding e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow) Pull request description: Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info. Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
…oft fork deployments instead of hard coding e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow) Pull request description: Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info. Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
…oft fork deployments instead of hard coding e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow) Pull request description: Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info. Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
…oft fork deployments instead of hard coding e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow) Pull request description: Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info. Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
…oft fork deployments instead of hard coding e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow) Pull request description: Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info. Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
…oft fork deployments instead of hard coding e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow) Pull request description: Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info. Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
Instead of hard coding which deployment statistics should be listed in the
getblockchaininfo
output, loop through the available deployments (except testdummy) when displaying their deployment info.