diff options
Diffstat (limited to 'src/wallet/walletdb.cpp')
-rw-r--r-- | src/wallet/walletdb.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 149d0e0c20..6f5ddece9a 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -760,24 +760,23 @@ void MaybeCompactWalletDB() return; } - CWalletDBWrapper& dbh = pwalletMain->GetDBHandle(); + for (CWalletRef pwallet : vpwallets) { + CWalletDBWrapper& dbh = pwallet->GetDBHandle(); - static unsigned int nLastSeen = dbh.GetUpdateCounter(); - static unsigned int nLastFlushed = dbh.GetUpdateCounter(); - static int64_t nLastWalletUpdate = GetTime(); + unsigned int nUpdateCounter = dbh.nUpdateCounter; - if (nLastSeen != dbh.GetUpdateCounter()) - { - nLastSeen = dbh.GetUpdateCounter(); - nLastWalletUpdate = GetTime(); - } + if (dbh.nLastSeen != nUpdateCounter) { + dbh.nLastSeen = nUpdateCounter; + dbh.nLastWalletUpdate = GetTime(); + } - if (nLastFlushed != dbh.GetUpdateCounter() && GetTime() - nLastWalletUpdate >= 2) - { - if (CDB::PeriodicFlush(dbh)) { - nLastFlushed = dbh.GetUpdateCounter(); + if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) { + if (CDB::PeriodicFlush(dbh)) { + dbh.nLastFlushed = nUpdateCounter; + } } } + fOneThread = false; } |