mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-26 05:48:20 +01:00
This avoids having to rely on implicit casts when passing them to the various functions allocating the caches. This also ensures that if the requested amount of db_cache does not fit in a size_t, it is clamped to the maximum value of a size_t. Also take this opportunity to make the total amounts of cache in the chainstate manager a size_t too.
33 lines
823 B
C++
33 lines
823 B
C++
// Copyright (c) 2021 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_NODE_CACHES_H
|
|
#define BITCOIN_NODE_CACHES_H
|
|
|
|
#include <kernel/caches.h>
|
|
#include <util/byte_units.h>
|
|
|
|
#include <cstddef>
|
|
|
|
class ArgsManager;
|
|
|
|
//! min. -dbcache (bytes)
|
|
static constexpr size_t MIN_DB_CACHE{4_MiB};
|
|
//! -dbcache default (bytes)
|
|
static constexpr size_t DEFAULT_DB_CACHE{DEFAULT_KERNEL_CACHE};
|
|
|
|
namespace node {
|
|
struct IndexCacheSizes {
|
|
size_t tx_index{0};
|
|
size_t filter_index{0};
|
|
};
|
|
struct CacheSizes {
|
|
IndexCacheSizes index;
|
|
kernel::CacheSizes kernel;
|
|
};
|
|
CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes = 0);
|
|
} // namespace node
|
|
|
|
#endif // BITCOIN_NODE_CACHES_H
|