MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / MaybeCompactWalletDB

Function MaybeCompactWalletDB

src/wallet/walletdb.cpp:750–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748}
749
750void MaybeCompactWalletDB()
751{
752 static std::atomic<bool> fOneThread(false);
753 if (fOneThread.exchange(true)) {
754 return;
755 }
756 if (!gArgs.GetBoolArg("-flushwallet", DEFAULT_FLUSHWALLET)) {
757 return;
758 }
759
760 for (const std::shared_ptr<CWallet>& pwallet : GetWallets()) {
761 WalletDatabase& dbh = pwallet->GetDBHandle();
762
763 unsigned int nUpdateCounter = dbh.nUpdateCounter;
764
765 if (dbh.nLastSeen != nUpdateCounter) {
766 dbh.nLastSeen = nUpdateCounter;
767 dbh.nLastWalletUpdate = GetTime();
768 }
769
770 if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) {
771 if (BerkeleyBatch::PeriodicFlush(dbh)) {
772 dbh.nLastFlushed = nUpdateCounter;
773 }
774 }
775 }
776
777 fOneThread = false;
778}
779
780//
781// Try to (very carefully!) recover wallet file if there is a problem.

Callers

nothing calls this directly

Calls 3

GetWalletsFunction · 0.85
GetTimeFunction · 0.85
GetBoolArgMethod · 0.80

Tested by

no test coverage detected