Inside Bitcoin
Opening the selected file…
Inside Bitcoin
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) The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or https://opensource.org/license/mit.5#include <kernel/caches.h>6#include <node/caches.h>7#include <util/byte_units.h>9#include <boost/test/unit_test.hpp>11#include <cstdint>13using namespace node;15namespace {16void CheckDbCacheWarnThreshold(uint64_t threshold, uint64_t total_ram)17{18BOOST_CHECK(!ShouldWarnOversizedDbCache(threshold, total_ram));19BOOST_CHECK( ShouldWarnOversizedDbCache(threshold + 1, total_ram));20}21} // namespace23BOOST_AUTO_TEST_SUITE(caches_tests)25BOOST_AUTO_TEST_CASE(oversized_dbcache_warning)26{27BOOST_CHECK(!ShouldWarnOversizedDbCache(MIN_DBCACHE_BYTES, 1_GiB));29// Below DBCACHE_WARNING_RESERVED_RAM the existing fixed default dominates.30CheckDbCacheWarnThreshold(DEFAULT_KERNEL_CACHE, 1_GiB);31CheckDbCacheWarnThreshold(DEFAULT_KERNEL_CACHE, DBCACHE_WARNING_RESERVED_RAM);33// Above DBCACHE_WARNING_RESERVED_RAM the warning fires at 75% of the headroom.34CheckDbCacheWarnThreshold(((3_GiB - DBCACHE_WARNING_RESERVED_RAM) / 4) * 3, 3_GiB);36for (const auto total_ram : {8_GiB, 16_GiB, 32_GiB}) {37CheckDbCacheWarnThreshold(((total_ram - DBCACHE_WARNING_RESERVED_RAM) / 4) * 3, total_ram);38}39}41BOOST_AUTO_TEST_SUITE_END()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.