walletdb: Move PeriodicFlush into WalletDatabase

Make PeriodicFlush a non-static member of WalletDatabase instead of
WalletBatch.
This commit is contained in:
Andrew Chow 2020-06-15 14:39:26 -04:00
parent 8f1bcf8b7b
commit 91d109156d
3 changed files with 6 additions and 9 deletions

View File

@ -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)
{

View File

@ -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)
{

View File

@ -964,7 +964,7 @@ void MaybeCompactWalletDB()
}
if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) {
if (BerkeleyBatch::PeriodicFlush(dbh)) {
if (dbh.PeriodicFlush()) {
dbh.nLastFlushed = nUpdateCounter;
}
}