wallet: Make WalletInitInterface members const

pull/12977/head
João Barbosa 7 years ago
parent 39439e5ab4
commit 1936125671

@ -76,15 +76,15 @@ std::unique_ptr<PeerLogicValidation> peerLogic;
class DummyWalletInit : public WalletInitInterface { class DummyWalletInit : public WalletInitInterface {
public: public:
std::string GetHelpString(bool showDebug) override {return std::string{};} std::string GetHelpString(bool showDebug) const override {return std::string{};}
bool ParameterInteraction() override {return true;} bool ParameterInteraction() const override {return true;}
void RegisterRPC(CRPCTable &) override {} void RegisterRPC(CRPCTable &) const override {}
bool Verify() override {return true;} bool Verify() const override {return true;}
bool Open() override {LogPrintf("No wallet support compiled in!\n"); return true;} bool Open() const override {LogPrintf("No wallet support compiled in!\n"); return true;}
void Start(CScheduler& scheduler) override {} void Start(CScheduler& scheduler) const override {}
void Flush() override {} void Flush() const override {}
void Stop() override {} void Stop() const override {}
void Close() override {} void Close() const override {}
}; };
static DummyWalletInit g_dummy_wallet_init; static DummyWalletInit g_dummy_wallet_init;

@ -18,39 +18,39 @@ class WalletInit : public WalletInitInterface {
public: public:
//! Return the wallets help message. //! Return the wallets help message.
std::string GetHelpString(bool showDebug) override; std::string GetHelpString(bool showDebug) const override;
//! Wallets parameter interaction //! Wallets parameter interaction
bool ParameterInteraction() override; bool ParameterInteraction() const override;
//! Register wallet RPCs. //! 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. //! 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 // 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). // being loaded (WalletParameterInteraction forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet).
bool Verify() override; bool Verify() const override;
//! Load wallet databases. //! Load wallet databases.
bool Open() override; bool Open() const override;
//! Complete startup of wallets. //! Complete startup of wallets.
void Start(CScheduler& scheduler) override; void Start(CScheduler& scheduler) const override;
//! Flush all wallets in preparation for shutdown. //! Flush all wallets in preparation for shutdown.
void Flush() override; void Flush() const override;
//! Stop all wallets. Wallets will be flushed first. //! Stop all wallets. Wallets will be flushed first.
void Stop() override; void Stop() const override;
//! Close all wallets. //! Close all wallets.
void Close() override; void Close() const override;
}; };
static WalletInit g_wallet_init; static WalletInit g_wallet_init;
WalletInitInterface* const g_wallet_init_interface = &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:")); 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))); 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; return strUsage;
} }
bool WalletInit::ParameterInteraction() bool WalletInit::ParameterInteraction() const
{ {
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
for (const std::string& wallet : gArgs.GetArgs("-wallet")) { for (const std::string& wallet : gArgs.GetArgs("-wallet")) {
@ -220,7 +220,7 @@ bool WalletInit::ParameterInteraction()
return true; return true;
} }
void WalletInit::RegisterRPC(CRPCTable &t) void WalletInit::RegisterRPC(CRPCTable &t) const
{ {
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
return; return;
@ -229,7 +229,7 @@ void WalletInit::RegisterRPC(CRPCTable &t)
RegisterWalletRPCCommands(t); RegisterWalletRPCCommands(t);
} }
bool WalletInit::Verify() bool WalletInit::Verify() const
{ {
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
return true; return true;
@ -304,7 +304,7 @@ bool WalletInit::Verify()
return true; return true;
} }
bool WalletInit::Open() bool WalletInit::Open() const
{ {
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
LogPrintf("Wallet disabled!\n"); LogPrintf("Wallet disabled!\n");
@ -322,28 +322,28 @@ bool WalletInit::Open()
return true; return true;
} }
void WalletInit::Start(CScheduler& scheduler) void WalletInit::Start(CScheduler& scheduler) const
{ {
for (CWalletRef pwallet : vpwallets) { for (CWalletRef pwallet : vpwallets) {
pwallet->postInitProcess(scheduler); pwallet->postInitProcess(scheduler);
} }
} }
void WalletInit::Flush() void WalletInit::Flush() const
{ {
for (CWalletRef pwallet : vpwallets) { for (CWalletRef pwallet : vpwallets) {
pwallet->Flush(false); pwallet->Flush(false);
} }
} }
void WalletInit::Stop() void WalletInit::Stop() const
{ {
for (CWalletRef pwallet : vpwallets) { for (CWalletRef pwallet : vpwallets) {
pwallet->Flush(true); pwallet->Flush(true);
} }
} }
void WalletInit::Close() void WalletInit::Close() const
{ {
for (CWalletRef pwallet : vpwallets) { for (CWalletRef pwallet : vpwallets) {
delete pwallet; delete pwallet;

@ -13,23 +13,23 @@ class CRPCTable;
class WalletInitInterface { class WalletInitInterface {
public: public:
/** Get wallet help string */ /** Get wallet help string */
virtual std::string GetHelpString(bool showDebug) = 0; virtual std::string GetHelpString(bool showDebug) const = 0;
/** Check wallet parameter interaction */ /** Check wallet parameter interaction */
virtual bool ParameterInteraction() = 0; virtual bool ParameterInteraction() const = 0;
/** Register wallet RPC*/ /** Register wallet RPC*/
virtual void RegisterRPC(CRPCTable &) = 0; virtual void RegisterRPC(CRPCTable &) const = 0;
/** Verify wallets */ /** Verify wallets */
virtual bool Verify() = 0; virtual bool Verify() const = 0;
/** Open wallets*/ /** Open wallets*/
virtual bool Open() = 0; virtual bool Open() const = 0;
/** Start wallets*/ /** Start wallets*/
virtual void Start(CScheduler& scheduler) = 0; virtual void Start(CScheduler& scheduler) const = 0;
/** Flush Wallets*/ /** Flush Wallets*/
virtual void Flush() = 0; virtual void Flush() const = 0;
/** Stop Wallets*/ /** Stop Wallets*/
virtual void Stop() = 0; virtual void Stop() const = 0;
/** Close wallets */ /** Close wallets */
virtual void Close() = 0; virtual void Close() const = 0;
virtual ~WalletInitInterface() {} virtual ~WalletInitInterface() {}
}; };

Loading…
Cancel
Save