Skip to content

Commit

Permalink
Use block height 0 when checking for genesis block
Browse files Browse the repository at this point in the history
There is no previous block when validating the genesis block as part of contextual checks,
so block height cannot be used. Consensus parameters are now taken from height 0 for
the genesis check, and from block height only if the it's not the genesis block.
  • Loading branch information
Ross Nicoll committed Jul 26, 2015
1 parent 8cd835c commit d97a37f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2747,14 +2747,14 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex * const pindexPrev)
{
const CChainParams& chainParams = Params();
const Consensus::Params& consensusParams = chainParams.GetConsensus(pindexPrev->nHeight + 1);
uint256 hash = block.GetHash();
if (hash == consensusParams.hashGenesisBlock)
if (hash == chainParams.GetConsensus(0).hashGenesisBlock)
return true;

assert(pindexPrev);

int nHeight = pindexPrev->nHeight+1;
const Consensus::Params& consensusParams = chainParams.GetConsensus(nHeight);

// Disallow legacy blocks after merge-mining start.
if (!consensusParams.fAllowLegacyBlocks
Expand Down

0 comments on commit d97a37f

Please sign in to comment.