aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2015-07-26 12:22:04 +0000
committerRoss Nicoll <[email protected]>2015-07-26 12:25:03 +0000
commitd97a37f4a9553ec6c0e58abf0d1e67621b4ea1e3 (patch)
tree5368cd349963752e3bfcd8d3970a1e51f1b5502d
parentMerge pull request #1201 from rnicoll/1.10-sync (diff)
downloaddiscoin-d97a37f4a9553ec6c0e58abf0d1e67621b4ea1e3.tar.xz
discoin-d97a37f4a9553ec6c0e58abf0d1e67621b4ea1e3.zip
Use block height 0 when checking for genesis block
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.
-rw-r--r--src/main.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index dfcd50310..ded32eb03 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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