Skip to content

Commit 91d1091

Browse files
committed
walletdb: Move PeriodicFlush into WalletDatabase
Make PeriodicFlush a non-static member of WalletDatabase instead of WalletBatch.
1 parent 8f1bcf8 commit 91d1091

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/wallet/bdb.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,12 @@ void BerkeleyEnvironment::Flush(bool fShutdown)
614614
}
615615
}
616616

617-
bool BerkeleyBatch::PeriodicFlush(BerkeleyDatabase& database)
617+
bool BerkeleyDatabase::PeriodicFlush()
618618
{
619-
if (database.IsDummy()) {
619+
if (IsDummy()) {
620620
return true;
621621
}
622622
bool ret = false;
623-
BerkeleyEnvironment *env = database.env.get();
624-
const std::string& strFile = database.strFile;
625623
TRY_LOCK(cs_db, lockDb);
626624
if (lockDb)
627625
{

src/wallet/bdb.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ class BerkeleyDatabase
131131
/** Make sure all changes are flushed to disk.
132132
*/
133133
void Flush(bool shutdown);
134+
/* flush the wallet passively (TRY_LOCK)
135+
ideal to be called periodically */
136+
bool PeriodicFlush();
134137

135138
void IncrementUpdateCounter();
136139

@@ -215,10 +218,6 @@ class BerkeleyBatch
215218
void Flush();
216219
void Close();
217220

218-
/* flush the wallet passively (TRY_LOCK)
219-
ideal to be called periodically */
220-
static bool PeriodicFlush(BerkeleyDatabase& database);
221-
222221
template <typename K, typename T>
223222
bool Read(const K& key, T& value)
224223
{

src/wallet/walletdb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ void MaybeCompactWalletDB()
964964
}
965965

966966
if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) {
967-
if (BerkeleyBatch::PeriodicFlush(dbh)) {
967+
if (dbh.PeriodicFlush()) {
968968
dbh.nLastFlushed = nUpdateCounter;
969969
}
970970
}

0 commit comments

Comments
 (0)