diff options
| author | James O'Beirne <[email protected]> | 2019-04-17 10:07:15 -0400 |
|---|---|---|
| committer | James O'Beirne <[email protected]> | 2020-07-01 14:44:24 -0400 |
| commit | b223111da2e0e9ceccef75df8a20252b0094b7bc (patch) | |
| tree | db40a92d85a7bd7a3dd8ff413abad13f21062220 /src/txdb.h | |
| parent | Merge #18700: Fix locking on WSL using flock instead of fcntl (diff) | |
| download | discoin-b223111da2e0e9ceccef75df8a20252b0094b7bc.tar.xz discoin-b223111da2e0e9ceccef75df8a20252b0094b7bc.zip | |
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.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/txdb.h b/src/txdb.h index 488c24f93..0cf7e2f1b 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 */ |