Skip to content

Commit c943282

Browse files
committed
validation: remove redundant check on pindex
This removes a conditional that checks if pindex is equal to nullptr. This check is redundant because the branch where pindex is set returns at an earlier time. Additionaly, The independence of the earlier and later pindex is made clearer.
1 parent c175690 commit c943282

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/validation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,11 +3548,10 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
35483548
// Check for duplicate
35493549
uint256 hash = block.GetHash();
35503550
BlockMap::iterator miSelf = m_block_index.find(hash);
3551-
CBlockIndex *pindex = nullptr;
35523551
if (hash != chainparams.GetConsensus().hashGenesisBlock) {
35533552
if (miSelf != m_block_index.end()) {
35543553
// Block header is already known.
3555-
pindex = miSelf->second;
3554+
CBlockIndex* pindex = miSelf->second;
35563555
if (ppindex)
35573556
*ppindex = pindex;
35583557
if (pindex->nStatus & BLOCK_FAILED_MASK) {
@@ -3621,8 +3620,7 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
36213620
}
36223621
}
36233622
}
3624-
if (pindex == nullptr)
3625-
pindex = AddToBlockIndex(block);
3623+
CBlockIndex* pindex = AddToBlockIndex(block);
36263624

36273625
if (ppindex)
36283626
*ppindex = pindex;

0 commit comments

Comments
 (0)