Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | |||||
extern Mutex g_best_block_mutex; | extern Mutex g_best_block_mutex; | ||||
extern std::condition_variable g_best_block_cv; | extern std::condition_variable g_best_block_cv; | ||||
extern uint256 g_best_block; | extern uint256 g_best_block; | ||||
extern std::atomic_bool fImporting; | extern std::atomic_bool fImporting; | ||||
extern std::atomic_bool fReindex; | extern std::atomic_bool fReindex; | ||||
extern bool fRequireStandard; | extern bool fRequireStandard; | ||||
extern bool fCheckBlockIndex; | extern bool fCheckBlockIndex; | ||||
extern bool fCheckpointsEnabled; | extern bool fCheckpointsEnabled; | ||||
extern size_t nCoinCacheUsage; | |||||
/** | /** | ||||
* A fee rate smaller than this is considered zero fee (for relaying, mining and | * A fee rate smaller than this is considered zero fee (for relaying, mining and | ||||
* transaction creation) | * transaction creation) | ||||
*/ | */ | ||||
extern CFeeRate minRelayTxFee; | extern CFeeRate minRelayTxFee; | ||||
/** | /** | ||||
* If the tip is older than this (in seconds), the node is considered to be in | * If the tip is older than this (in seconds), the node is considered to be in | ||||
▲ Show 20 Lines • Show All 587 Lines • ▼ Show 20 Lines | public: | ||||
* | * | ||||
* All parameters forwarded to CoinsViews. | * All parameters forwarded to CoinsViews. | ||||
*/ | */ | ||||
void InitCoinsDB(size_t cache_size_bytes, bool in_memory, bool should_wipe, | void InitCoinsDB(size_t cache_size_bytes, bool in_memory, bool should_wipe, | ||||
std::string leveldb_name = "chainstate"); | std::string leveldb_name = "chainstate"); | ||||
//! 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() EXCLUSIVE_LOCKS_REQUIRED(::cs_main); | void InitCoinsCache(size_t cache_size_bytes) | ||||
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() EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | bool CanFlushToDisk() EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
return m_coins_views && m_coins_views->m_cacheview; | return m_coins_views && m_coins_views->m_cacheview; | ||||
} | } | ||||
Show All 31 Lines | public: | ||||
CCoinsViewErrorCatcher &CoinsErrorCatcher() | CCoinsViewErrorCatcher &CoinsErrorCatcher() | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | EXCLUSIVE_LOCKS_REQUIRED(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. | |||||
size_t m_coinsdb_cache_size_bytes{0}; | |||||
//! The cache size of the in-memory coins view. | |||||
size_t m_coinstip_cache_size_bytes{0}; | |||||
//! Resize the CoinsViews caches dynamically and flush state to disk. | |||||
//! @returns true unless an error occurred during the flush. | |||||
bool ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size) | |||||
EXCLUSIVE_LOCKS_REQUIRED(::cs_main); | |||||
/** | /** | ||||
* Update the on-disk chain state. | * Update the on-disk chain state. | ||||
* The caches and indexes are flushed depending on the mode we're called | * The caches and indexes are flushed depending on the mode we're called | ||||
* with if they're too large, if it's been a while since the last write, or | * with if they're too large, if it's been a while since the last write, or | ||||
* always and in all cases if we're in prune mode and are deleting files. | * always and in all cases if we're in prune mode and are deleting files. | ||||
* | * | ||||
* If FlushStateMode::NONE is used, then FlushStateToDisk(...) won't do | * If FlushStateMode::NONE is used, then FlushStateToDisk(...) won't do | ||||
* anything besides checking if we need to prune. | * anything besides checking if we need to prune. | ||||
▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | private: | ||||
friend CChainState &ChainstateActive(); | friend CChainState &ChainstateActive(); | ||||
friend CChain &ChainActive(); | friend CChain &ChainActive(); | ||||
public: | public: | ||||
//! A single BlockManager instance is shared across each constructed | //! A single BlockManager instance is shared across each constructed | ||||
//! chainstate to avoid duplicating block metadata. | //! chainstate to avoid duplicating block metadata. | ||||
BlockManager m_blockman GUARDED_BY(::cs_main); | BlockManager m_blockman GUARDED_BY(::cs_main); | ||||
//! The total number of bytes available for us to use across all in-memory | |||||
//! coins caches. This will be split somehow across chainstates. | |||||
int64_t m_total_coinstip_cache{0}; | |||||
// | |||||
//! The total number of bytes available for us to use across all leveldb | |||||
//! coins databases. This will be split somehow across chainstates. | |||||
int64_t m_total_coinsdb_cache{0}; | |||||
//! Instantiate a new chainstate and assign it based upon whether it is | //! Instantiate a new chainstate and assign it based upon whether it is | ||||
//! from a snapshot. | //! from a snapshot. | ||||
//! | //! | ||||
//! @param[in] snapshot_blockhash If given, signify that this chainstate | //! @param[in] snapshot_blockhash If given, signify that this chainstate | ||||
//! is based on a snapshot. | //! is based on a snapshot. | ||||
CChainState & | CChainState & | ||||
InitializeChainstate(const BlockHash &snapshot_blockhash = BlockHash()) | InitializeChainstate(const BlockHash &snapshot_blockhash = BlockHash()) | ||||
EXCLUSIVE_LOCKS_REQUIRED(::cs_main); | EXCLUSIVE_LOCKS_REQUIRED(::cs_main); | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | public: | ||||
bool LoadBlockIndex(const Consensus::Params ¶ms) | bool LoadBlockIndex(const Consensus::Params ¶ms) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
//! 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(); | ||||
//! Check to see if caches are out of balance and if so, call | |||||
//! ResizeCoinsCaches() as needed. | |||||
void MaybeRebalanceCaches() EXCLUSIVE_LOCKS_REQUIRED(::cs_main); | |||||
}; | }; | ||||
/** | /** | ||||
* DEPRECATED! Please use node.chainman instead. May only be used in | * DEPRECATED! Please use node.chainman instead. May only be used in | ||||
* validation.cpp internally | * validation.cpp internally | ||||
*/ | */ | ||||
extern ChainstateManager g_chainman GUARDED_BY(::cs_main); | extern ChainstateManager g_chainman GUARDED_BY(::cs_main); | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |