@@ -2810,36 +2810,37 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
28102810 uint256 hash = block.GetHash ();
28112811 BlockMap::iterator miSelf = mapBlockIndex.find (hash);
28122812 CBlockIndex *pindex = NULL ;
2813- if (miSelf != mapBlockIndex.end ()) {
2814- // Block header is already known.
2815- pindex = miSelf->second ;
2816- if (ppindex)
2817- *ppindex = pindex;
2818- if (pindex->nStatus & BLOCK_FAILED_MASK )
2819- return state.Invalid (error (" %s: block is marked invalid" , __func__), 0 , " duplicate" );
2820- return true ;
2821- }
2813+ if (hash != chainparams.GetConsensus ().hashGenesisBlock ) {
28222814
2823- if (!CheckBlockHeader (block, state))
2824- return false ;
2815+ if (miSelf != mapBlockIndex.end ()) {
2816+ // Block header is already known.
2817+ pindex = miSelf->second ;
2818+ if (ppindex)
2819+ *ppindex = pindex;
2820+ if (pindex->nStatus & BLOCK_FAILED_MASK )
2821+ return state.Invalid (error (" %s: block is marked invalid" , __func__), 0 , " duplicate" );
2822+ return true ;
2823+ }
28252824
2826- // Get prev block index
2827- CBlockIndex* pindexPrev = NULL ;
2828- if (hash != chainparams.GetConsensus ().hashGenesisBlock ) {
2825+ if (!CheckBlockHeader (block, state))
2826+ return false ;
2827+
2828+ // Get prev block index
2829+ CBlockIndex* pindexPrev = NULL ;
28292830 BlockMap::iterator mi = mapBlockIndex.find (block.hashPrevBlock );
28302831 if (mi == mapBlockIndex.end ())
28312832 return state.DoS (10 , error (" %s: prev block not found" , __func__), 0 , " bad-prevblk" );
28322833 pindexPrev = (*mi).second ;
28332834 if (pindexPrev->nStatus & BLOCK_FAILED_MASK )
28342835 return state.DoS (100 , error (" %s: prev block invalid" , __func__), REJECT_INVALID , " bad-prevblk" );
2835- }
2836- assert (pindexPrev);
2837- if (fCheckpointsEnabled && !CheckIndexAgainstCheckpoint (pindexPrev, state, chainparams, hash))
2838- return error (" %s: CheckIndexAgainstCheckpoint(): %s" , __func__, state.GetRejectReason ().c_str ());
28392836
2840- if (!ContextualCheckBlockHeader (block, state, pindexPrev))
2841- return false ;
2837+ assert (pindexPrev);
2838+ if (fCheckpointsEnabled && !CheckIndexAgainstCheckpoint (pindexPrev, state, chainparams, hash))
2839+ return error (" %s: CheckIndexAgainstCheckpoint(): %s" , __func__, state.GetRejectReason ().c_str ());
28422840
2841+ if (!ContextualCheckBlockHeader (block, state, pindexPrev))
2842+ return false ;
2843+ }
28432844 if (pindex == NULL )
28442845 pindex = AddToBlockIndex (block);
28452846
0 commit comments