Skip to content

Commit

Permalink
node/chainstate: Add options for in-memory DBs
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Dec 16, 2024
1 parent 52bb35d commit c06e074
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions src/node/chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ std::optional<ChainstateLoadingError> 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<bool()> shutdown_requested,
std::function<void()> coins_error_cb)
{
Expand All @@ -73,7 +75,7 @@ std::optional<ChainstateLoadingError> 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();
Expand Down Expand Up @@ -177,7 +179,7 @@ std::optional<ChainstateLoadingError> 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) {
Expand Down
2 changes: 2 additions & 0 deletions src/node/chainstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ std::optional<ChainstateLoadingError> 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<bool()> shutdown_requested = nullptr,
std::function<void()> coins_error_cb = nullptr);

Expand Down

0 comments on commit c06e074

Please sign in to comment.