diff --git a/src/miner.cpp b/src/miner.cpp index b19f2a8768..71dfebbbda 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -101,7 +102,7 @@ void BlockAssembler::resetBlock() Optional BlockAssembler::m_last_block_num_txs{nullopt}; Optional BlockAssembler::m_last_block_weight{nullopt}; -std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, int min_tx_age) +std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, int min_tx_age, ConsensusParamEntry* proposed_entry) { assert(min_tx_age >= 0); int64_t nTimeStart = GetTimeMicros(); @@ -165,7 +166,16 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc // transaction (which in most cases can be a no-op). fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus()); - if (g_signed_blocks) { + if (IsDynaFedEnabled(pindexPrev, chainparams.GetConsensus())) { + ConsensusParamEntry current_params = ComputeNextBlockCurrentParameters(chainActive.Tip(), chainparams.GetConsensus()); + DynaFedParams block_params(current_params, proposed_entry ? *proposed_entry : ConsensusParamEntry()); + pblock->m_dyna_params = block_params; + nBlockWeight += ::GetSerializeSize(block_params, PROTOCOL_VERSION)*WITNESS_SCALE_FACTOR; + nBlockWeight += current_params.m_sbs_wit_limit; // Note witness discount + assert(pblock->proof.IsNull()); + + } else if (g_signed_blocks) { + // Old style signed blocks // Pad block weight by block proof fields (including upper-bound of signature) nBlockWeight += chainparams.GetConsensus().signblockscript.size() * WITNESS_SCALE_FACTOR; nBlockWeight += chainparams.GetConsensus().max_block_signature_size * WITNESS_SCALE_FACTOR; diff --git a/src/miner.h b/src/miner.h index 2afeeb994f..3ff58812bd 100644 --- a/src/miner.h +++ b/src/miner.h @@ -159,7 +159,7 @@ public: BlockAssembler(const CChainParams& params, const Options& options); /** Construct a new block template with coinbase to scriptPubKeyIn. min_tx_age is in seconds */ - std::unique_ptr CreateNewBlock(const CScript& scriptPubKeyIn, int min_tx_age=0); + std::unique_ptr CreateNewBlock(const CScript& scriptPubKeyIn, int min_tx_age=0, ConsensusParamEntry* = nullptr); static Optional m_last_block_num_txs; static Optional m_last_block_weight;