diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -140,8 +140,9 @@ assert(pindexPrev != nullptr); nHeight = pindexPrev->nHeight + 1; - pblock->nVersion = - ComputeBlockVersion(pindexPrev, chainparams.GetConsensus()); + const Consensus::Params &consensusParams = chainparams.GetConsensus(); + + pblock->nVersion = ComputeBlockVersion(pindexPrev, consensusParams); // -regtest only: allow overriding block.nVersion with // -blockversion=N to test forking scenarios if (chainparams.MineBlocksOnDemand()) { @@ -159,7 +160,7 @@ int nDescendantsUpdated = 0; addPackageTxs(nPackagesSelected, nDescendantsUpdated); - if (IsMagneticAnomalyEnabled(chainparams.GetConsensus(), pindexPrev)) { + if (IsMagneticAnomalyEnabled(consensusParams, pindexPrev)) { // If magnetic anomaly is enabled, we make sure transaction are // canonically ordered. std::sort(std::begin(pblocktemplate->entries) + 1, @@ -186,7 +187,7 @@ coinbaseTx.vout.resize(1); coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn; coinbaseTx.vout[0].nValue = - nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus()); + nFees + GetBlockSubsidy(nHeight, consensusParams); coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0; // Make sure the coinbase is big enough. @@ -207,9 +208,8 @@ // Fill in header. pblock->hashPrevBlock = pindexPrev->GetBlockHash(); - UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); - pblock->nBits = - GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus()); + UpdateTime(pblock, consensusParams, pindexPrev); + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); pblock->nNonce = 0; pblocktemplate->entries[0].sigOpCount = GetSigOpCountWithoutP2SH( *pblocktemplate->entries[0].tx, STANDARD_SCRIPT_VERIFY_FLAGS);