mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Bugfix: Don't check the genesis block header before accepting it
This fixes an error triggered when running with -reindex after #5975
This commit is contained in:
parent
247b91449a
commit
36c97b4e5d
@ -2809,6 +2809,8 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
||||
uint256 hash = block.GetHash();
|
||||
BlockMap::iterator miSelf = mapBlockIndex.find(hash);
|
||||
CBlockIndex *pindex = NULL;
|
||||
if (hash != chainparams.GetConsensus().hashGenesisBlock) {
|
||||
|
||||
if (miSelf != mapBlockIndex.end()) {
|
||||
// Block header is already known.
|
||||
pindex = miSelf->second;
|
||||
@ -2824,21 +2826,20 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
||||
|
||||
// Get prev block index
|
||||
CBlockIndex* pindexPrev = NULL;
|
||||
if (hash != chainparams.GetConsensus().hashGenesisBlock) {
|
||||
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
|
||||
if (mi == mapBlockIndex.end())
|
||||
return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
|
||||
pindexPrev = (*mi).second;
|
||||
if (pindexPrev->nStatus & BLOCK_FAILED_MASK)
|
||||
return state.DoS(100, error("%s: prev block invalid", __func__), REJECT_INVALID, "bad-prevblk");
|
||||
}
|
||||
|
||||
assert(pindexPrev);
|
||||
if (fCheckpointsEnabled && !CheckIndexAgainstCheckpoint(pindexPrev, state, chainparams, hash))
|
||||
return error("%s: CheckIndexAgainstCheckpoint(): %s", __func__, state.GetRejectReason().c_str());
|
||||
|
||||
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
||||
return false;
|
||||
|
||||
}
|
||||
if (pindex == NULL)
|
||||
pindex = AddToBlockIndex(block);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user