aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2017-09-28 14:13:29 -0400
committerRussell Yanofsky <russ@yanofsky.org>2018-11-06 11:44:40 -0400
commitea961c3d7256c66146b4976ab1293db4a628c0de (patch)
treeae47f0f47559d05007ebc63130f3099d9f003a5e /src/interfaces
parent8db11dd0b182a93042899651545cc21b34bf0742 (diff)
downloadbitcoin-ea961c3d7256c66146b4976ab1293db4a628c0de.tar.xz
Remove direct node->wallet calls in init.cpp
Route calls during node initialization and shutdown that would happen between a node process and wallet processes through the serializable `Chain::Client` interface, rather than `WalletInitInterface` which is now simpler and only deals with early initialization and parameter interaction. This commit mostly does not change behavior. The only change is that the "Wallet disabled!" and "No wallet support compiled in!" messages are now logged earlier during startup.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/chain.h20
-rw-r--r--src/interfaces/wallet.cpp12
2 files changed, 32 insertions, 0 deletions
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
index 8a40cb4cda..30bc9f5f73 100644
--- a/src/interfaces/chain.h
+++ b/src/interfaces/chain.h
@@ -9,6 +9,8 @@
#include <string>
#include <vector>
+class CScheduler;
+
namespace interfaces {
//! Interface for giving wallet processes access to blockchain state.
@@ -24,6 +26,24 @@ class ChainClient
{
public:
virtual ~ChainClient() {}
+
+ //! Register rpcs.
+ virtual void registerRpcs() = 0;
+
+ //! Check for errors before loading.
+ virtual bool verify() = 0;
+
+ //! Load saved state.
+ virtual bool load() = 0;
+
+ //! Start client execution and provide a scheduler.
+ virtual void start(CScheduler& scheduler) = 0;
+
+ //! Save state to disk.
+ virtual void flush() = 0;
+
+ //! Shut down client.
+ virtual void stop() = 0;
};
//! Return implementation of Chain interface.
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
index e9f4669f4d..a29440ee4a 100644
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -7,6 +7,7 @@
#include <amount.h>
#include <chain.h>
#include <consensus/validation.h>
+#include <init.h>
#include <interfaces/chain.h>
#include <interfaces/handler.h>
#include <net.h>
@@ -14,6 +15,8 @@
#include <policy/fees.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
+#include <rpc/server.h>
+#include <scheduler.h>
#include <script/ismine.h>
#include <script/standard.h>
#include <support/allocators/secure.h>
@@ -25,7 +28,9 @@
#include <validation.h>
#include <wallet/feebumper.h>
#include <wallet/fees.h>
+#include <wallet/rpcwallet.h>
#include <wallet/wallet.h>
+#include <wallet/walletutil.h>
#include <memory>
#include <string>
@@ -470,6 +475,13 @@ public:
: m_chain(chain), m_wallet_filenames(std::move(wallet_filenames))
{
}
+ void registerRpcs() override { return RegisterWalletRPCCommands(::tableRPC); }
+ bool verify() override { return VerifyWallets(m_chain, m_wallet_filenames); }
+ bool load() override { return LoadWallets(m_chain, m_wallet_filenames); }
+ void start(CScheduler& scheduler) override { return StartWallets(scheduler); }
+ void flush() override { return FlushWallets(); }
+ void stop() override { return StopWallets(); }
+ ~WalletClientImpl() override { UnloadWallets(); }
Chain& m_chain;
std::vector<std::string> m_wallet_filenames;