Skip to content

Commit c541da0

Browse files
committed
node/chainstate: Add options for in-memory DBs
[META] In a future commit, these options will be used in TestingSetup to ensure that the DBs are in-memory.
1 parent ceb9790 commit c541da0

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/init.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14151415
cache_sizes.block_tree_db,
14161416
cache_sizes.coins_db,
14171417
cache_sizes.coins,
1418+
false,
1419+
false,
14181420
ShutdownRequested,
14191421
[]() {
14201422
uiInterface.ThreadSafeMessageBox(

src/node/chainstate.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
1717
int64_t nBlockTreeDBCache,
1818
int64_t nCoinDBCache,
1919
int64_t nCoinCacheUsage,
20+
bool block_tree_db_in_memory,
21+
bool coins_db_in_memory,
2022
std::function<bool()> shutdown_requested,
2123
std::function<void()> coins_error_cb)
2224
{
@@ -36,7 +38,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
3638
// new CBlockTreeDB tries to delete the existing file, which
3739
// fails if it's still open from the previous loop. Close it first:
3840
pblocktree.reset();
39-
pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, false, fReset));
41+
pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, block_tree_db_in_memory, fReset));
4042

4143
if (fReset) {
4244
pblocktree->WriteReindexing(true);
@@ -81,7 +83,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
8183
for (CChainState* chainstate : chainman.GetAll()) {
8284
chainstate->InitCoinsDB(
8385
/* cache_size_bytes */ nCoinDBCache,
84-
/* in_memory */ false,
86+
/* in_memory */ coins_db_in_memory,
8587
/* should_wipe */ fReset || fReindexChainState);
8688

8789
if (coins_error_cb) {

src/node/chainstate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
6363
int64_t nBlockTreeDBCache,
6464
int64_t nCoinDBCache,
6565
int64_t nCoinCacheUsage,
66+
bool block_tree_db_in_memory,
67+
bool coins_db_in_memory,
6668
std::function<bool()> shutdown_requested = nullptr,
6769
std::function<void()> coins_error_cb = nullptr);
6870

0 commit comments

Comments
 (0)