node/chainstate: Add options for in-memory DBs

This commit is contained in:
Kittywhiskers Van Gogh 2024-10-03 14:16:24 +00:00
parent 52bb35d9c8
commit c06e07461e
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
3 changed files with 8 additions and 2 deletions

View File

@ -1881,6 +1881,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
cache_sizes.block_tree_db, cache_sizes.block_tree_db,
cache_sizes.coins_db, cache_sizes.coins_db,
cache_sizes.coins, cache_sizes.coins,
/*block_tree_db_in_memory=*/false,
/*coins_db_in_memory=*/false,
ShutdownRequested, ShutdownRequested,
[]() { []() {
uiInterface.ThreadSafeMessageBox( uiInterface.ThreadSafeMessageBox(

View File

@ -48,6 +48,8 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
int64_t nBlockTreeDBCache, int64_t nBlockTreeDBCache,
int64_t nCoinDBCache, int64_t nCoinDBCache,
int64_t nCoinCacheUsage, int64_t nCoinCacheUsage,
bool block_tree_db_in_memory,
bool coins_db_in_memory,
std::function<bool()> shutdown_requested, std::function<bool()> shutdown_requested,
std::function<void()> coins_error_cb) std::function<void()> coins_error_cb)
{ {
@ -73,7 +75,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
// new CBlockTreeDB tries to delete the existing file, which // new CBlockTreeDB tries to delete the existing file, which
// fails if it's still open from the previous loop. Close it first: // fails if it's still open from the previous loop. Close it first:
pblocktree.reset(); 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 // Same logic as above with pblocktree
dmnman.reset(); dmnman.reset();
@ -177,7 +179,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
for (CChainState* chainstate : chainman.GetAll()) { for (CChainState* chainstate : chainman.GetAll()) {
chainstate->InitCoinsDB( chainstate->InitCoinsDB(
/* cache_size_bytes */ nCoinDBCache, /* cache_size_bytes */ nCoinDBCache,
/* in_memory */ false, /* in_memory */ coins_db_in_memory,
/* should_wipe */ fReset || fReindexChainState); /* should_wipe */ fReset || fReindexChainState);
if (coins_error_cb) { if (coins_error_cb) {

View File

@ -110,6 +110,8 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
int64_t nBlockTreeDBCache, int64_t nBlockTreeDBCache,
int64_t nCoinDBCache, int64_t nCoinDBCache,
int64_t nCoinCacheUsage, int64_t nCoinCacheUsage,
bool block_tree_db_in_memory,
bool coins_db_in_memory,
std::function<bool()> shutdown_requested = nullptr, std::function<bool()> shutdown_requested = nullptr,
std::function<void()> coins_error_cb = nullptr); std::function<void()> coins_error_cb = nullptr);