Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2021-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_NODE_CACHES_H6#define BITCOIN_NODE_CACHES_H8#include <kernel/caches.h>9#include <util/byte_units.h>11#include <algorithm>12#include <cstddef>13#include <cstdint>15class ArgsManager;17//! Reserved non-dbcache memory usage.18inline constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM{2_GiB};20namespace node {21uint64_t GetDefaultDBCache();22struct IndexCacheSizes {23uint64_t tx_index{0};24uint64_t filter_index{0};25uint64_t txospender_index{0};26};27struct CacheSizes {28IndexCacheSizes index;29kernel::CacheSizes kernel;30};31CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes = 0);32constexpr bool ShouldWarnOversizedDbCache(uint64_t dbcache, uint64_t total_ram) noexcept33{34const uint64_t available_ram{total_ram > DBCACHE_WARNING_RESERVED_RAM ? total_ram - DBCACHE_WARNING_RESERVED_RAM : 0};35const uint64_t cap{std::max(DEFAULT_KERNEL_CACHE, (available_ram / 4) * 3)};36return dbcache > cap;37}39void LogOversizedDbCache(const ArgsManager& args) noexcept;40} // namespace node42#endif // BITCOIN_NODE_CACHES_H