Skip to content

Commit be265e2

Browse files
committed
Merge commit 'origin-pull/32364/head^' into HEAD
2 parents ee4007e + 61a51ec commit be265e2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/validation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5331,8 +5331,8 @@ void ChainstateManager::CheckBlockIndex()
53315331
if (pindex->pprev == nullptr) {
53325332
// Genesis block checks.
53335333
assert(pindex->GetBlockHash() == GetConsensus().hashGenesisBlock); // Genesis block's hash must match.
5334-
for (auto c : GetAll()) {
5335-
if (c->m_chain.Genesis() != nullptr) {
5334+
for (const Chainstate* c : {m_ibd_chainstate.get(), m_snapshot_chainstate.get()}) {
5335+
if (c && c->m_chain.Genesis() != nullptr) {
53365336
assert(pindex == c->m_chain.Genesis()); // The chain's genesis block must be this block.
53375337
}
53385338
}
@@ -5387,8 +5387,8 @@ void ChainstateManager::CheckBlockIndex()
53875387
}
53885388

53895389
// Chainstate-specific checks on setBlockIndexCandidates
5390-
for (auto c : GetAll()) {
5391-
if (c->m_chain.Tip() == nullptr) continue;
5390+
for (const Chainstate* c : {m_ibd_chainstate.get(), m_snapshot_chainstate.get()}) {
5391+
if (!c || c->m_chain.Tip() == nullptr) continue;
53925392
// Two main factors determine whether pindex is a candidate in
53935393
// setBlockIndexCandidates:
53945394
//
@@ -5471,7 +5471,8 @@ void ChainstateManager::CheckBlockIndex()
54715471
// tip.
54725472
// So if this block is itself better than any m_chain.Tip() and it wasn't in
54735473
// setBlockIndexCandidates, then it must be in m_blocks_unlinked.
5474-
for (auto c : GetAll()) {
5474+
for (const Chainstate* c : {m_ibd_chainstate.get(), m_snapshot_chainstate.get()}) {
5475+
if (!c) continue;
54755476
const bool is_active = c == &ActiveChainstate();
54765477
if (!CBlockIndexWorkComparator()(pindex, c->m_chain.Tip()) && c->setBlockIndexCandidates.count(pindex) == 0) {
54775478
if (pindexFirstInvalid == nullptr) {

0 commit comments

Comments
 (0)