Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 1,128 Lines • ▼ Show 20 Lines | private: | ||||
//! The chainstate used under normal operation (i.e. "regular" IBD) or, if | //! The chainstate used under normal operation (i.e. "regular" IBD) or, if | ||||
//! a snapshot is in use, for background validation. | //! a snapshot is in use, for background validation. | ||||
//! | //! | ||||
//! Its contents (including on-disk data) will be deleted *upon shutdown* | //! Its contents (including on-disk data) will be deleted *upon shutdown* | ||||
//! after background validation of the snapshot has completed. We do not | //! after background validation of the snapshot has completed. We do not | ||||
//! free the chainstate contents immediately after it finishes validation | //! free the chainstate contents immediately after it finishes validation | ||||
//! to cautiously avoid a case where some other part of the system is still | //! to cautiously avoid a case where some other part of the system is still | ||||
//! using this pointer (e.g. net_processing). | //! using this pointer (e.g. net_processing). | ||||
//! | |||||
//! Once this pointer is set to a corresponding chainstate, it will not | |||||
//! be reset until init.cpp:Shutdown(). This means it is safe to acquire | |||||
//! the contents of this pointer with ::cs_main held, release the lock, | |||||
//! and then use the reference without concern of it being deconstructed. | |||||
//! | |||||
//! This is especially important when, e.g., calling ActivateBestChain() | |||||
//! on all chainstates because we are not able to hold ::cs_main going into | |||||
//! that call. | |||||
std::unique_ptr<CChainState> m_ibd_chainstate; | std::unique_ptr<CChainState> m_ibd_chainstate; | ||||
//! A chainstate initialized on the basis of a UTXO snapshot. If this is | //! A chainstate initialized on the basis of a UTXO snapshot. If this is | ||||
//! non-null, it is always our active chainstate. | //! non-null, it is always our active chainstate. | ||||
//! | |||||
//! Once this pointer is set to a corresponding chainstate, it will not | |||||
//! be reset until init.cpp:Shutdown(). This means it is safe to acquire | |||||
//! the contents of this pointer with ::cs_main held, release the lock, | |||||
//! and then use the reference without concern of it being deconstructed. | |||||
//! | |||||
//! This is especially important when, e.g., calling ActivateBestChain() | |||||
//! on all chainstates because we are not able to hold ::cs_main going into | |||||
//! that call. | |||||
std::unique_ptr<CChainState> m_snapshot_chainstate; | std::unique_ptr<CChainState> m_snapshot_chainstate; | ||||
//! Points to either the ibd or snapshot chainstate; indicates our | //! Points to either the ibd or snapshot chainstate; indicates our | ||||
//! most-work chain. | //! most-work chain. | ||||
//! | |||||
//! Once this pointer is set to a corresponding chainstate, it will not | |||||
//! be reset until init.cpp:Shutdown(). This means it is safe to acquire | |||||
//! the contents of this pointer with ::cs_main held, release the lock, | |||||
//! and then use the reference without concern of it being deconstructed. | |||||
//! | |||||
//! This is especially important when, e.g., calling ActivateBestChain() | |||||
//! on all chainstates because we are not able to hold ::cs_main going into | |||||
//! that call. | |||||
CChainState *m_active_chainstate{nullptr}; | CChainState *m_active_chainstate{nullptr}; | ||||
//! If true, the assumed-valid chainstate has been fully validated | //! If true, the assumed-valid chainstate has been fully validated | ||||
//! by the background validation chainstate. | //! by the background validation chainstate. | ||||
bool m_snapshot_validated{false}; | bool m_snapshot_validated{false}; | ||||
// For access to m_active_chainstate. | // For access to m_active_chainstate. | ||||
friend CChainState &ChainstateActive(); | friend CChainState &ChainstateActive(); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | public: | ||||
//! Unload block index and chain data before shutdown. | //! Unload block index and chain data before shutdown. | ||||
void Unload() EXCLUSIVE_LOCKS_REQUIRED(::cs_main); | void Unload() EXCLUSIVE_LOCKS_REQUIRED(::cs_main); | ||||
//! Clear (deconstruct) chainstate data. | //! Clear (deconstruct) chainstate data. | ||||
void Reset(); | void Reset(); | ||||
}; | }; | ||||
extern ChainstateManager g_chainman; | extern ChainstateManager g_chainman GUARDED_BY(::cs_main); | ||||
/** @returns the most-work valid chainstate. */ | /** @returns the most-work valid chainstate. */ | ||||
CChainState &ChainstateActive(); | CChainState &ChainstateActive(); | ||||
/** @returns the most-work chain. */ | /** @returns the most-work chain. */ | ||||
CChain &ChainActive(); | CChain &ChainActive(); | ||||
/** @returns the global block index map. */ | /** @returns the global block index map. */ | ||||
Show All 34 Lines |