diff options
| author | Luke Dashjr <[email protected]> | 2014-10-16 03:50:33 +0000 |
|---|---|---|
| committer | Luke Dashjr <[email protected]> | 2014-11-18 19:20:10 +0000 |
| commit | 4ea1be7fb84a397222754473c2bc315e3665ff18 (patch) | |
| tree | 45568c5b462cfb6cc2ba1e4eab69853d15c50c6c /src/miner.cpp | |
| parent | Abstract context-dependent block checking from acceptance (diff) | |
| download | discoin-4ea1be7fb84a397222754473c2bc315e3665ff18.tar.xz discoin-4ea1be7fb84a397222754473c2bc315e3665ff18.zip | |
CreateNewBlock and miner_tests: Also check generated template is valid by CheckBlockHeader, ContextualCheckBlockHeader, CheckBlock, and ContextualCheckBlock
Diffstat (limited to 'src/miner.cpp')
| -rw-r--r-- | src/miner.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/miner.cpp b/src/miner.cpp index b5bfa9c7b..d7ecd5e40 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -326,8 +326,17 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) 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"); } return pblocktemplate.release(); |