mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
refactor: extract LargeCoinsCacheThreshold from GetCoinsCacheSizeState
Move-only commit, enabled reusing the large cache size calculation logic later. The only difference is the removal of the `static` keyword (since in a constexpr function it's a C++23 extension)
This commit is contained in:
@@ -2786,15 +2786,10 @@ CoinsCacheSizeState Chainstate::GetCoinsCacheSizeState(
|
||||
int64_t nTotalSpace =
|
||||
max_coins_cache_size_bytes + std::max<int64_t>(int64_t(max_mempool_size_bytes) - nMempoolUsage, 0);
|
||||
|
||||
//! No need to periodic flush if at least this much space still available.
|
||||
static constexpr int64_t MAX_BLOCK_COINSDB_USAGE_BYTES = 10 * 1024 * 1024; // 10MB
|
||||
int64_t large_threshold =
|
||||
std::max((9 * nTotalSpace) / 10, nTotalSpace - MAX_BLOCK_COINSDB_USAGE_BYTES);
|
||||
|
||||
if (cacheSize > nTotalSpace) {
|
||||
LogPrintf("Cache size (%s) exceeds total space (%s)\n", cacheSize, nTotalSpace);
|
||||
return CoinsCacheSizeState::CRITICAL;
|
||||
} else if (cacheSize > large_threshold) {
|
||||
} else if (cacheSize > LargeCoinsCacheThreshold(nTotalSpace)) {
|
||||
return CoinsCacheSizeState::LARGE;
|
||||
}
|
||||
return CoinsCacheSizeState::OK;
|
||||
|
||||
Reference in New Issue
Block a user