From c06e07461eb96e3dfa57e1ddd851a9e0b88007fc Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:16:24 +0000 Subject: [PATCH] node/chainstate: Add options for in-memory DBs --- src/init.cpp | 2 ++ src/node/chainstate.cpp | 6 ++++-- src/node/chainstate.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 803db7244b..8d8186200b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1881,6 +1881,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) cache_sizes.block_tree_db, cache_sizes.coins_db, cache_sizes.coins, + /*block_tree_db_in_memory=*/false, + /*coins_db_in_memory=*/false, ShutdownRequested, []() { uiInterface.ThreadSafeMessageBox( diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 8923f6a81f..9835c8960d 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -48,6 +48,8 @@ std::optional LoadChainstate(bool fReset, int64_t nBlockTreeDBCache, int64_t nCoinDBCache, int64_t nCoinCacheUsage, + bool block_tree_db_in_memory, + bool coins_db_in_memory, std::function shutdown_requested, std::function coins_error_cb) { @@ -73,7 +75,7 @@ std::optional LoadChainstate(bool fReset, // new CBlockTreeDB tries to delete the existing file, which // fails if it's still open from the previous loop. Close it first: pblocktree.reset(); - pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, false, fReset)); + pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, block_tree_db_in_memory, fReset)); // Same logic as above with pblocktree dmnman.reset(); @@ -177,7 +179,7 @@ std::optional LoadChainstate(bool fReset, for (CChainState* chainstate : chainman.GetAll()) { chainstate->InitCoinsDB( /* cache_size_bytes */ nCoinDBCache, - /* in_memory */ false, + /* in_memory */ coins_db_in_memory, /* should_wipe */ fReset || fReindexChainState); if (coins_error_cb) { diff --git a/src/node/chainstate.h b/src/node/chainstate.h index c2aa6d827f..b7f2942869 100644 --- a/src/node/chainstate.h +++ b/src/node/chainstate.h @@ -110,6 +110,8 @@ std::optional LoadChainstate(bool fReset, int64_t nBlockTreeDBCache, int64_t nCoinDBCache, int64_t nCoinCacheUsage, + bool block_tree_db_in_memory, + bool coins_db_in_memory, std::function shutdown_requested = nullptr, std::function coins_error_cb = nullptr);