Merge #20868: validation: remove redundant check on pindex

c943282b5e validation: remove redundant check on pindex (jarolrod)

Pull request description:

  This removes a redundant check on `pindex` being a `nullptr`. By the time we get to this step `pindex` is always a `nullptr` as the branch where it has been set would have already returned.

  Closes #19223

ACKs for top commit:
  Zero-1729:
    re-ACK c943282
  ajtowns:
    ACK c943282b5e - code review only
  MarcoFalke:
    review ACK c943282b5e 📨
  theStack:
    re-ACK c943282b5e

Tree-SHA512: d2dc58206be61d2897b0703ee93af67abed492a80e84ea03dcfbf7116833173da3bdafa18ff80422d5296729d5254d57cc1db03fdaf817c8f57c62c3abef673c
This commit is contained in:
MarcoFalke 2021-02-01 10:56:19 +01:00
commit 87394b6741
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25

View file

@ -3558,11 +3558,10 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
// Check for duplicate
uint256 hash = block.GetHash();
BlockMap::iterator miSelf = m_block_index.find(hash);
CBlockIndex *pindex = nullptr;
if (hash != chainparams.GetConsensus().hashGenesisBlock) {
if (miSelf != m_block_index.end()) {
// Block header is already known.
pindex = miSelf->second;
CBlockIndex* pindex = miSelf->second;
if (ppindex)
*ppindex = pindex;
if (pindex->nStatus & BLOCK_FAILED_MASK) {
@ -3631,8 +3630,7 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
}
}
}
if (pindex == nullptr)
pindex = AddToBlockIndex(block);
CBlockIndex* pindex = AddToBlockIndex(block);
if (ppindex)
*ppindex = pindex;