@@ -76,9 +76,11 @@ void RegenerateCommitments(CBlock& block, ChainstateManager& chainman)
7676 block.hashMerkleRoot = BlockMerkleRoot (block);
7777}
7878
79- static BlockAssembler::Options ClampOptions (BlockAssembler::Options options)
79+ static BlockCreateOptions ClampOptions (BlockCreateOptions options)
8080{
81- // Apply DEFAULT_BLOCK_RESERVED_WEIGHT and DEFAULT_BLOCK_MAX_WEIGHT when the caller left it unset.
81+ // Typically block_reserved_weight and block_max_weight are set by
82+ // ApplyMiningDefaults before the constructor calls this; value_or(DEFAULT_...)
83+ // only affects (test) call sites that don't go through the Mining interface.
8284 options.block_reserved_weight = std::clamp<size_t >(options.block_reserved_weight .value_or (DEFAULT_BLOCK_RESERVED_WEIGHT), MINIMUM_BLOCK_RESERVED_WEIGHT, MAX_BLOCK_WEIGHT);
8385 options.coinbase_output_max_additional_sigops = std::clamp<size_t >(options.coinbase_output_max_additional_sigops , 0 , MAX_BLOCK_SIGOPS_COST);
8486 // Limit weight to between block_reserved_weight and MAX_BLOCK_WEIGHT for sanity:
@@ -87,26 +89,26 @@ static BlockAssembler::Options ClampOptions(BlockAssembler::Options options)
8789 return options;
8890}
8991
90- BlockAssembler::BlockAssembler (Chainstate& chainstate, const CTxMemPool* mempool, const Options& options)
92+ BlockAssembler::BlockAssembler (Chainstate& chainstate,
93+ const CTxMemPool* mempool,
94+ MiningArgs mining_args,
95+ BlockCreateOptions options)
9196 : chainparams{chainstate.m_chainman .GetParams ()},
9297 m_mempool{options.use_mempool ? mempool : nullptr },
9398 m_chainstate{chainstate},
99+ m_mining_args{mining_args},
94100 m_options{ClampOptions (options)}
95101{
96102}
97103
98- void ApplyArgsManOptions (const ArgsManager & args, BlockAssembler::Options & options)
104+ void ApplyMiningDefaults (const MiningArgs & args, BlockCreateOptions & options)
99105{
100106 // Block resource limits
101107 if (!options.block_max_weight ) {
102- options.block_max_weight = args.GetIntArg ( " -blockmaxweight " ) ;
108+ options.block_max_weight = args.default_block_max_weight ;
103109 }
104- if (const auto blockmintxfee{args.GetArg (" -blockmintxfee" )}) {
105- if (const auto parsed{ParseMoney (*blockmintxfee)}) options.blockMinFeeRate = CFeeRate{*parsed};
106- }
107- options.print_modified_fee = args.GetBoolArg (" -printpriority" , options.print_modified_fee );
108110 if (!options.block_reserved_weight ) {
109- options.block_reserved_weight = args.GetIntArg ( " -blockreservedweight " ) ;
111+ options.block_reserved_weight = args.default_block_reserved_weight ;
110112 }
111113}
112114
@@ -271,7 +273,7 @@ void BlockAssembler::AddToBlock(const CTxMemPoolEntry& entry)
271273 nBlockSigOpsCost += entry.GetSigOpCost ();
272274 nFees += entry.GetFee ();
273275
274- if (m_options .print_modified_fee ) {
276+ if (m_mining_args .print_modified_fee ) {
275277 LogInfo (" fee rate %s txid %s\n " ,
276278 CFeeRate (entry.GetModifiedFee (), entry.GetTxSize ()).ToString (),
277279 entry.GetTx ().GetHash ().ToString ());
@@ -297,7 +299,7 @@ void BlockAssembler::addChunks()
297299
298300 while (selected_transactions.size () > 0 ) {
299301 // Check to see if min fee rate is still respected.
300- if (chunk_feerate_vsize << m_options .blockMinFeeRate .GetFeePerVSize ()) {
302+ if (chunk_feerate_vsize << m_mining_args .blockMinFeeRate .GetFeePerVSize ()) {
301303 // Everything else we might consider has a lower feerate
302304 return ;
303305 }
@@ -365,7 +367,8 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
365367 CTxMemPool* mempool,
366368 const std::unique_ptr<CBlockTemplate>& block_template,
367369 const BlockWaitOptions& options,
368- const BlockAssembler::Options& assemble_options,
370+ const MiningArgs& mining_args,
371+ const BlockCreateOptions& assemble_options,
369372 bool & interrupt_wait)
370373{
371374 // Delay calculating the current template fees, just in case a new block
@@ -426,8 +429,9 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
426429 auto new_tmpl{BlockAssembler{
427430 chainman.ActiveChainstate (),
428431 mempool,
429- assemble_options}
430- .CreateNewBlock ()};
432+ mining_args,
433+ assemble_options
434+ }.CreateNewBlock ()};
431435
432436 // If the tip changed, return the new template regardless of its fees.
433437 if (tip_changed) return new_tmpl;
0 commit comments