Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 740 Lines • ▼ Show 20 Lines | public: | ||||
//! Initialize the in-memory coins cache (to be done after the health of the | //! Initialize the in-memory coins cache (to be done after the health of the | ||||
//! on-disk database is verified). | //! on-disk database is verified). | ||||
void InitCoinsCache(size_t cache_size_bytes) | void InitCoinsCache(size_t cache_size_bytes) | ||||
EXCLUSIVE_LOCKS_REQUIRED(::cs_main); | EXCLUSIVE_LOCKS_REQUIRED(::cs_main); | ||||
//! @returns whether or not the CoinsViews object has been fully initialized | //! @returns whether or not the CoinsViews object has been fully initialized | ||||
//! and we can | //! and we can | ||||
//! safely flush this object to disk. | //! safely flush this object to disk. | ||||
bool CanFlushToDisk() const EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | bool CanFlushToDisk() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { | ||||
AssertLockHeld(::cs_main); | |||||
return m_coins_views && m_coins_views->m_cacheview; | return m_coins_views && m_coins_views->m_cacheview; | ||||
} | } | ||||
//! The current chain of blockheaders we consult and build on. | //! The current chain of blockheaders we consult and build on. | ||||
//! @see CChain, CBlockIndex. | //! @see CChain, CBlockIndex. | ||||
CChain m_chain; | CChain m_chain; | ||||
/** | /** | ||||
Show All 15 Lines | public: | ||||
* (for itself and all ancestors) *or* BLOCK_ASSUMED_VALID (if using | * (for itself and all ancestors) *or* BLOCK_ASSUMED_VALID (if using | ||||
* background chainstates) and as good as our current tip or better. | * background chainstates) and as good as our current tip or better. | ||||
* Entries may be failed, though, and pruning nodes may be missing the data | * Entries may be failed, though, and pruning nodes may be missing the data | ||||
* for the block. | * for the block. | ||||
*/ | */ | ||||
std::set<CBlockIndex *, CBlockIndexWorkComparator> setBlockIndexCandidates; | std::set<CBlockIndex *, CBlockIndexWorkComparator> setBlockIndexCandidates; | ||||
//! @returns A reference to the in-memory cache of the UTXO set. | //! @returns A reference to the in-memory cache of the UTXO set. | ||||
CCoinsViewCache &CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | CCoinsViewCache &CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { | ||||
AssertLockHeld(::cs_main); | |||||
assert(m_coins_views->m_cacheview); | assert(m_coins_views->m_cacheview); | ||||
return *m_coins_views->m_cacheview.get(); | return *m_coins_views->m_cacheview.get(); | ||||
} | } | ||||
//! @returns A reference to the on-disk UTXO set database. | //! @returns A reference to the on-disk UTXO set database. | ||||
CCoinsViewDB &CoinsDB() { return m_coins_views->m_dbview; } | CCoinsViewDB &CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { | ||||
AssertLockHeld(::cs_main); | |||||
return m_coins_views->m_dbview; | |||||
} | |||||
//! @returns A pointer to the mempool. | //! @returns A pointer to the mempool. | ||||
CTxMemPool *GetMempool() { return m_mempool; } | CTxMemPool *GetMempool() { return m_mempool; } | ||||
//! @returns A reference to a wrapped view of the in-memory UTXO set that | //! @returns A reference to a wrapped view of the in-memory UTXO set that | ||||
//! handles disk read errors gracefully. | //! handles disk read errors gracefully. | ||||
CCoinsViewErrorCatcher &CoinsErrorCatcher() | CCoinsViewErrorCatcher &CoinsErrorCatcher() | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
AssertLockHeld(::cs_main); | |||||
return m_coins_views->m_catcherview; | return m_coins_views->m_catcherview; | ||||
} | } | ||||
//! Destructs all objects related to accessing the UTXO set. | //! Destructs all objects related to accessing the UTXO set. | ||||
void ResetCoinsViews() { m_coins_views.reset(); } | void ResetCoinsViews() { m_coins_views.reset(); } | ||||
//! The cache size of the on-disk coins view. | //! The cache size of the on-disk coins view. | ||||
size_t m_coinsdb_cache_size_bytes{0}; | size_t m_coinsdb_cache_size_bytes{0}; | ||||
▲ Show 20 Lines • Show All 410 Lines • ▼ Show 20 Lines | public: | ||||
//! The most-work chain. | //! The most-work chain. | ||||
CChainState &ActiveChainstate() const; | CChainState &ActiveChainstate() const; | ||||
CChain &ActiveChain() const { return ActiveChainstate().m_chain; } | CChain &ActiveChain() const { return ActiveChainstate().m_chain; } | ||||
int ActiveHeight() const { return ActiveChain().Height(); } | int ActiveHeight() const { return ActiveChain().Height(); } | ||||
CBlockIndex *ActiveTip() const { return ActiveChain().Tip(); } | CBlockIndex *ActiveTip() const { return ActiveChain().Tip(); } | ||||
node::BlockMap &BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { | node::BlockMap &BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { | ||||
AssertLockHeld(::cs_main); | |||||
return m_blockman.m_block_index; | return m_blockman.m_block_index; | ||||
} | } | ||||
//! @returns true if a snapshot-based chainstate is in use. Also implies | //! @returns true if a snapshot-based chainstate is in use. Also implies | ||||
//! that a background validation chainstate is also in use. | //! that a background validation chainstate is also in use. | ||||
bool IsSnapshotActive() const; | bool IsSnapshotActive() const; | ||||
std::optional<BlockHash> SnapshotBlockhash() const; | std::optional<BlockHash> SnapshotBlockhash() const; | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |