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
This commit is contained in:
1 parent
1b40dc02a6
commit
64ed0fa6b7
1 file changed
+6
-6
+6
-6
@@ -27,6 +27,7 @@
|
|||||||
#include <txdb.h>
|
#include <txdb.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
#include <util/byte_units.h>
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
#include <util/hasher.h>
|
#include <util/hasher.h>
|
||||||
@@ -504,13 +505,12 @@ enum class CoinsCacheSizeState
|
|||||||
OK = 0
|
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.
|
// No periodic flush needed if at least this much space is free
|
||||||
constexpr int64_t MAX_BLOCK_COINSDB_USAGE_BYTES = 10 * 1024 * 1024; // 10MB
|
constexpr int64_t MAX_BLOCK_COINSDB_USAGE_BYTES{int64_t(10_MiB)};
|
||||||
int64_t large_threshold =
|
return std::max((total_space * 9) / 10,
|
||||||
std::max((9 * nTotalSpace) / 10, nTotalSpace - MAX_BLOCK_COINSDB_USAGE_BYTES);
|
total_space - MAX_BLOCK_COINSDB_USAGE_BYTES);
|
||||||
return large_threshold;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user