aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/node/chainstate.cpp9
-rw-r--r--src/test/util/setup_common.cpp5
-rw-r--r--src/txdb.cpp9
-rw-r--r--src/txdb.h3
4 files changed, 13 insertions, 13 deletions
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp
index ba1024d22e..fa521a9e03 100644
--- a/src/node/chainstate.cpp
+++ b/src/node/chainstate.cpp
@@ -10,12 +10,14 @@
#include <consensus/params.h>
#include <logging.h>
#include <node/blockstorage.h>
+#include <node/database_args.h>
#include <node/caches.h>
#include <sync.h>
#include <threadsafety.h>
#include <tinyformat.h>
#include <txdb.h>
#include <uint256.h>
+#include <util/system.h>
#include <util/time.h>
#include <util/translation.h>
#include <validation.h>
@@ -64,7 +66,12 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
// 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(cache_sizes.block_tree_db, options.block_tree_db_in_memory, options.reindex));
+ pblocktree = std::make_unique<CBlockTreeDB>(DBParams{
+ .path = gArgs.GetDataDirNet() / "blocks" / "index",
+ .cache_bytes = static_cast<size_t>(cache_sizes.block_tree_db),
+ .memory_only = options.block_tree_db_in_memory,
+ .wipe_data = options.reindex,
+ .options = [] { DBOptions options; node::ReadDatabaseArgs(gArgs, options); return options; }()});
if (options.reindex) {
pblocktree->WriteReindexing(true);
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index 6e72f69968..2318380c6e 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -184,7 +184,10 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
.check_block_index = true,
};
m_node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
- m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(m_cache_sizes.block_tree_db, true);
+ m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(DBParams{
+ .path = m_args.GetDataDirNet() / "blocks" / "index",
+ .cache_bytes = static_cast<size_t>(m_cache_sizes.block_tree_db),
+ .memory_only = true});
constexpr int script_check_threads = 2;
StartScriptCheckWorkerThreads(script_check_threads);
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 5803bc7b31..7257fb4959 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -6,7 +6,6 @@
#include <txdb.h>
#include <chain.h>
-#include <node/database_args.h>
#include <pow.h>
#include <random.h>
#include <shutdown.h>
@@ -176,14 +175,6 @@ size_t CCoinsViewDB::EstimateSize() const
return m_db->EstimateSize(DB_COIN, uint8_t(DB_COIN + 1));
}
-CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper{DBParams{
- .path = gArgs.GetDataDirNet() / "blocks" / "index",
- .cache_bytes = nCacheSize,
- .memory_only = fMemory,
- .wipe_data = fWipe,
- .options = [] { DBOptions options; node::ReadDatabaseArgs(gArgs, options); return options; }()}} {
-}
-
bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) {
return Read(std::make_pair(DB_BLOCK_FILES, nFile), info);
}
diff --git a/src/txdb.h b/src/txdb.h
index bfbfab57a4..8a876349fb 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -86,8 +86,7 @@ public:
class CBlockTreeDB : public CDBWrapper
{
public:
- explicit CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
-
+ using CDBWrapper::CDBWrapper;
bool WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo);
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &info);
bool ReadLastBlockFile(int &nFile);