mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 03:22:47 +01:00
node/caches: Remove intermediate variables
This commit is contained in:
parent
4ab182751e
commit
52bb35d9c8
@ -13,26 +13,20 @@ CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
|
|||||||
int64_t nTotalCache = (args.GetArg("-dbcache", nDefaultDbCache) << 20);
|
int64_t nTotalCache = (args.GetArg("-dbcache", nDefaultDbCache) << 20);
|
||||||
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
|
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
|
||||||
nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greater than nMaxDbcache
|
nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greater than nMaxDbcache
|
||||||
int64_t nBlockTreeDBCache = std::min(nTotalCache / 8, nMaxBlockDBCache << 20);
|
CacheSizes sizes;
|
||||||
nTotalCache -= nBlockTreeDBCache;
|
sizes.block_tree_db = std::min(nTotalCache / 8, nMaxBlockDBCache << 20);
|
||||||
int64_t nTxIndexCache = std::min(nTotalCache / 8, args.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? nMaxTxIndexCache << 20 : 0);
|
nTotalCache -= sizes.block_tree_db;
|
||||||
nTotalCache -= nTxIndexCache;
|
sizes.tx_index = std::min(nTotalCache / 8, args.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? nMaxTxIndexCache << 20 : 0);
|
||||||
int64_t filter_index_cache = 0;
|
nTotalCache -= sizes.tx_index;
|
||||||
|
sizes.filter_index = 0;
|
||||||
if (n_indexes > 0) {
|
if (n_indexes > 0) {
|
||||||
int64_t max_cache = std::min(nTotalCache / 8, max_filter_index_cache << 20);
|
int64_t max_cache = std::min(nTotalCache / 8, max_filter_index_cache << 20);
|
||||||
filter_index_cache = max_cache / n_indexes;
|
sizes.filter_index = max_cache / n_indexes;
|
||||||
nTotalCache -= filter_index_cache * n_indexes;
|
nTotalCache -= sizes.filter_index * n_indexes;
|
||||||
}
|
}
|
||||||
int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache
|
sizes.coins_db = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache
|
||||||
nCoinDBCache = std::min(nCoinDBCache, nMaxCoinsDBCache << 20); // cap total coins db cache
|
sizes.coins_db = std::min(sizes.coins_db, nMaxCoinsDBCache << 20); // cap total coins db cache
|
||||||
nTotalCache -= nCoinDBCache;
|
nTotalCache -= sizes.coins_db;
|
||||||
int64_t nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache
|
sizes.coins = nTotalCache; // the rest goes to in-memory cache
|
||||||
|
return sizes;
|
||||||
return {
|
|
||||||
nBlockTreeDBCache,
|
|
||||||
nCoinDBCache,
|
|
||||||
nCoinCacheUsage,
|
|
||||||
nTxIndexCache,
|
|
||||||
filter_index_cache,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user