diff options
| author | Wladimir J. van der Laan <[email protected]> | 2017-03-14 10:37:15 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2017-03-14 10:38:27 +0100 |
| commit | 1b046603b30ebfab6199a2f92015d507b248b590 (patch) | |
| tree | 90de4ab043e222a976d73f4d783f04682b0f0f4b /src/validation.cpp | |
| parent | Merge #9977: QA: getblocktemplate_longpoll.py should always use >0 fee tx (diff) | |
| parent | Assert ConnectBlock block and pIndex are the same block (diff) | |
| download | discoin-1b046603b30ebfab6199a2f92015d507b248b590.tar.xz discoin-1b046603b30ebfab6199a2f92015d507b248b590.zip | |
Merge #8665: Assert all the things!
4d51e9b Assert ConnectBlock block and pIndex are the same block (NicolasDorier)
972714c pow: GetNextWorkRequired never called with NULL pindexLast (Daniel Cousens)
cc44c8f ContextualCheckBlockHeader should never have pindexPrev to NULL (NicolasDorier)
Tree-SHA512: 7cc568bf9417267c335f21ec3d1505b26e56e5b3d5f4d3dbb555279489800aaa65a3bcd7bc376e274dd102912aec16ddbb18de2e2060b2667b41eb979cd9321e
Diffstat (limited to 'src/validation.cpp')
| -rw-r--r-- | src/validation.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 63918a3f3..be82026b3 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1714,7 +1714,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin CCoinsViewCache& view, const CChainParams& chainparams, bool fJustCheck) { AssertLockHeld(cs_main); - + assert(pindex); + // pindex->phashBlock can be null if called by CreateNewBlock/TestBlockValidity + assert((pindex->phashBlock == NULL) || + (*pindex->phashBlock == block.GetHash())); int64_t nTimeStart = GetTimeMicros(); // Check it again in case a previous version let a bad block in @@ -2948,7 +2951,8 @@ std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBloc bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) { - const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; + assert(pindexPrev != NULL); + const int nHeight = pindexPrev->nHeight + 1; // Check proof of work if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) return state.DoS(100, false, REJECT_INVALID, "bad-diffbits", false, "incorrect proof of work"); |