Skip to content

Commit f45b885

Browse files
committed
init/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 1f966b8 commit f45b885

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/init.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
13991399
cache_sizes.coin_cache_usage_size,
14001400
args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS),
14011401
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL),
1402+
false,
1403+
false,
14021404
GetAdjustedTime,
14031405
ShutdownRequested,
14041406
[]() {

src/init/chainstate.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ std::optional<ChainstateLoadingError> LoadChainstateSequence(bool fReset,
1919
int64_t nCoinCacheUsage,
2020
unsigned int check_blocks,
2121
unsigned int check_level,
22+
bool block_tree_db_in_memory,
23+
bool coins_db_in_memory,
2224
std::function<int64_t()> get_unix_time_seconds,
2325
std::optional<std::function<bool()>> shutdown_requested,
2426
std::optional<std::function<void()>> coins_error_cb,
@@ -39,7 +41,7 @@ std::optional<ChainstateLoadingError> LoadChainstateSequence(bool fReset,
3941
// new CBlockTreeDB tries to delete the existing file, which
4042
// fails if it's still open from the previous loop. Close it first:
4143
pblocktree.reset();
42-
pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, false, fReset));
44+
pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, block_tree_db_in_memory, fReset));
4345

4446
if (fReset) {
4547
pblocktree->WriteReindexing(true);
@@ -86,7 +88,7 @@ std::optional<ChainstateLoadingError> LoadChainstateSequence(bool fReset,
8688
for (CChainState* chainstate : chainman.GetAll()) {
8789
chainstate->InitCoinsDB(
8890
/* cache_size_bytes */ nCoinDBCache,
89-
/* in_memory */ false,
91+
/* in_memory */ coins_db_in_memory,
9092
/* should_wipe */ fReset || fReindexChainState);
9193

9294
if (coins_error_cb.has_value()) {

src/init/chainstate.h

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ std::optional<ChainstateLoadingError> LoadChainstateSequence(bool fReset,
4040
int64_t nCoinCacheUsage,
4141
unsigned int check_blocks,
4242
unsigned int check_level,
43+
bool block_tree_db_in_memory,
44+
bool coins_db_in_memory,
4345
std::function<int64_t()> get_unix_time_seconds,
4446
std::optional<std::function<bool()>> shutdown_requested = std::nullopt,
4547
std::optional<std::function<void()>> coins_error_cb = std::nullopt,

0 commit comments

Comments
 (0)