diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2022-08-16 23:32:55 -0400 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2023-02-10 04:39:11 -0400 |
commit | 0352258148c51572426666d337c7b28d0033376c (patch) | |
tree | fac9e1484d8c25cfa64b1869c866e82b371c10b3 /src/node | |
parent | c00fa1a7341d3f47f992e0beb043da655cbca777 (diff) |
refactor, txdb: Use DBParams struct in CBlockTreeDB
Use DBParams struct to remove ArgsManager uses from txdb.
To reduce size of this commit, this moves references to gArgs variable out of
txdb.cpp to calling code in chainstate.cpp. But these moves are temporary. The
gArgs references in chainstate.cpp are moved out to calling code in init.cpp in
later commits.
This commit does not change behavior.
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/chainstate.cpp | 9 |
1 files changed, 8 insertions, 1 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); |