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.
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-
sipa commented at 0:17 am on February 27, 2017: memberIt feels strange that
-
Abstract out BlockAssembler options 48faf0bf63
-
Run miner_tests with fixed options 277b472fb2
-
fanquake added the label Mining on Feb 27, 2017
-
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 thestd::max
on theOptions
object once, and just have a reference to that object on theBlockAssembler
? -
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. -
jonasschnelli approved
-
jonasschnelli commented at 9:27 am on February 28, 2017: contributorutACK 277b472fb21db824fea9625a0287640fab4df282
-
sdaftuar commented at 8:54 pm on February 28, 2017: memberACK 277b472
-
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
-
laanwj merged this on Mar 1, 2017
-
laanwj closed this on Mar 1, 2017
-
laanwj referenced this in commit cbdb4732f1 on Mar 1, 2017
-
theuni commented at 2:16 pm on March 1, 2017: memberpost-merge utACK. I love these kinds of separations!
-
sipa deleted the branch on Jun 23, 2017
-
PastaPastaPasta referenced this in commit 2036a1f5c6 on Dec 28, 2018
-
PastaPastaPasta referenced this in commit 61bad50d8d on Dec 28, 2018
-
PastaPastaPasta referenced this in commit 42882abb58 on Dec 28, 2018
-
PastaPastaPasta referenced this in commit d60ea0c04e on Dec 28, 2018
-
PastaPastaPasta referenced this in commit 25289862b4 on Dec 28, 2018
-
PastaPastaPasta referenced this in commit 31e2467810 on Dec 29, 2018
-
PastaPastaPasta referenced this in commit c2f1d4292a on Dec 29, 2018
-
PastaPastaPasta referenced this in commit f563c162e5 on Dec 29, 2018
-
PastaPastaPasta referenced this in commit cbd404fa11 on Dec 29, 2018
-
PastaPastaPasta referenced this in commit 34e0a84851 on Dec 31, 2018
-
PastaPastaPasta referenced this in commit 8b1a0b20cb on Dec 31, 2018
-
PastaPastaPasta referenced this in commit 412c2ef941 on Jan 2, 2019
-
PastaPastaPasta referenced this in commit 92bf45873f on Jan 2, 2019
-
PastaPastaPasta referenced this in commit 6dec3d4722 on Jan 3, 2019
-
PastaPastaPasta referenced this in commit 0ed83dbad9 on Jan 3, 2019
-
PastaPastaPasta referenced this in commit dc04f526b0 on Jan 3, 2019
-
PastaPastaPasta referenced this in commit 9bb1565ebe on Jan 3, 2019
-
PastaPastaPasta referenced this in commit d87a8b6b74 on Jan 5, 2019
-
PastaPastaPasta referenced this in commit 7aa4cbb187 on Jan 5, 2019
-
PastaPastaPasta referenced this in commit c8564e9ca4 on Jan 7, 2019
-
PastaPastaPasta referenced this in commit 4263b953cf on Jan 7, 2019
-
PastaPastaPasta referenced this in commit 124aade6fe on Jan 7, 2019
-
PastaPastaPasta referenced this in commit 73761a6a02 on Jan 7, 2019
-
PastaPastaPasta referenced this in commit 947b350799 on Jan 21, 2019
-
PastaPastaPasta referenced this in commit a78cbe3573 on Jan 21, 2019
-
PastaPastaPasta referenced this in commit 3ddf3dc62b on Jan 23, 2019
-
PastaPastaPasta referenced this in commit f9c585776b on Jan 23, 2019
-
PastaPastaPasta referenced this in commit 0cd4e4351d on Jan 25, 2019
-
PastaPastaPasta referenced this in commit e502b70cc6 on Jan 25, 2019
-
PastaPastaPasta referenced this in commit b173ccee31 on Jan 25, 2019
-
PastaPastaPasta referenced this in commit c2a80c42d3 on Jan 25, 2019
-
DrahtBot locked this on Sep 8, 2021