Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/load.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2018 The Bitcoin Core developers | // Copyright (c) 2009-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <wallet/load.h> | #include <wallet/load.h> | ||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <scheduler.h> | #include <scheduler.h> | ||||
#include <util/string.h> | #include <util/string.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
#include <wallet/walletdb.h> | |||||
bool VerifyWallets(const CChainParams &chainParams, interfaces::Chain &chain, | bool VerifyWallets(const CChainParams &chainParams, interfaces::Chain &chain, | ||||
const std::vector<std::string> &wallet_files) { | const std::vector<std::string> &wallet_files) { | ||||
if (gArgs.IsArgSet("-walletdir")) { | if (gArgs.IsArgSet("-walletdir")) { | ||||
fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); | fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); | ||||
boost::system::error_code error; | boost::system::error_code error; | ||||
// The canonical path cleans the path, preventing >1 Berkeley | // The canonical path cleans the path, preventing >1 Berkeley | ||||
// environment instances for the same directory | // environment instances for the same directory | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | for (const std::string &walletFile : wallet_files) { | ||||
return false; | return false; | ||||
} | } | ||||
AddWallet(pwallet); | AddWallet(pwallet); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
void StartWallets(CScheduler &scheduler) { | void StartWallets(CScheduler &scheduler, const ArgsManager &args) { | ||||
for (const std::shared_ptr<CWallet> &pwallet : GetWallets()) { | for (const std::shared_ptr<CWallet> &pwallet : GetWallets()) { | ||||
pwallet->postInitProcess(); | pwallet->postInitProcess(); | ||||
} | } | ||||
// Schedule periodic wallet flushes and tx rebroadcasts | // Schedule periodic wallet flushes and tx rebroadcasts | ||||
if (args.GetBoolArg("-flushwallet", DEFAULT_FLUSHWALLET)) { | |||||
scheduler.scheduleEvery( | scheduler.scheduleEvery( | ||||
[] { | [] { | ||||
MaybeCompactWalletDB(); | MaybeCompactWalletDB(); | ||||
return true; | return true; | ||||
}, | }, | ||||
std::chrono::milliseconds{500}); | std::chrono::milliseconds{500}); | ||||
} | |||||
scheduler.scheduleEvery( | scheduler.scheduleEvery( | ||||
[] { | [] { | ||||
MaybeResendWalletTxs(); | MaybeResendWalletTxs(); | ||||
return true; | return true; | ||||
}, | }, | ||||
std::chrono::milliseconds{1000}); | std::chrono::milliseconds{1000}); | ||||
} | } | ||||
Show All 21 Lines |