getblockchaininfo
output, loop through the available deployments (except testdummy) when displaying their deployment info.
[RPC] getblockchaininfo: Loop through the bip9 soft fork deployments instead of hard coding #10874
pull achow101 wants to merge 1 commits into bitcoin:master from achow101:getblockchaininfo-bip9-loop changing 1 files +5 −4-
achow101 commented at 0:43 am on July 19, 2017: memberInstead of hard coding which deployment statistics should be listed in the
-
in src/rpc/blockchain.cpp:1188 in 4048d77fb4 outdated
1184@@ -1185,8 +1185,11 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) 1185 softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); 1186 softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); 1187 softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); 1188- BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV); 1189- BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT); 1190+ for (int BIP9SoftFork = Consensus::DEPLOYMENT_CSV; BIP9SoftFork != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++BIP9SoftFork) {
sipa commented at 0:45 am on July 19, 2017:Why convert to int and back toNevermind, enums don’t suportDeploymentPos
?++
.jonasschnelli commented at 8:19 am on July 19, 2017: contributorutACK 4048d77fb462268f374edd420a827d91be8af11fjonasschnelli added the label Docs and Output on Jul 19, 2017jnewbery commented at 3:45 pm on August 10, 2017: memberI’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?
achow101 commented at 4:51 pm on August 10, 2017: memberIt’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 withgetblockchaininfo
bothered me.promag commented at 3:11 pm on October 31, 2017: memberACK 4048d77.
Nit, make it so that the name is accessed in
BIP9SoftForkDescPushBack()
, so the loop would be:0for (int pos = Consensus::DEPLOYMENT_CSV; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) { 1 BIP9SoftForkDescPushBack(bip9_softforks, consensusParams, static_cast<Consensus::DeploymentPos>(pos)); 2}
laanwj commented at 1:33 pm on November 9, 2017: memberNit, make it so that the name is accessed in BIP9SoftForkDescPushBack(), so the loop would be:
I also prefer that to casting to int and back in the loop header.
MarcoFalke added the label RPC/REST/ZMQ on Nov 18, 2017laanwj removed the label Docs on Nov 30, 2017laanwj added the label Refactoring on Nov 30, 2017achow101 force-pushed on Nov 30, 2017achow101 commented at 4:35 pm on November 30, 2017: memberDone.in src/rpc/blockchain.cpp:1190 in 8cf8b0667d outdated
1184@@ -1185,8 +1185,10 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) 1185 softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); 1186 softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); 1187 softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); 1188- BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV); 1189- BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT); 1190+ for (int pos = Consensus::DEPLOYMENT_CSV; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) { 1191+ BIP9SoftForkDescPushBack(bip9_softforks, consensusParams, static_cast<Consensus::DeploymentPos>(pos)); 1192+
laanwj commented at 4:41 pm on November 30, 2017:please don’t add an empty line here
achow101 commented at 5:16 pm on November 30, 2017:Oops, removed.promag commented at 4:47 pm on November 30, 2017: memberThanks, much better.
utACK 8cf8b06.
Loop through the bip9 soft fork deployments instead of hard coding e4d0af4fe1achow101 force-pushed on Nov 30, 2017laanwj commented at 5:19 pm on November 30, 2017: memberutACK e4d0af4laanwj merged this on Nov 30, 2017laanwj closed this on Nov 30, 2017
laanwj referenced this in commit 9e38d35744 on Nov 30, 2017PastaPastaPasta referenced this in commit da77fb8105 on Mar 23, 2020PastaPastaPasta referenced this in commit a227cc8cec on Mar 28, 2020PastaPastaPasta referenced this in commit a4d625f0c6 on Mar 29, 2020PastaPastaPasta referenced this in commit 2c4f38d19b on Mar 31, 2020UdjinM6 referenced this in commit 0aa76451ae on Mar 31, 2020PastaPastaPasta referenced this in commit 58422516d0 on Apr 1, 2020ckti referenced this in commit 13c4351102 on Mar 28, 2021DrahtBot locked this on Sep 8, 2021
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 09:12 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 09:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me