diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-03-29 16:39:50 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-03-29 17:03:22 +0200 |
commit | 6d53663a4339070b32f95b09cb834cf8a3fc8986 (patch) | |
tree | e988fbe3e7523f0b6d118ab763ea616d9891ac9e /src/wallet | |
parent | d3908e2cee6534e261d8277c1508ce0fb7298509 (diff) | |
parent | c7ec5243892c38f9f77781b0e24a237942e7c776 (diff) |
Merge #10762: [wallet] Remove Wallet dependencies from init.cpp
c7ec524 [wallet] Add dummy wallet init class (John Newbery)
49baa4a [wallet] Use global g_wallet_init_interface to init/destroy the wallet. (John Newbery)
caaf972 [wallet] Create wallet init interface. (John Newbery)
5fb5421 [wallet] Move wallet init functions into WalletInit class. (John Newbery)
Pull request description:
This continues the work of #7965. This PR, along with several others, would remove the remaining dependencies from libbitcoin_server.a on libbitcoin_wallet.a.
To create the interface, I've just translated all the old init.cpp wallet function calls into an interface class. I've not done any thinking about whether it makes sense to change that interface by combining/splitting those calls. This is a purely internal interface, so there's no problem in changing it later.
Tree-SHA512: 32ea57615229c33fd1a7f2f29ebc11bf30337685f7211baffa899823ef74b65dcbf068289c557a161c5afffb51fdc38a2ee8180720371f64d433b12b0615cf3f
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/init.cpp | 22 | ||||
-rw-r--r-- | src/wallet/init.h | 45 |
2 files changed, 38 insertions, 29 deletions
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 61481e01b6..3d7bb674f0 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -14,7 +14,7 @@ #include <wallet/wallet.h> #include <wallet/walletutil.h> -std::string GetWalletHelpString(bool showDebug) +std::string WalletInit::GetHelpString(bool showDebug) { std::string strUsage = HelpMessageGroup(_("Wallet options:")); strUsage += HelpMessageOpt("-addresstype", strprintf("What type of addresses to use (\"legacy\", \"p2sh-segwit\", or \"bech32\", default: \"%s\")", FormatOutputType(DEFAULT_ADDRESS_TYPE))); @@ -56,7 +56,7 @@ std::string GetWalletHelpString(bool showDebug) return strUsage; } -bool WalletParameterInteraction() +bool WalletInit::ParameterInteraction() { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { for (const std::string& wallet : gArgs.GetArgs("-wallet")) { @@ -184,7 +184,7 @@ bool WalletParameterInteraction() return true; } -void RegisterWalletRPC(CRPCTable &t) +void WalletInit::RegisterRPC(CRPCTable &t) { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { return; @@ -193,7 +193,7 @@ void RegisterWalletRPC(CRPCTable &t) RegisterWalletRPCCommands(t); } -bool VerifyWallets() +bool WalletInit::Verify() { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { return true; @@ -268,7 +268,7 @@ bool VerifyWallets() return true; } -bool OpenWallets() +bool WalletInit::Open() { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { LogPrintf("Wallet disabled!\n"); @@ -286,25 +286,29 @@ bool OpenWallets() return true; } -void StartWallets(CScheduler& scheduler) { +void WalletInit::Start(CScheduler& scheduler) +{ for (CWalletRef pwallet : vpwallets) { pwallet->postInitProcess(scheduler); } } -void FlushWallets() { +void WalletInit::Flush() +{ for (CWalletRef pwallet : vpwallets) { pwallet->Flush(false); } } -void StopWallets() { +void WalletInit::Stop() +{ for (CWalletRef pwallet : vpwallets) { pwallet->Flush(true); } } -void CloseWallets() { +void WalletInit::Close() +{ for (CWalletRef pwallet : vpwallets) { delete pwallet; } diff --git a/src/wallet/init.h b/src/wallet/init.h index 0b3ee2dda2..f8be90d3e3 100644 --- a/src/wallet/init.h +++ b/src/wallet/init.h @@ -6,38 +6,43 @@ #ifndef BITCOIN_WALLET_INIT_H #define BITCOIN_WALLET_INIT_H +#include <walletinitinterface.h> #include <string> class CRPCTable; class CScheduler; -//! Return the wallets help message. -std::string GetWalletHelpString(bool showDebug); +class WalletInit : public WalletInitInterface { +public: -//! Wallets parameter interaction -bool WalletParameterInteraction(); + //! Return the wallets help message. + std::string GetHelpString(bool showDebug) override; -//! Register wallet RPCs. -void RegisterWalletRPC(CRPCTable &tableRPC); + //! Wallets parameter interaction + bool ParameterInteraction() override; -//! Responsible for reading and validating the -wallet arguments and verifying the wallet database. -// This function will perform salvage on the wallet if requested, as long as only one wallet is -// being loaded (WalletParameterInteraction forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet). -bool VerifyWallets(); + //! Register wallet RPCs. + void RegisterRPC(CRPCTable &tableRPC) override; -//! Load wallet databases. -bool OpenWallets(); + //! Responsible for reading and validating the -wallet arguments and verifying the wallet database. + // This function will perform salvage on the wallet if requested, as long as only one wallet is + // being loaded (WalletParameterInteraction forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet). + bool Verify() override; -//! Complete startup of wallets. -void StartWallets(CScheduler& scheduler); + //! Load wallet databases. + bool Open() override; -//! Flush all wallets in preparation for shutdown. -void FlushWallets(); + //! Complete startup of wallets. + void Start(CScheduler& scheduler) override; -//! Stop all wallets. Wallets will be flushed first. -void StopWallets(); + //! Flush all wallets in preparation for shutdown. + void Flush() override; -//! Close all wallets. -void CloseWallets(); + //! Stop all wallets. Wallets will be flushed first. + void Stop() override; + + //! Close all wallets. + void Close() override; +}; #endif // BITCOIN_WALLET_INIT_H |