@@ -5331,8 +5331,8 @@ void ChainstateManager::CheckBlockIndex()
5331
5331
if (pindex->pprev == nullptr ) {
5332
5332
// Genesis block checks.
5333
5333
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 ) {
5336
5336
assert (pindex == c->m_chain .Genesis ()); // The chain's genesis block must be this block.
5337
5337
}
5338
5338
}
@@ -5387,8 +5387,8 @@ void ChainstateManager::CheckBlockIndex()
5387
5387
}
5388
5388
5389
5389
// 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 ;
5392
5392
// Two main factors determine whether pindex is a candidate in
5393
5393
// setBlockIndexCandidates:
5394
5394
//
@@ -5471,7 +5471,8 @@ void ChainstateManager::CheckBlockIndex()
5471
5471
// tip.
5472
5472
// So if this block is itself better than any m_chain.Tip() and it wasn't in
5473
5473
// 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 ;
5475
5476
const bool is_active = c == &ActiveChainstate ();
5476
5477
if (!CBlockIndexWorkComparator ()(pindex, c->m_chain .Tip ()) && c->setBlockIndexCandidates .count (pindex) == 0 ) {
5477
5478
if (pindexFirstInvalid == nullptr ) {
0 commit comments