mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 21:52:53 +02:00
kernel: allow setting chainstate dbcache
Add `btck_chainstate_manager_options_set_database_cache_bytes()` so Kernel callers can set the total database cache budget. Use `uint64_t` for a fixed-width C API, reject values outside the architecture-specific range, and keep `DEFAULT_KERNEL_CACHE` as the fallback. Apply the selected split to the block tree database and `LoadChainstate()`. Co-authored-by: stickies-v <stickies-v@protonmail.com> Co-authored-by: w0xlt <94266259+w0xlt@users.noreply.github.com> Co-authored-by: stringintech <stringintech@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <kernel/bitcoinkernel.h>
|
||||
#include <kernel/bitcoinkernel_wrapper.h>
|
||||
#include <util/byte_units.h>
|
||||
#include <util/fs.h>
|
||||
|
||||
#define BOOST_TEST_MODULE Bitcoin Kernel Test Suite
|
||||
@@ -800,6 +801,9 @@ BOOST_AUTO_TEST_CASE(btck_chainman_tests)
|
||||
|
||||
ChainstateManagerOptions chainman_opts{context, PathToString(test_directory.m_directory), PathToString(test_directory.m_directory / "blocks")};
|
||||
chainman_opts.SetWorkerThreads(4);
|
||||
BOOST_CHECK(!chainman_opts.SetDatabaseCacheBytes(4_MiB - 1));
|
||||
if constexpr (sizeof(void*) == 4) BOOST_CHECK(!chainman_opts.SetDatabaseCacheBytes(2_GiB));
|
||||
BOOST_CHECK(chainman_opts.SetDatabaseCacheBytes(4_MiB));
|
||||
BOOST_CHECK(!chainman_opts.SetWipeDbs(/*wipe_block_tree=*/true, /*wipe_chainstate=*/false));
|
||||
BOOST_CHECK(chainman_opts.SetWipeDbs(/*wipe_block_tree=*/true, /*wipe_chainstate=*/true));
|
||||
BOOST_CHECK(chainman_opts.SetWipeDbs(/*wipe_block_tree=*/false, /*wipe_chainstate=*/true));
|
||||
|
||||
Reference in New Issue
Block a user