From 64ed0fa6b7a2b637f236c3abf2f045adf6a067cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Sat, 19 Jul 2025 17:20:33 -0700 Subject: [PATCH] refactor: modernize `LargeCoinsCacheThreshold` * parameter name uses underscores * commit message typo fixed and compacted * used `10_MiB` to avoid having to comment * swapped order of operands in (9 * x / 10) to make it obvious that we're calculating 90% * inlined return value --- src/validation.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/validation.h b/src/validation.h index 8998dccedcf..6be6ae287fc 100644 --- a/src/validation.h +++ b/src/validation.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -504,13 +505,12 @@ enum class CoinsCacheSizeState OK = 0 }; -constexpr int64_t LargeCoinsCacheThreshold(int64_t nTotalSpace) noexcept +constexpr int64_t LargeCoinsCacheThreshold(int64_t total_space) noexcept { - //! No need to periodic flush if at least this much space still available. - 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); - return large_threshold; + // No periodic flush needed if at least this much space is free + constexpr int64_t MAX_BLOCK_COINSDB_USAGE_BYTES{int64_t(10_MiB)}; + return std::max((total_space * 9) / 10, + total_space - MAX_BLOCK_COINSDB_USAGE_BYTES); } /**