mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
refactor, txdb: Add CoinsViewOptions struct
Add CoinsViewOptions 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 validation.cpp. But these moves are temporary. The gArgs references in validation.cpp are moved out to calling code in init.cpp in later commits. This commit does not change behavior.
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include <node/blockstorage.h>
|
||||
#include <node/interface_ui.h>
|
||||
#include <node/utxo_snapshot.h>
|
||||
#include <node/coins_view_args.h>
|
||||
#include <node/database_args.h>
|
||||
#include <policy/policy.h>
|
||||
#include <policy/rbf.h>
|
||||
#include <policy/settings.h>
|
||||
@@ -1511,13 +1513,9 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
|
||||
return nSubsidy;
|
||||
}
|
||||
|
||||
CoinsViews::CoinsViews(
|
||||
fs::path ldb_name,
|
||||
size_t cache_size_bytes,
|
||||
bool in_memory,
|
||||
bool should_wipe) : m_dbview(
|
||||
gArgs.GetDataDirNet() / ldb_name, cache_size_bytes, in_memory, should_wipe),
|
||||
m_catcherview(&m_dbview) {}
|
||||
CoinsViews::CoinsViews(DBParams db_params, CoinsViewOptions options)
|
||||
: m_dbview{std::move(db_params), std::move(options)},
|
||||
m_catcherview(&m_dbview) {}
|
||||
|
||||
void CoinsViews::InitCache()
|
||||
{
|
||||
@@ -1546,7 +1544,14 @@ void Chainstate::InitCoinsDB(
|
||||
}
|
||||
|
||||
m_coins_views = std::make_unique<CoinsViews>(
|
||||
leveldb_name, cache_size_bytes, in_memory, should_wipe);
|
||||
DBParams{
|
||||
.path = gArgs.GetDataDirNet() / leveldb_name,
|
||||
.cache_bytes = cache_size_bytes,
|
||||
.memory_only = in_memory,
|
||||
.wipe_data = should_wipe,
|
||||
.obfuscate = true,
|
||||
.options = [] { DBOptions options; node::ReadDatabaseArgs(gArgs, options); return options; }()},
|
||||
[] { CoinsViewOptions options; node::ReadCoinsViewArgs(gArgs, options); return options; }());
|
||||
}
|
||||
|
||||
void Chainstate::InitCoinsCache(size_t cache_size_bytes)
|
||||
|
||||
Reference in New Issue
Block a user