refactor: validation: add const GetAll method

A read-only accessor into the Chainstates is required for a future
commit to make CheckBlockIndex const.
This commit is contained in:
stickies-v 2025-04-23 15:44:09 +01:00
parent d05481df64
commit 9a79ee285f
No known key found for this signature in database
GPG key ID: 5CB1CE6E5E66A757
2 changed files with 13 additions and 0 deletions

View file

@ -5657,6 +5657,18 @@ std::vector<Chainstate*> ChainstateManager::GetAll()
return out;
}
std::vector<const Chainstate*> ChainstateManager::GetAll() const
{
LOCK(::cs_main);
std::vector<const Chainstate*> out;
for (const Chainstate* cs : {m_ibd_chainstate.get(), m_snapshot_chainstate.get()}) {
if (this->IsUsable(cs)) out.push_back(cs);
}
return out;
}
Chainstate& ChainstateManager::InitializeChainstate(CTxMemPool* mempool)
{
AssertLockHeld(::cs_main);

View file

@ -1078,6 +1078,7 @@ public:
//! Get all chainstates currently being used.
std::vector<Chainstate*> GetAll();
std::vector<const Chainstate*> GetAll() const;
//! Construct and activate a Chainstate on the basis of UTXO snapshot data.
//!