From 91d109156d63ff81cda534bd7bec8369af0027dd Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 15 Jun 2020 14:39:26 -0400 Subject: walletdb: Move PeriodicFlush into WalletDatabase Make PeriodicFlush a non-static member of WalletDatabase instead of WalletBatch. --- src/wallet/bdb.cpp | 6 ++---- src/wallet/bdb.h | 7 +++---- src/wallet/walletdb.cpp | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src/wallet') 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 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; } } -- cgit v1.2.3