[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
  1. achow101 commented at 0:43 am on July 19, 2017: member
    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.
  2. 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 to DeploymentPos? Nevermind, enums don’t suport ++.
  3. jonasschnelli commented at 8:19 am on July 19, 2017: contributor
    utACK 4048d77fb462268f374edd420a827d91be8af11f
  4. jonasschnelli added the label Docs and Output on Jul 19, 2017
  5. jnewbery commented at 3:45 pm on August 10, 2017: member

    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?

  6. achow101 commented at 4:51 pm on August 10, 2017: member
    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 getblockchaininfo bothered me.
  7. promag commented at 3:11 pm on October 31, 2017: member

    ACK 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}
    
  8. laanwj commented at 1:33 pm on November 9, 2017: member

    Nit, 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.

  9. MarcoFalke added the label RPC/REST/ZMQ on Nov 18, 2017
  10. laanwj commented at 11:04 am on November 30, 2017: member
    Ping @achow101
  11. laanwj removed the label Docs on Nov 30, 2017
  12. laanwj added the label Refactoring on Nov 30, 2017
  13. achow101 commented at 4:04 pm on November 30, 2017: member
    pong @laanwj
  14. laanwj commented at 4:10 pm on November 30, 2017: member
    @achow101 can you respond to @promag’s nit? If you don’t want to do it that’s fine just say so, but if you don’t respond to review comments your PR will be in limbo.
  15. achow101 force-pushed on Nov 30, 2017
  16. achow101 commented at 4:35 pm on November 30, 2017: member
    Done.
  17. 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.
  18. promag commented at 4:47 pm on November 30, 2017: member

    Thanks, much better.

    utACK 8cf8b06.

  19. Loop through the bip9 soft fork deployments instead of hard coding e4d0af4fe1
  20. achow101 force-pushed on Nov 30, 2017
  21. laanwj commented at 5:19 pm on November 30, 2017: member
    utACK e4d0af4
  22. laanwj merged this on Nov 30, 2017
  23. laanwj closed this on Nov 30, 2017

  24. laanwj referenced this in commit 9e38d35744 on Nov 30, 2017
  25. PastaPastaPasta referenced this in commit da77fb8105 on Mar 23, 2020
  26. PastaPastaPasta referenced this in commit a227cc8cec on Mar 28, 2020
  27. PastaPastaPasta referenced this in commit a4d625f0c6 on Mar 29, 2020
  28. PastaPastaPasta referenced this in commit 2c4f38d19b on Mar 31, 2020
  29. UdjinM6 referenced this in commit 0aa76451ae on Mar 31, 2020
  30. PastaPastaPasta referenced this in commit 58422516d0 on Apr 1, 2020
  31. ckti referenced this in commit 13c4351102 on Mar 28, 2021
  32. DrahtBot 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-07-05 19:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me