From 19b3648bb52d27c3a9674159d71726b73fe532d9 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 9 Mar 2017 20:56:58 +0000 Subject: CWalletDB: Store the update counter per wallet --- src/wallet/walletdb.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'src/wallet/walletdb.cpp') diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 75dbb2edff..149d0e0c20 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -22,8 +22,6 @@ #include #include -static std::atomic nWalletDBUpdateCounter; - // // CWalletDB // @@ -762,20 +760,22 @@ void MaybeCompactWalletDB() return; } - static unsigned int nLastSeen = CWalletDB::GetUpdateCounter(); - static unsigned int nLastFlushed = CWalletDB::GetUpdateCounter(); + CWalletDBWrapper& dbh = pwalletMain->GetDBHandle(); + + static unsigned int nLastSeen = dbh.GetUpdateCounter(); + static unsigned int nLastFlushed = dbh.GetUpdateCounter(); static int64_t nLastWalletUpdate = GetTime(); - if (nLastSeen != CWalletDB::GetUpdateCounter()) + if (nLastSeen != dbh.GetUpdateCounter()) { - nLastSeen = CWalletDB::GetUpdateCounter(); + nLastSeen = dbh.GetUpdateCounter(); nLastWalletUpdate = GetTime(); } - if (nLastFlushed != CWalletDB::GetUpdateCounter() && GetTime() - nLastWalletUpdate >= 2) + if (nLastFlushed != dbh.GetUpdateCounter() && GetTime() - nLastWalletUpdate >= 2) { - if (CDB::PeriodicFlush(pwalletMain->GetDBHandle())) { - nLastFlushed = CWalletDB::GetUpdateCounter(); + if (CDB::PeriodicFlush(dbh)) { + nLastFlushed = dbh.GetUpdateCounter(); } } fOneThread = false; @@ -845,16 +845,6 @@ bool CWalletDB::WriteHDChain(const CHDChain& chain) return WriteIC(std::string("hdchain"), chain); } -void CWalletDB::IncrementUpdateCounter() -{ - nWalletDBUpdateCounter++; -} - -unsigned int CWalletDB::GetUpdateCounter() -{ - return nWalletDBUpdateCounter; -} - bool CWalletDB::TxnBegin() { return batch.TxnBegin(); -- cgit v1.2.3