Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show All 15 Lines | |||||
#include <key_io.h> | #include <key_io.h> | ||||
#include <keystore.h> | #include <keystore.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <rpc/server.h> // for IsDeprecatedRPCEnabled | #include <rpc/server.h> // for IsDeprecatedRPCEnabled | ||||
#include <scheduler.h> | |||||
#include <script/script.h> | #include <script/script.h> | ||||
#include <script/sighashtype.h> | #include <script/sighashtype.h> | ||||
#include <script/sign.h> | #include <script/sign.h> | ||||
#include <timedata.h> | #include <timedata.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <ui_interface.h> | #include <ui_interface.h> | ||||
#include <util.h> | #include <util.h> | ||||
#include <utilmoneystr.h> | #include <utilmoneystr.h> | ||||
▲ Show 20 Lines • Show All 4,470 Lines • ▼ Show 20 Lines | CWallet *CWallet::CreateWalletFromFile(const CChainParams &chainParams, | ||||
LogPrintf("setKeyPool.size() = %u\n", walletInstance->GetKeyPoolSize()); | LogPrintf("setKeyPool.size() = %u\n", walletInstance->GetKeyPoolSize()); | ||||
LogPrintf("mapWallet.size() = %u\n", walletInstance->mapWallet.size()); | LogPrintf("mapWallet.size() = %u\n", walletInstance->mapWallet.size()); | ||||
LogPrintf("mapAddressBook.size() = %u\n", | LogPrintf("mapAddressBook.size() = %u\n", | ||||
walletInstance->mapAddressBook.size()); | walletInstance->mapAddressBook.size()); | ||||
return walletInstance; | return walletInstance; | ||||
} | } | ||||
std::atomic<bool> CWallet::fFlushScheduled(false); | void CWallet::postInitProcess() { | ||||
void CWallet::postInitProcess(CScheduler &scheduler) { | |||||
// Add wallet transactions that aren't already in a block to mempool. | // Add wallet transactions that aren't already in a block to mempool. | ||||
// Do this here as mempool requires genesis block to be loaded. | // Do this here as mempool requires genesis block to be loaded. | ||||
ReacceptWalletTransactions(); | ReacceptWalletTransactions(); | ||||
// Run a thread to flush wallet periodically. | |||||
if (!CWallet::fFlushScheduled.exchange(true)) { | |||||
scheduler.scheduleEvery( | |||||
[]() { | |||||
MaybeCompactWalletDB(); | |||||
return true; | |||||
}, | |||||
500); | |||||
} | |||||
} | } | ||||
bool CWallet::BackupWallet(const std::string &strDest) { | bool CWallet::BackupWallet(const std::string &strDest) { | ||||
return database->Backup(strDest); | return database->Backup(strDest); | ||||
} | } | ||||
CKeyPool::CKeyPool() { | CKeyPool::CKeyPool() { | ||||
nTime = GetTime(); | nTime = GetTime(); | ||||
▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines |