aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.cpp
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2022-08-16 23:32:55 -0400
committerRyan Ofsky <ryan@ofsky.org>2023-02-10 04:39:11 -0400
commit2eaeded37f3a07c35eef38d9a80c1e5fbd4d41ee (patch)
tree3d41da9574698a955573712336ffb52e7badf065 /src/txdb.cpp
parent4f841cbb81ecce6e1aab42e8edb5bf1c6f0c36bb (diff)
downloadbitcoin-2eaeded37f3a07c35eef38d9a80c1e5fbd4d41ee.tar.xz
refactor, dbwrapper: Add DBParams and DBOptions structs
Add DBParams and DBOptions structs to remove ArgsManager uses from dbwrapper. To reduce size of this commit, this moves references to gArgs variable out of dbwrapper.cpp to calling code in txdb.cpp. But these moves are temporary. The gArgs references in txdb.cpp are moved out to calling code in init.cpp in later commits. This commit does not change behavior.
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r--src/txdb.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp
index c12b540b9b..697eaa926d 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -6,6 +6,7 @@
#include <txdb.h>
#include <chain.h>
+#include <node/database_args.h>
#include <pow.h>
#include <random.h>
#include <shutdown.h>
@@ -71,7 +72,13 @@ struct CoinEntry {
} // namespace
CCoinsViewDB::CCoinsViewDB(fs::path ldb_path, size_t nCacheSize, bool fMemory, bool fWipe) :
- m_db(std::make_unique<CDBWrapper>(ldb_path, nCacheSize, fMemory, fWipe, true)),
+ m_db{std::make_unique<CDBWrapper>(DBParams{
+ .path = ldb_path,
+ .cache_bytes = nCacheSize,
+ .memory_only = fMemory,
+ .wipe_data = fWipe,
+ .obfuscate = true,
+ .options = [] { DBOptions options; node::ReadDatabaseArgs(gArgs, options); return options; }()})},
m_ldb_path(ldb_path),
m_is_memory(fMemory) { }
@@ -83,8 +90,13 @@ void CCoinsViewDB::ResizeCache(size_t new_cache_size)
// Have to do a reset first to get the original `m_db` state to release its
// filesystem lock.
m_db.reset();
- m_db = std::make_unique<CDBWrapper>(
- m_ldb_path, new_cache_size, m_is_memory, /*fWipe=*/false, /*obfuscate=*/true);
+ m_db = std::make_unique<CDBWrapper>(DBParams{
+ .path = m_ldb_path,
+ .cache_bytes = new_cache_size,
+ .memory_only = m_is_memory,
+ .wipe_data = false,
+ .obfuscate = true,
+ .options = [] { DBOptions options; node::ReadDatabaseArgs(gArgs, options); return options; }()});
}
}
@@ -176,7 +188,12 @@ 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(gArgs.GetDataDirNet() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
+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) {