@@ -2810,36 +2810,37 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
2810
2810
uint256 hash = block.GetHash ();
2811
2811
BlockMap::iterator miSelf = mapBlockIndex.find (hash);
2812
2812
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 ) {
2822
2814
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
+ }
2825
2824
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 ;
2829
2830
BlockMap::iterator mi = mapBlockIndex.find (block.hashPrevBlock );
2830
2831
if (mi == mapBlockIndex.end ())
2831
2832
return state.DoS (10 , error (" %s: prev block not found" , __func__), 0 , " bad-prevblk" );
2832
2833
pindexPrev = (*mi).second ;
2833
2834
if (pindexPrev->nStatus & BLOCK_FAILED_MASK)
2834
2835
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 ());
2839
2836
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 ());
2842
2840
2841
+ if (!ContextualCheckBlockHeader (block, state, pindexPrev))
2842
+ return false ;
2843
+ }
2843
2844
if (pindex == NULL )
2844
2845
pindex = AddToBlockIndex (block);
2845
2846
0 commit comments