mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
Merge bitcoin/bitcoin#33021: test/refactor: revive test verifying that GetCoinsCacheSizeState switches from OK→LARGE→CRITICAL
554befd873test: revive `getcoinscachesizestate` (Lőrinc)64ed0fa6b7refactor: modernize `LargeCoinsCacheThreshold` (Lőrinc)1b40dc02a6refactor: extract `LargeCoinsCacheThreshold` from `GetCoinsCacheSizeState` (Lőrinc) Pull request description: After the changes in https://github.com/bitcoin/bitcoin/pull/25325 `getcoinscachesizestate` [always ended the test early](https://maflcko.github.io/b-c-cov/test_bitcoin.coverage/src/test/validation_flush_tests.cpp.gcov.html#L65): | File | Line Rate | Line Total | Line Hit | Branch Rate | Branch Total | Branch Hit | |------------------------------|---------:|-----------:|---------:|------------:|-------------:|-----------:| | validation_flush_tests.cpp | **31.5 %** | 54 | 17 | 22.3 % | 242 | 54 | The test revival was [extracted from a related PR](https://github.com/bitcoin/bitcoin/pull/28531#discussion_r2109417797) where it was [discovered](https://github.com/bitcoin/bitcoin/pull/28531#discussion_r2044004503). ACKs for top commit: achow101: ACK554befd873LarryRuane: ACK554befd873w0xlt: ACK554befd873Tree-SHA512: f5057254de8fb3fa627dd20fee6818cfadeb2e9f629f9972059ad7b32e01fcd7dc9922eff9da2d363b36a9f0954d9bc1c4131d47b2a9c6cc348d9864953b91be
This commit is contained in:
@@ -2766,15 +2766,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