mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
-BEGIN VERIFY SCRIPT- sed --in-place --regexp-extended \ 's;( 20[0-2][0-9])(-20[0-2][0-9])? The Bitcoin Core developers;\1-present The Bitcoin Core developers;g' \ $( git grep -l 'The Bitcoin Core developers' -- ':(exclude)COPYING' ':(exclude)src/ipc/libmultiprocess' ':(exclude)src/minisketch' ) -END VERIFY SCRIPT-
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
// Copyright (c) 2021-present 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);
|
|
constexpr bool ShouldWarnOversizedDbCache(size_t dbcache, size_t total_ram) noexcept
|
|
{
|
|
const size_t cap{(total_ram < 2048_MiB) ? DEFAULT_DB_CACHE : (total_ram / 100) * 75};
|
|
return dbcache > cap;
|
|
}
|
|
|
|
void LogOversizedDbCache(const ArgsManager& args) noexcept;
|
|
} // namespace node
|
|
|
|
#endif // BITCOIN_NODE_CACHES_H
|