kernel: Move default cache constants to caches

They are not related to the txdb, so a better place for them is the
new kernel and node cache file. Re-use the default amount of kernel
cache for the default node cache.
This commit is contained in:
TheCharlatan committed 2025-01-15 15:44:55 +01:00
1 parent 8826cae285
commit 65cde3621d
8 files changed
+18 -16

No files matched your search

+2 -3
View File
@@ -7,7 +7,6 @@
#include <common/args.h>
#include <index/txindex.h>
#include <kernel/caches.h>
#include <txdb.h>
#include <algorithm>
#include <string>
@@ -22,8 +21,8 @@ static constexpr int64_t MAX_FILTER_INDEX_CACHE{1024};
namespace node {
CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
{
int64_t nTotalCache = (args.GetIntArg("-dbcache", nDefaultDbCache) << 20);
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
int64_t nTotalCache = (args.GetIntArg("-dbcache", DEFAULT_DB_CACHE) << 20);
nTotalCache = std::max(nTotalCache, MIN_DB_CACHE << 20);
IndexCacheSizes sizes;
sizes.tx_index = std::min(nTotalCache / 8, args.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? MAX_TX_INDEX_CACHE << 20 : 0);
nTotalCache -= sizes.tx_index;
+5
View File
@@ -11,6 +11,11 @@
class ArgsManager;
//! min. -dbcache (MiB)
static constexpr int64_t MIN_DB_CACHE{4};
//! -dbcache default (MiB)
static constexpr int64_t DEFAULT_DB_CACHE{DEFAULT_KERNEL_CACHE};
namespace node {
struct IndexCacheSizes {
size_t tx_index{0};