mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
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:
parent
d05481df64
commit
9a79ee285f
2 changed files with 13 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
//!
|
||||
|
|
Loading…
Add table
Reference in a new issue