Abstract out the command line options for block assembly #9868

pull sipa wants to merge 2 commits into bitcoin:master from sipa:assembleroptions changing 3 files +68 −37
  1. sipa commented at 0:17 am on February 27, 2017: member
    It feels strange that BlockAssembler’s constructor inspects command-line options to set its configurable fields. This PR introduces a BlockAssembler::Options struct which can be constructed from the command-line options, but is constructed with static values for tests instead.
  2. Abstract out BlockAssembler options 48faf0bf63
  3. Run miner_tests with fixed options 277b472fb2
  4. fanquake added the label Mining on Feb 27, 2017
  5. in src/miner.cpp: in 277b472fb2
    84+{
    85+    blockMinFeeRate = options.blockMinFeeRate;
    86+    // Limit weight to between 4K and MAX_BLOCK_WEIGHT-4K for sanity:
    87+    nBlockMaxWeight = std::max<size_t>(4000, std::min<size_t>(MAX_BLOCK_WEIGHT - 4000, options.nBlockMaxWeight));
    88+    // Limit size to between 1K and MAX_BLOCK_SERIALIZED_SIZE-1K for sanity:
    89+    nBlockMaxSize = std::max<size_t>(1000, std::min<size_t>(MAX_BLOCK_SERIALIZED_SIZE - 1000, options.nBlockMaxSize));
    


    luke-jr commented at 2:31 am on February 27, 2017:
    Why not do the std::max on the Options object once, and just have a reference to that object on the BlockAssembler?
  6. in src/miner.cpp: in 277b472fb2
    71@@ -72,43 +72,56 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
    72     return nNewTime - nOldTime;
    73 }
    74 
    75-BlockAssembler::BlockAssembler(const CChainParams& _chainparams)
    76-    : chainparams(_chainparams)
    77+BlockAssembler::Options::Options() {
    78+    blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
    79+    nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
    80+    nBlockMaxSize = DEFAULT_BLOCK_MAX_SIZE;
    


    luke-jr commented at 2:32 am on February 27, 2017:
    Is there ever a time we would want to just assume the hard-coded defaults? Leaving the fields uninitialised has the benefit of exposing bugs in static analysis and/or valgrind/memorysanitizer.
  7. jonasschnelli approved
  8. jonasschnelli commented at 9:27 am on February 28, 2017: contributor
    utACK 277b472fb21db824fea9625a0287640fab4df282
  9. sdaftuar commented at 8:54 pm on February 28, 2017: member
    ACK 277b472
  10. laanwj commented at 11:37 am on March 1, 2017: member

    It feels strange that BlockAssembler’s constructor inspects command-line options to set its configurable fields.

    Yes that is strange, utACK 277b472

  11. laanwj merged this on Mar 1, 2017
  12. laanwj closed this on Mar 1, 2017

  13. laanwj referenced this in commit cbdb4732f1 on Mar 1, 2017
  14. theuni commented at 2:16 pm on March 1, 2017: member
    post-merge utACK. I love these kinds of separations!
  15. sipa deleted the branch on Jun 23, 2017
  16. PastaPastaPasta referenced this in commit 2036a1f5c6 on Dec 28, 2018
  17. PastaPastaPasta referenced this in commit 61bad50d8d on Dec 28, 2018
  18. PastaPastaPasta referenced this in commit 42882abb58 on Dec 28, 2018
  19. PastaPastaPasta referenced this in commit d60ea0c04e on Dec 28, 2018
  20. PastaPastaPasta referenced this in commit 25289862b4 on Dec 28, 2018
  21. PastaPastaPasta referenced this in commit 31e2467810 on Dec 29, 2018
  22. PastaPastaPasta referenced this in commit c2f1d4292a on Dec 29, 2018
  23. PastaPastaPasta referenced this in commit f563c162e5 on Dec 29, 2018
  24. PastaPastaPasta referenced this in commit cbd404fa11 on Dec 29, 2018
  25. PastaPastaPasta referenced this in commit 34e0a84851 on Dec 31, 2018
  26. PastaPastaPasta referenced this in commit 8b1a0b20cb on Dec 31, 2018
  27. PastaPastaPasta referenced this in commit 412c2ef941 on Jan 2, 2019
  28. PastaPastaPasta referenced this in commit 92bf45873f on Jan 2, 2019
  29. PastaPastaPasta referenced this in commit 6dec3d4722 on Jan 3, 2019
  30. PastaPastaPasta referenced this in commit 0ed83dbad9 on Jan 3, 2019
  31. PastaPastaPasta referenced this in commit dc04f526b0 on Jan 3, 2019
  32. PastaPastaPasta referenced this in commit 9bb1565ebe on Jan 3, 2019
  33. PastaPastaPasta referenced this in commit d87a8b6b74 on Jan 5, 2019
  34. PastaPastaPasta referenced this in commit 7aa4cbb187 on Jan 5, 2019
  35. PastaPastaPasta referenced this in commit c8564e9ca4 on Jan 7, 2019
  36. PastaPastaPasta referenced this in commit 4263b953cf on Jan 7, 2019
  37. PastaPastaPasta referenced this in commit 124aade6fe on Jan 7, 2019
  38. PastaPastaPasta referenced this in commit 73761a6a02 on Jan 7, 2019
  39. PastaPastaPasta referenced this in commit 947b350799 on Jan 21, 2019
  40. PastaPastaPasta referenced this in commit a78cbe3573 on Jan 21, 2019
  41. PastaPastaPasta referenced this in commit 3ddf3dc62b on Jan 23, 2019
  42. PastaPastaPasta referenced this in commit f9c585776b on Jan 23, 2019
  43. PastaPastaPasta referenced this in commit 0cd4e4351d on Jan 25, 2019
  44. PastaPastaPasta referenced this in commit e502b70cc6 on Jan 25, 2019
  45. PastaPastaPasta referenced this in commit b173ccee31 on Jan 25, 2019
  46. PastaPastaPasta referenced this in commit c2a80c42d3 on Jan 25, 2019
  47. 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-11-21 09:12 UTC

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