|
25 | 25 | #include <util/system.h> |
26 | 26 | #include <validationinterface.h> |
27 | 27 |
|
| 28 | +#include <dynafed.h> |
28 | 29 |
|
29 | 30 | #include <algorithm> |
30 | 31 | #include <queue> |
@@ -101,7 +102,7 @@ void BlockAssembler::resetBlock() |
101 | 102 | Optional<int64_t> BlockAssembler::m_last_block_num_txs{nullopt}; |
102 | 103 | Optional<int64_t> BlockAssembler::m_last_block_weight{nullopt}; |
103 | 104 |
|
104 | | -std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, int min_tx_age) |
| 105 | +std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, int min_tx_age, ConsensusParamEntry* proposed_entry) |
105 | 106 | { |
106 | 107 | assert(min_tx_age >= 0); |
107 | 108 | int64_t nTimeStart = GetTimeMicros(); |
@@ -165,7 +166,16 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc |
165 | 166 | // transaction (which in most cases can be a no-op). |
166 | 167 | fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus()); |
167 | 168 |
|
168 | | - if (g_signed_blocks) { |
| 169 | + if (IsDynaFedEnabled(pindexPrev, chainparams.GetConsensus())) { |
| 170 | + ConsensusParamEntry current_params = ComputeNextBlockCurrentParameters(chainActive.Tip(), chainparams.GetConsensus()); |
| 171 | + DynaFedParams block_params(current_params, proposed_entry ? *proposed_entry : ConsensusParamEntry()); |
| 172 | + pblock->m_dyna_params = block_params; |
| 173 | + nBlockWeight += ::GetSerializeSize(block_params, PROTOCOL_VERSION)*WITNESS_SCALE_FACTOR; |
| 174 | + nBlockWeight += current_params.m_sbs_wit_limit; // Note witness discount |
| 175 | + assert(pblock->proof.IsNull()); |
| 176 | + |
| 177 | + } else if (g_signed_blocks) { |
| 178 | + // Old style signed blocks |
169 | 179 | // Pad block weight by block proof fields (including upper-bound of signature) |
170 | 180 | nBlockWeight += chainparams.GetConsensus().signblockscript.size() * WITNESS_SCALE_FACTOR; |
171 | 181 | nBlockWeight += chainparams.GetConsensus().max_block_signature_size * WITNESS_SCALE_FACTOR; |
|
0 commit comments