diff --git a/src/main.cpp b/src/main.cpp index 60b8789f9..31881ad5f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4398,9 +4398,10 @@ bool ProcessNewBlock(CValidationState& state, const CChainParams& chainparams, c } /** - * This is only invoked by the miner. fCheckPOW is always false. + * This is only invoked by the miner. + * The block's proof-of-work is assumed invalid and not checked. */ -bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot) +bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckMerkleRoot) { AssertLockHeld(cs_main); assert(pindexPrev == chainActive.Tip()); @@ -4416,7 +4417,7 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, if (!ContextualCheckBlockHeader(block, state, chainparams, pindexPrev)) return false; // The following may be duplicative of the `CheckBlock` call within `ConnectBlock` - if (!CheckBlock(block, state, chainparams, verifier, fCheckPOW, fCheckMerkleRoot, true)) + if (!CheckBlock(block, state, chainparams, verifier, false, fCheckMerkleRoot, true)) return false; if (!ContextualCheckBlock(block, state, chainparams, pindexPrev, true)) return false; diff --git a/src/main.h b/src/main.h index 1595a955e..d3b9afea1 100644 --- a/src/main.h +++ b/src/main.h @@ -481,7 +481,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin * Check a block is completely valid from start to finish (only works on top * of our current best block, with cs_main held) */ -bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true); +bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckMerkleRoot); /** diff --git a/src/miner.cpp b/src/miner.cpp index 9721649d3..7c599ed88 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -619,7 +619,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); CValidationState state; - if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) + if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false)) throw std::runtime_error(std::string("CreateNewBlock(): TestBlockValidity failed: ") + state.GetRejectReason()); } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 07086422a..82d410e6f 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -529,7 +529,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return "inconclusive-not-best-prevblk"; CValidationState state; - TestBlockValidity(state, Params(), block, pindexPrev, false, true); + TestBlockValidity(state, Params(), block, pindexPrev, true); return BIP22ValidationResult(state); } }