From 1936125671fbdb3411fcdf0d09fbd7ced32272e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Fri, 13 Apr 2018 14:02:59 +0100 Subject: wallet: Make WalletInitInterface members const --- src/init.cpp | 18 +++++++++--------- src/wallet/init.cpp | 36 ++++++++++++++++++------------------ src/walletinitinterface.h | 18 +++++++++--------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 9edd93000f..0be5f7c4f7 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -76,15 +76,15 @@ std::unique_ptr peerLogic; class DummyWalletInit : public WalletInitInterface { public: - std::string GetHelpString(bool showDebug) override {return std::string{};} - bool ParameterInteraction() override {return true;} - void RegisterRPC(CRPCTable &) override {} - bool Verify() override {return true;} - bool Open() override {LogPrintf("No wallet support compiled in!\n"); return true;} - void Start(CScheduler& scheduler) override {} - void Flush() override {} - void Stop() override {} - void Close() override {} + std::string GetHelpString(bool showDebug) const override {return std::string{};} + bool ParameterInteraction() const override {return true;} + void RegisterRPC(CRPCTable &) const override {} + bool Verify() const override {return true;} + bool Open() const override {LogPrintf("No wallet support compiled in!\n"); return true;} + void Start(CScheduler& scheduler) const override {} + void Flush() const override {} + void Stop() const override {} + void Close() const override {} }; static DummyWalletInit g_dummy_wallet_init; diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index b6f4a0e1e1..72d1fa3ec6 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -18,39 +18,39 @@ class WalletInit : public WalletInitInterface { public: //! Return the wallets help message. - std::string GetHelpString(bool showDebug) override; + std::string GetHelpString(bool showDebug) const override; //! Wallets parameter interaction - bool ParameterInteraction() override; + bool ParameterInteraction() const override; //! Register wallet RPCs. - void RegisterRPC(CRPCTable &tableRPC) override; + void RegisterRPC(CRPCTable &tableRPC) const 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 Verify() override; + bool Verify() const override; //! Load wallet databases. - bool Open() override; + bool Open() const override; //! Complete startup of wallets. - void Start(CScheduler& scheduler) override; + void Start(CScheduler& scheduler) const override; //! Flush all wallets in preparation for shutdown. - void Flush() override; + void Flush() const override; //! Stop all wallets. Wallets will be flushed first. - void Stop() override; + void Stop() const override; //! Close all wallets. - void Close() override; + void Close() const override; }; static WalletInit g_wallet_init; WalletInitInterface* const g_wallet_init_interface = &g_wallet_init; -std::string WalletInit::GetHelpString(bool showDebug) +std::string WalletInit::GetHelpString(bool showDebug) const { 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))); @@ -92,7 +92,7 @@ std::string WalletInit::GetHelpString(bool showDebug) return strUsage; } -bool WalletInit::ParameterInteraction() +bool WalletInit::ParameterInteraction() const { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { for (const std::string& wallet : gArgs.GetArgs("-wallet")) { @@ -220,7 +220,7 @@ bool WalletInit::ParameterInteraction() return true; } -void WalletInit::RegisterRPC(CRPCTable &t) +void WalletInit::RegisterRPC(CRPCTable &t) const { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { return; @@ -229,7 +229,7 @@ void WalletInit::RegisterRPC(CRPCTable &t) RegisterWalletRPCCommands(t); } -bool WalletInit::Verify() +bool WalletInit::Verify() const { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { return true; @@ -304,7 +304,7 @@ bool WalletInit::Verify() return true; } -bool WalletInit::Open() +bool WalletInit::Open() const { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { LogPrintf("Wallet disabled!\n"); @@ -322,28 +322,28 @@ bool WalletInit::Open() return true; } -void WalletInit::Start(CScheduler& scheduler) +void WalletInit::Start(CScheduler& scheduler) const { for (CWalletRef pwallet : vpwallets) { pwallet->postInitProcess(scheduler); } } -void WalletInit::Flush() +void WalletInit::Flush() const { for (CWalletRef pwallet : vpwallets) { pwallet->Flush(false); } } -void WalletInit::Stop() +void WalletInit::Stop() const { for (CWalletRef pwallet : vpwallets) { pwallet->Flush(true); } } -void WalletInit::Close() +void WalletInit::Close() const { for (CWalletRef pwallet : vpwallets) { delete pwallet; diff --git a/src/walletinitinterface.h b/src/walletinitinterface.h index c7eee37ce5..5bfde6faaf 100644 --- a/src/walletinitinterface.h +++ b/src/walletinitinterface.h @@ -13,23 +13,23 @@ class CRPCTable; class WalletInitInterface { public: /** Get wallet help string */ - virtual std::string GetHelpString(bool showDebug) = 0; + virtual std::string GetHelpString(bool showDebug) const = 0; /** Check wallet parameter interaction */ - virtual bool ParameterInteraction() = 0; + virtual bool ParameterInteraction() const = 0; /** Register wallet RPC*/ - virtual void RegisterRPC(CRPCTable &) = 0; + virtual void RegisterRPC(CRPCTable &) const = 0; /** Verify wallets */ - virtual bool Verify() = 0; + virtual bool Verify() const = 0; /** Open wallets*/ - virtual bool Open() = 0; + virtual bool Open() const = 0; /** Start wallets*/ - virtual void Start(CScheduler& scheduler) = 0; + virtual void Start(CScheduler& scheduler) const = 0; /** Flush Wallets*/ - virtual void Flush() = 0; + virtual void Flush() const = 0; /** Stop Wallets*/ - virtual void Stop() = 0; + virtual void Stop() const = 0; /** Close wallets */ - virtual void Close() = 0; + virtual void Close() const = 0; virtual ~WalletInitInterface() {} }; -- cgit v1.2.3