aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.h
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@gmail.com>2019-04-17 10:07:15 -0400
committerJames O'Beirne <james.obeirne@pm.me>2020-07-01 14:44:24 -0400
commitb223111da2e0e9ceccef75df8a20252b0094b7bc (patch)
treedb40a92d85a7bd7a3dd8ff413abad13f21062220 /src/txdb.h
parentea3e9e0b84c57df4110ca9e5ccced65c5bbe4611 (diff)
downloadbitcoin-b223111da2e0e9ceccef75df8a20252b0094b7bc.tar.xz
txdb: add CCoinsViewDB::ChangeCacheSize
We'll need this to dynamically update the cache size of the existing CCoinsViewDB instance when we create a new one during snapshot activation. This requires us to keep the CDBWrapper instance as a pointer instead of a reference so that we're able to destruct it and create a new instance when the cache size changes. Also renames `db` to `m_db` since we're already modifying each usage. Includes feedback from Russ Yanofsky.
Diffstat (limited to 'src/txdb.h')
-rw-r--r--src/txdb.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/txdb.h b/src/txdb.h
index 488c24f935..0cf7e2f1b8 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -39,11 +39,16 @@ static const int64_t max_filter_index_cache = 1024;
//! Max memory allocated to coin DB specific cache (MiB)
static const int64_t nMaxCoinsDBCache = 8;
+// Actually declared in validation.cpp; can't include because of circular dependency.
+extern RecursiveMutex cs_main;
+
/** CCoinsView backed by the coin database (chainstate/) */
class CCoinsViewDB final : public CCoinsView
{
protected:
- CDBWrapper db;
+ 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.
@@ -60,6 +65,9 @@ public:
//! Attempt to update from an older database format. Returns whether an error occurred.
bool Upgrade();
size_t EstimateSize() const override;
+
+ //! Dynamically alter the underlying leveldb cache size.
+ void ResizeCache(size_t new_cache_size) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
};
/** Specialization of CCoinsViewCursor to iterate over a CCoinsViewDB */