mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-28 16:36:04 +01:00
Add CChainState::ResizeCoinsCaches
Also adds CCoinsViewCache::ReallocateCache() to attempt to free
memory that the cacheCoins's allocator may be hanging onto when
downsizing the cache.
Adds `CChainState::m_coins{tip,db}_cache_size_bytes` data members
so that we can reference cache size on a per-chainstate basis for
flushing.
This commit is contained in:
committed by
James O'Beirne
parent
b223111da2
commit
f36aaa6392
@@ -127,7 +127,6 @@ extern bool g_parallel_script_checks;
|
||||
extern bool fRequireStandard;
|
||||
extern bool fCheckBlockIndex;
|
||||
extern bool fCheckpointsEnabled;
|
||||
extern size_t nCoinCacheUsage;
|
||||
/** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */
|
||||
extern CFeeRate minRelayTxFee;
|
||||
/** If the tip is older than this (in seconds), the node is considered to be in initial block download. */
|
||||
@@ -519,7 +518,7 @@ public:
|
||||
|
||||
//! Initialize the in-memory coins cache (to be done after the health of the 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 and we can
|
||||
//! safely flush this object to disk.
|
||||
@@ -568,6 +567,17 @@ public:
|
||||
//! Destructs all objects related to accessing the UTXO set.
|
||||
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.
|
||||
* The caches and indexes are flushed depending on the mode we're called with
|
||||
|
||||
Reference in New Issue
Block a user