Skip to content

Commit

Permalink
Merge pull request #3 from shafisher/fix_validation_height
Browse files Browse the repository at this point in the history
validation: change pindexPrev->nHeight + 1 to nHeight
  • Loading branch information
instagibbs authored Nov 13, 2018
2 parents 1e19efa + 3392181 commit 078d20f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3984,7 +3984,9 @@ 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 (!CheckChallenge(block, *pindexPrev, consensusParams))
return state.DoS(100, false, REJECT_INVALID, "bad-diffbits", false, "incorrect proof of work");
Expand All @@ -3994,7 +3996,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
return state.Invalid(false, REJECT_INVALID, "time-too-old", "block's timestamp is too early");

// Check height in header against prev
if ((uint32_t)pindexPrev->nHeight + 1 != block.nHeight)
if ((uint32_t)nHeight != block.nHeight)
return state.Invalid(error("%s: block height in header is incorrect", __func__),
REJECT_INVALID, "bad-header-height");

Expand Down

0 comments on commit 078d20f

Please sign in to comment.