Use CScheduler for wallet flushing, remove ThreadFlushWalletDB
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "primitives/transaction.h"
|
||||
#include "script/script.h"
|
||||
#include "script/sign.h"
|
||||
#include "scheduler.h"
|
||||
#include "timedata.h"
|
||||
#include "txmempool.h"
|
||||
#include "util.h"
|
||||
@@ -3754,17 +3755,17 @@ bool CWallet::InitLoadWallet()
|
||||
return true;
|
||||
}
|
||||
|
||||
std::atomic<bool> CWallet::fFlushThreadRunning(false);
|
||||
std::atomic<bool> CWallet::fFlushScheduled(false);
|
||||
|
||||
void CWallet::postInitProcess(boost::thread_group& threadGroup)
|
||||
void CWallet::postInitProcess(CScheduler& scheduler)
|
||||
{
|
||||
// Add wallet transactions that aren't already in a block to mempool
|
||||
// Do this here as mempool requires genesis block to be loaded
|
||||
ReacceptWalletTransactions();
|
||||
|
||||
// Run a thread to flush wallet periodically
|
||||
if (!CWallet::fFlushThreadRunning.exchange(true)) {
|
||||
threadGroup.create_thread(ThreadFlushWalletDB);
|
||||
if (!CWallet::fFlushScheduled.exchange(true)) {
|
||||
scheduler.scheduleEvery(MaybeFlushWalletDB, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user