mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-07 03:03:58 +01:00
refactoring: introduce CChainState::GetCoinsCacheSizeState
This separates out some logic for detecting how full the coins cache is from FlushStateToDisk. We'll want to reuse this logic when deciding when to flush the coins cache during UTXO snapshot activation.
This commit is contained in:
@@ -530,6 +530,15 @@ public:
|
||||
void InitCache() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
};
|
||||
|
||||
enum class CoinsCacheSizeState
|
||||
{
|
||||
//! The coins cache is in immediate need of a flush.
|
||||
CRITICAL = 2,
|
||||
//! The cache is at >= 90% capacity.
|
||||
LARGE = 1,
|
||||
OK = 0
|
||||
};
|
||||
|
||||
/**
|
||||
* CChainState stores and provides an API to update our local knowledge of the
|
||||
* current best chain.
|
||||
@@ -721,6 +730,17 @@ public:
|
||||
/** Update the chain tip based on database information, i.e. CoinsTip()'s best block. */
|
||||
bool LoadChainTip(const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
//! Dictates whether we need to flush the cache to disk or not.
|
||||
//!
|
||||
//! @return the state of the size of the coins cache.
|
||||
CoinsCacheSizeState GetCoinsCacheSizeState(const CTxMemPool& tx_pool)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
CoinsCacheSizeState GetCoinsCacheSizeState(
|
||||
const CTxMemPool& tx_pool,
|
||||
size_t max_coins_cache_size_bytes,
|
||||
size_t max_mempool_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
private:
|
||||
bool ActivateBestChainStep(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs);
|
||||
bool ConnectTip(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs);
|
||||
|
||||
Reference in New Issue
Block a user