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
Concept ACK
ACK
Perhaps make it:
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) {
@@ -3621,7 +3620,7 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
}
}
}
- pindex = AddToBlockIndex(block);
+ CBlockIndex *pindex = AddToBlockIndex(block);
so it's clear that the earlier pindex and the later pindex are independent?
3619 | @@ -3621,8 +3620,7 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS 3620 | } 3621 | } 3622 | } 3623 | - if (pindex == nullptr) 3624 | - pindex = AddToBlockIndex(block); 3625 | + CBlockIndex *pindex = AddToBlockIndex(block);
nit, CBlockIndex* pindex = ..., same in L3554.
Code review ACK 8be1a34f56ab8cb76b2d29b081c77c052bbad191.
Code review ACK 8be1a34f56ab8cb76b2d29b081c77c052bbad191 🥃
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.
re-ACK c943282b5e6312537f885c811d43120ce2f5b766
updated 8be1a34f56ab8cb76b2d29b081c77c052bbad191 -> c943282b5e6312537f885c811d43120ce2f5b766
Moved placement of pointer from name to type based on @promag suggestion
re-ACK c943282
ACK c943282b5e6312537f885c811d43120ce2f5b766 - code review only
Concept ACK
review ACK c943282b5e6312537f885c811d43120ce2f5b766 📨
<details><summary>Show signature and timestamp</summary>
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK c943282b5e6312537f885c811d43120ce2f5b766 📨
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhzXQwAyGILsbFtO9WYGBALSWon9GjpoziL7M+3LqQBj7D21YVmRmCZAL4FV8+8
++ebIBccAaI84vRn+TAjY74UYHv55EsxnwbZQzY44KivRc6kWUlf1AubA16WrW0z
jl3uP4qImGpy2nflWUjGsKkVtWg+Y/fAmgM0v2HiEGRsz+GmyidMpeIqFSjd07A4
uyavf+dC3BK8q9kM7EYhH7lZxlrbti9cdtM5f8gfccYWJg33tpBrEJAwJ0EXKjEh
6vYTEf7XYXlSX3FZQZ9q2fyyUecvfo05+G15anfGSGqzKnE5u4n438VamUuQtM3b
yQyMddEnmI0iodXOIRGtZhuxwFh7RDdyPUdG//fPqhHrvN4/7LG3vP1aBAO0MRZU
kT+pQWxvHHgCun7hgu4SCfdAMP2vFZ0aPTatj98KQ/t4wMJcboEVAL6l7c1aeOgU
GM/S9HoT3mjiV8VZTZ4ykC1HcgZFHRaSWiBRseJ8GmAg7DLKkTu9d/LFkX8VqdSY
pxX7K5l9
=o4SE
-----END PGP SIGNATURE-----
Timestamp of file with hash 76e16b7b369644db399a29534fee3202bd7da8a1fc17996983ad5d72b5c4ff4a -
</details>