aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.h
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
commitc00fa1a7341d3f47f992e0beb043da655cbca777 (patch)
treec48ec5e4b9f5713e7e50c3bd4199586c8d96130e /src/txdb.h
parent2eaeded37f3a07c35eef38d9a80c1e5fbd4d41ee (diff)
downloadbitcoin-c00fa1a7341d3f47f992e0beb043da655cbca777.tar.xz
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.
Diffstat (limited to 'src/txdb.h')
-rw-r--r--src/txdb.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/txdb.h b/src/txdb.h
index e3422846c0..bfbfab57a4 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -45,18 +45,24 @@ static const int64_t max_filter_index_cache = 1024;
//! Max memory allocated to coin DB specific cache (MiB)
static const int64_t nMaxCoinsDBCache = 8;
+//! User-controlled performance and debug options.
+struct CoinsViewOptions {
+ //! Maximum database write batch size in bytes.
+ size_t batch_write_bytes = nDefaultDbBatchSize;
+ //! If non-zero, randomly exit when the database is flushed with (1/ratio)
+ //! probability.
+ int simulate_crash_ratio = 0;
+};
+
/** CCoinsView backed by the coin database (chainstate/) */
class CCoinsViewDB final : public CCoinsView
{
protected:
+ DBParams m_db_params;
+ CoinsViewOptions m_options;
std::unique_ptr<CDBWrapper> m_db;
- fs::path m_ldb_path;
- bool m_is_memory;
public:
- /**
- * @param[in] ldb_path Location in the filesystem where leveldb data will be stored.
- */
- explicit CCoinsViewDB(fs::path ldb_path, size_t nCacheSize, bool fMemory, bool fWipe);
+ explicit CCoinsViewDB(DBParams db_params, CoinsViewOptions options);
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
bool HaveCoin(const COutPoint &outpoint) const override;