mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Merge ef19a193fc into merged_master (Bitcoin PR bitcoin/bitcoin#30356)
This commit is contained in:
commit
9cfa8d130d
6 changed files with 42 additions and 19 deletions
|
|
@ -72,14 +72,17 @@ void RegenerateCommitments(CBlock& block, ChainstateManager& chainman)
|
|||
|
||||
static BlockAssembler::Options ClampOptions(BlockAssembler::Options options)
|
||||
{
|
||||
// Limit weight to between 4K and DEFAULT_BLOCK_MAX_WEIGHT for sanity:
|
||||
options.nBlockMaxWeight = std::clamp<size_t>(options.nBlockMaxWeight, 4000, DEFAULT_BLOCK_MAX_WEIGHT);
|
||||
Assert(options.coinbase_max_additional_weight <= DEFAULT_BLOCK_MAX_WEIGHT);
|
||||
Assert(options.coinbase_output_max_additional_sigops <= MAX_BLOCK_SIGOPS_COST);
|
||||
// Limit weight to between coinbase_max_additional_weight and DEFAULT_BLOCK_MAX_WEIGHT for sanity:
|
||||
// Coinbase (reserved) outputs can safely exceed -blockmaxweight, but the rest of the block template will be empty.
|
||||
options.nBlockMaxWeight = std::clamp<size_t>(options.nBlockMaxWeight, options.coinbase_max_additional_weight, DEFAULT_BLOCK_MAX_WEIGHT);
|
||||
return options;
|
||||
}
|
||||
|
||||
BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options)
|
||||
: chainparams{chainstate.m_chainman.GetParams()},
|
||||
m_mempool{mempool},
|
||||
m_mempool{options.use_mempool ? mempool : nullptr},
|
||||
m_chainstate{chainstate},
|
||||
m_options{ClampOptions(options)}
|
||||
{
|
||||
|
|
@ -100,8 +103,8 @@ void BlockAssembler::resetBlock()
|
|||
inBlock.clear();
|
||||
|
||||
// Reserve space for coinbase tx
|
||||
nBlockWeight = 4000;
|
||||
nBlockSigOpsCost = 400;
|
||||
nBlockWeight = m_options.coinbase_max_additional_weight;
|
||||
nBlockSigOpsCost = m_options.coinbase_output_max_additional_sigops;
|
||||
|
||||
// These counters do not include coinbase tx
|
||||
nBlockTx = 0;
|
||||
|
|
@ -446,7 +449,7 @@ void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSele
|
|||
++nConsecutiveFailed;
|
||||
|
||||
if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight >
|
||||
m_options.nBlockMaxWeight - 4000) {
|
||||
m_options.nBlockMaxWeight - m_options.coinbase_max_additional_weight) {
|
||||
// Give up if we're close to full and haven't succeeded in a while
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue