mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
walletdb: Move PeriodicFlush into WalletDatabase
Make PeriodicFlush a non-static member of WalletDatabase instead of WalletBatch.
This commit is contained in:
parent
8f1bcf8b7b
commit
91d109156d
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -964,7 +964,7 @@ void MaybeCompactWalletDB()
|
||||
}
|
||||
|
||||
if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) {
|
||||
if (BerkeleyBatch::PeriodicFlush(dbh)) {
|
||||
if (dbh.PeriodicFlush()) {
|
||||
dbh.nLastFlushed = nUpdateCounter;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user