diff options
author | Andrew Chow <achow101-github@achow101.com> | 2020-06-15 14:39:26 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2020-07-01 12:32:06 -0400 |
commit | 91d109156d63ff81cda534bd7bec8369af0027dd (patch) | |
tree | 288a93c357ad1dc8267c7597d3166e9d7cb33149 /src | |
parent | 8f1bcf8b7b6e47c05f2e43dd98ec3505b888d8b3 (diff) |
walletdb: Move PeriodicFlush into WalletDatabase
Make PeriodicFlush a non-static member of WalletDatabase instead of
WalletBatch.
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/bdb.cpp | 6 | ||||
-rw-r--r-- | src/wallet/bdb.h | 7 | ||||
-rw-r--r-- | src/wallet/walletdb.cpp | 2 |
3 files changed, 6 insertions, 9 deletions
diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp index b09337b5a6..4856f4bff8 100644 --- a/src/wallet/bdb.cpp +++ b/src/wallet/bdb.cpp @@ -614,14 +614,12 @@ void BerkeleyEnvironment::Flush(bool fShutdown) } } -bool BerkeleyBatch::PeriodicFlush(BerkeleyDatabase& database) +bool BerkeleyDatabase::PeriodicFlush() { - if (database.IsDummy()) { + if (IsDummy()) { return true; } bool ret = false; - BerkeleyEnvironment *env = database.env.get(); - const std::string& strFile = database.strFile; TRY_LOCK(cs_db, lockDb); if (lockDb) { diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h index f8ecdd75d4..d15efc810f 100644 --- a/src/wallet/bdb.h +++ b/src/wallet/bdb.h @@ -131,6 +131,9 @@ public: /** Make sure all changes are flushed to disk. */ void Flush(bool shutdown); + /* flush the wallet passively (TRY_LOCK) + ideal to be called periodically */ + bool PeriodicFlush(); void IncrementUpdateCounter(); @@ -215,10 +218,6 @@ public: void Flush(); void Close(); - /* flush the wallet passively (TRY_LOCK) - ideal to be called periodically */ - static bool PeriodicFlush(BerkeleyDatabase& database); - template <typename K, typename T> bool Read(const K& key, T& value) { diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 1c7649de67..0879f2d66e 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -964,7 +964,7 @@ void MaybeCompactWalletDB() } if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) { - if (BerkeleyBatch::PeriodicFlush(dbh)) { + if (dbh.PeriodicFlush()) { dbh.nLastFlushed = nUpdateCounter; } } |