diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -391,8 +392,16 @@ void WalletInit::Start(CScheduler &scheduler) const { for (CWallet *pwallet : GetWallets()) { - pwallet->postInitProcess(scheduler); + pwallet->postInitProcess(); } + + // Run a thread to flush wallet periodically + scheduler.scheduleEvery( + [] { + MaybeCompactWalletDB(); + return true; + }, + 500); } void WalletInit::Flush() const { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -63,7 +63,6 @@ class COutput; class CReserveKey; class CScript; -class CScheduler; class CTxMemPool; class CWalletTx; @@ -1210,7 +1209,7 @@ * Gives the wallet a chance to register repetitive tasks and complete * post-init tasks */ - void postInitProcess(CScheduler &scheduler); + void postInitProcess(); bool BackupWallet(const std::string &strDest); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -21,7 +21,6 @@ #include #include #include // for IsDeprecatedRPCEnabled -#include #include