From df08a626e0440457ae0d1966439fd956c27ae2fe Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 20 Oct 2014 02:10:03 +0000 Subject: TestBlockValidity function for CBlock proposals (used by CreateNewBlock) --- src/miner.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src/miner.cpp') diff --git a/src/miner.cpp b/src/miner.cpp index d7ecd5e40e..200498d109 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -321,22 +321,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblock->nNonce = 0; pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); - CBlockIndex indexDummy(*pblock); - indexDummy.pprev = pindexPrev; - indexDummy.nHeight = pindexPrev->nHeight + 1; - CCoinsViewCache viewNew(pcoinsTip); CValidationState state; - // NOTE: CheckBlockHeader is called by CheckBlock - if (!ContextualCheckBlockHeader(*pblock, state, pindexPrev)) - throw std::runtime_error("CreateNewBlock() : ContextualCheckBlockHeader failed"); - if (!CheckBlock(*pblock, state, false, false)) - throw std::runtime_error("CreateNewBlock() : CheckBlock failed"); - if (!ContextualCheckBlock(*pblock, state, pindexPrev)) - throw std::runtime_error("CreateNewBlock() : ContextualCheckBlock failed"); - if (!ConnectBlock(*pblock, state, &indexDummy, viewNew, true)) - throw std::runtime_error("CreateNewBlock() : ConnectBlock failed"); - if (!state.IsValid()) - throw std::runtime_error("CreateNewBlock() : State is not valid"); + if (!TestBlockValidity(state, *pblock, pindexPrev, false, false)) + throw std::runtime_error("CreateNewBlock() : TestBlockValidity failed"); } return pblocktemplate.release(); -- cgit v1.2.3