Chainparams: Explicit Consensus::Params arg for almost all remaining functions #6163

pull jtimon wants to merge 1 commits into bitcoin:master from jtimon:chainparams-remaining-consensus changing 7 files +52 −45
  1. jtimon commented at 11:02 pm on May 19, 2015: contributor

    Explicitly pass Consensus::Params to functions:

    -CheckBlockIndex -DisconnectTip -GetTransaction -InvalidateBlock -ProcessGetData -ReadBlockFromDisk

    Without counting the following consensus functions (which is done in #6591):

    -CheckBlockHeader -CheckBlock -ContextualCheckBlockHeader -ContextualCheckBlock

    These are all the functions that use Consensus::Params but not CChainParams.

  2. jtimon renamed this:
    Chainparams: Explicit Consensus::Params arg for main:
    Chainparams: Explicit Consensus::Params arg for almost all remaining functions
    on May 19, 2015
  3. laanwj added the label Improvement on May 20, 2015
  4. laanwj commented at 11:12 am on May 20, 2015: member
    utACK
  5. jtimon force-pushed on Jun 2, 2015
  6. jtimon commented at 11:47 am on June 2, 2015: contributor
    Needed rebase after merging #5669 and #6173 (1)
  7. jtimon force-pushed on Jun 21, 2015
  8. jtimon commented at 12:10 pm on June 21, 2015: contributor
    Needed rebase (2)
  9. jtimon force-pushed on Jun 21, 2015
  10. jtimon commented at 9:15 am on July 4, 2015: contributor
    ping
  11. theuni commented at 9:53 pm on July 22, 2015: member
    ut ACK
  12. jgarzik commented at 7:29 pm on July 23, 2015: contributor

    Asking a dumb but sincere question: why?

    These parameters are global and constant to main, the module being modified. This change appears to add parameters for little apparent gain.

    Is this an intermediate step to the code being moved to libconsensus?

  13. jtimon commented at 7:43 pm on July 23, 2015: contributor

    Well, these are actually the methods that are not required for libconsensus but still use Consensus::Params. This is part of a bigger process of making CChainParams being explicitly passed as a const reference instead of using the Params() function all around. Basically that function is a way to hide a global that @theuni and I want to take out of chainparams.

    Passing it explicitly as a parameter is also good for testing. Eventually we should be able to remove this line: https://github.com/bitcoin/bitcoin/blob/master/src/test/test_bitcoin.cpp#L36

    #5970 is closed but contains this and more of the same, to get a better view of what all this is about. Some of the changes there are no longer necessary because other PRs have kindly incorporated it when they were changing the function’s parameters already.

  14. jtimon force-pushed on Aug 20, 2015
  15. jtimon commented at 11:51 pm on August 20, 2015: contributor
    Needed rebase. (3)
  16. in src/main.cpp: in 48c8e9de20 outdated
    2266@@ -2264,6 +2267,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
    2267  * that is already loaded (to avoid loading it again from disk).
    2268  */
    2269 bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
    2270+    const CChainParams& chainparams = Params();
    2271     CBlockIndex *pindexNewTip = NULL;
    2272     CBlockIndex *pindexMostWork = NULL;
    2273     const CChainParams& chainParams = Params();
    


    jonasschnelli commented at 7:39 am on August 27, 2015:
    Dup of +L2270?

    dcousens commented at 7:51 am on August 27, 2015:
    How did this even compile?

    jonasschnelli commented at 7:52 am on August 27, 2015:
    chainparams != chainParams (mind the uppercase P).

    dcousens commented at 7:54 am on August 27, 2015:
    @jtimon s/chainparams/chainParams/g might be in order :+1:

    jtimon commented at 8:22 am on August 27, 2015:
    Oops, lost in rebase. Thanks @jonasschnelli @dcousens for the extremely fast and helpful review. I will force push this and #5970 with the fix.

    jtimon commented at 8:58 am on August 27, 2015:
    I’m going to maintain chainparams instead of chainParams for uniformity across the codebase. When @theuni asked me #XXXX not to use “params” for both CChainParams and Consensus::Params I used “consensusParams” and “chainparams”, but he meant “chainParams” (btw pow.cpp still uses “params” #5812, no big deal). Now I’m afraid is too late for chainParams, even if he used that in one of his improvements to the checkpoints code #YYYY. I can dig all the PR numbers if anyone is interested, but I don’t have them at hand. Sorry for the misunderstanding between theuni and me, mostly my fault since I was the listener. I don’t think theuni is married to chainParams, I’m sure he’s fine with chainparams, he seemed mostly concerned about using the same variable name for 2 different types, I was just removing “Params().” all around.
  17. jtimon force-pushed on Aug 27, 2015
  18. jtimon commented at 9:06 am on August 27, 2015: contributor
    @jonasschnelli ’s nit solved, faster with the help of @dcousens .
  19. jtimon force-pushed on Aug 27, 2015
  20. jonasschnelli commented at 11:11 am on August 27, 2015: contributor
    Tested ACK (ran unit tests, did fiddle around with it in regtest). Gitian build: https://builds.jonasschnelli.ch/pulls/6163/
  21. in src/main.cpp: in 0aac17ad1f outdated
    2063@@ -2063,13 +2064,14 @@ static int64_t nTimePostConnect = 0;
    2064  * corresponding to pindexNew, to bypass loading it again from disk.
    2065  */
    2066 bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, const CBlock *pblock) {
    2067+    const CChainParams& chainparams = Params();
    


    dcousens commented at 11:26 am on August 27, 2015:
    Nit, why did you opt for chainparams over chainParams? camelCase is used consistently for most other variables.

    jtimon commented at 11:47 pm on August 27, 2015:
    Yep, but chainparams is used in more places than chainParams (my fault) so it seems too late. I explained this in more detail here: #6163 (review)
  22. dcousens commented at 11:28 am on August 27, 2015: contributor
    utACK and concept ACK
  23. jtimon force-pushed on Oct 20, 2015
  24. jtimon commented at 5:42 pm on October 20, 2015: contributor
    Needed rebase (4).
  25. jtimon force-pushed on Oct 30, 2015
  26. jtimon commented at 11:28 am on October 30, 2015: contributor
    Rebased (4).
  27. jtimon force-pushed on Oct 30, 2015
  28. MarcoFalke commented at 12:08 pm on October 30, 2015: member
  29. jtimon force-pushed on Oct 30, 2015
  30. Globals: Explicit Consensus::Params arg for main:
    -CheckBlockIndex
    -DisconnectTip
    -GetTransaction
    -InvalidateBlock
    -ProcessGetData
    -ReadBlockFromDisk
    87cbdb8b41
  31. jtimon force-pushed on Oct 30, 2015
  32. jtimon commented at 1:08 pm on October 30, 2015: contributor
    @MarcoFalke Yep, that’s all I could see in travis, but I wanted to build src/zmq/zmqpublishnotifier.o locally before squashing. Squashing now…
  33. laanwj merged this on Nov 10, 2015
  34. laanwj closed this on Nov 10, 2015

  35. laanwj referenced this in commit 77beab70de on Nov 10, 2015
  36. jtimon referenced this in commit 26b9a6d851 on Nov 10, 2015
  37. jtimon referenced this in commit d21cf9dc61 on Nov 11, 2015
  38. jtimon referenced this in commit 7267843745 on Nov 11, 2015
  39. laanwj referenced this in commit cb841e7513 on Nov 11, 2015
  40. zkbot referenced this in commit 6dcc7dd6ce on Mar 9, 2018
  41. zkbot referenced this in commit b094b02c0b on Mar 10, 2018
  42. zkbot referenced this in commit 59ef0e4c9c on Mar 12, 2018
  43. zkbot referenced this in commit 6dfd4baa1a on Mar 12, 2018
  44. zkbot referenced this in commit 05132fdca8 on Apr 6, 2018
  45. zkbot referenced this in commit 5fefc451a7 on Apr 13, 2018
  46. zkbot referenced this in commit 4c91fbf1c7 on May 31, 2018
  47. zkbot referenced this in commit 82d64f57c9 on Oct 24, 2018
  48. zkbot referenced this in commit 971f37e510 on Oct 25, 2018
  49. zkbot referenced this in commit 5b8b057c96 on Apr 5, 2019
  50. zkbot referenced this in commit a53fd12544 on Apr 9, 2019
  51. zkbot referenced this in commit fcf551eaaf on May 24, 2019
  52. zkbot referenced this in commit e25cb39033 on May 24, 2019
  53. zkbot referenced this in commit 3d37ebe9d8 on May 28, 2019
  54. MarcoFalke 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-17 06:12 UTC

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