diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1883,8 +1883,7 @@ */ static bool ConnectBlock(const Config &config, const CBlock &block, CValidationState &state, CBlockIndex *pindex, - CCoinsViewCache &view, const CChainParams &chainparams, - bool fJustCheck = false) { + CCoinsViewCache &view, bool fJustCheck = false) { AssertLockHeld(cs_main); int64_t nTimeStart = GetTimeMicros(); @@ -1902,7 +1901,7 @@ // Special case for the genesis block, skipping connection of its // transactions (its coinbase is unspendable) - if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) { + if (block.GetHash() == config.GetChainParams().GetConsensus().hashGenesisBlock) { if (!fJustCheck) { view.SetBestBlock(pindex->GetBlockHash()); } @@ -1925,7 +1924,7 @@ pindexBestHeader->GetAncestor(pindex->nHeight) == pindex && pindexBestHeader->nChainWork >= UintToArith256( - chainparams.GetConsensus().nMinimumChainWork)) { + config.GetChainParams().GetConsensus().nMinimumChainWork)) { // This block is a member of the assumed verified chain and an // ancestor of the best header. The equivalent time check // discourages hashpower from extorting the network via DOS @@ -1942,7 +1941,7 @@ fScriptChecks = (GetBlockProofEquivalentTime( *pindexBestHeader, *pindex, *pindexBestHeader, - chainparams.GetConsensus()) <= 60 * 60 * 24 * 7 * 2); + config.GetChainParams().GetConsensus()) <= 60 * 60 * 24 * 7 * 2); } } } @@ -1987,12 +1986,12 @@ // we're on the known chain at height greater than where BIP34 activated, we // can save the db accesses needed for the BIP30 check. CBlockIndex *pindexBIP34height = - pindex->pprev->GetAncestor(chainparams.GetConsensus().BIP34Height); + pindex->pprev->GetAncestor(config.GetChainParams().GetConsensus().BIP34Height); // Only continue to enforce if we're below BIP34 activation height or the // block hash at that height doesn't correspond. fEnforceBIP30 = fEnforceBIP30 && (!pindexBIP34height || !(pindexBIP34height->GetBlockHash() == - chainparams.GetConsensus().BIP34Hash)); + config.GetChainParams().GetConsensus().BIP34Hash)); if (fEnforceBIP30) { for (const auto &tx : block.vtx) { @@ -2009,7 +2008,7 @@ // Start enforcing BIP68 (sequence locks) using versionbits logic. int nLockTimeFlags = 0; - if (VersionBitsState(pindex->pprev, chainparams.GetConsensus(), + if (VersionBitsState(pindex->pprev, config.GetChainParams().GetConsensus(), Consensus::DEPLOYMENT_CSV, versionbitscache) == THRESHOLD_ACTIVE) { nLockTimeFlags |= LOCKTIME_VERIFY_SEQUENCE; @@ -2126,7 +2125,7 @@ nTimeConnect * 0.000001); Amount blockReward = - nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()); + nFees + GetBlockSubsidy(pindex->nHeight, config.GetChainParams().GetConsensus()); if (block.vtx[0]->GetValueOut() > blockReward) { return state.DoS(100, error("ConnectBlock(): coinbase pays too much " "(actual=%d vs limit=%d)", @@ -2163,7 +2162,7 @@ return error("ConnectBlock(): FindUndoPos failed"); } if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), - chainparams.DiskMagic())) { + config.GetChainParams().DiskMagic())) { return AbortNode(state, "Failed to write undo data"); } @@ -2618,8 +2617,7 @@ (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001); { CCoinsViewCache view(pcoinsTip); - bool rv = ConnectBlock(config, blockConnecting, state, pindexNew, view, - config.GetChainParams()); + bool rv = ConnectBlock(config, blockConnecting, state, pindexNew, view); GetMainSignals().BlockChecked(blockConnecting, state); if (!rv) { if (state.IsInvalid()) { @@ -3853,8 +3851,7 @@ return error("%s: Consensus::ContextualCheckBlock: %s", __func__, FormatStateMessage(state)); } - if (!ConnectBlock(config, block, state, &indexDummy, viewNew, chainparams, - true)) { + if (!ConnectBlock(config, block, state, &indexDummy, viewNew, true)) { return false; } @@ -4233,8 +4230,6 @@ LogPrintf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel); - const CChainParams &chainparams = config.GetChainParams(); - CCoinsViewCache coins(coinsview); CBlockIndex *pindexState = chainActive.Tip(); CBlockIndex *pindexFailure = nullptr; @@ -4353,8 +4348,7 @@ "VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString()); } - if (!ConnectBlock(config, block, state, pindex, coins, - chainparams)) { + if (!ConnectBlock(config, block, state, pindex, coins)) { return error( "VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());