diff options
author | fanquake <fanquake@gmail.com> | 2021-09-16 08:23:04 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2021-09-16 08:47:38 +0800 |
commit | 528e08119fd837dfe73d80d0064409ac03b3bfee (patch) | |
tree | 1fc7829920298294639b0375f3ce36c7bab5591c /src/init | |
parent | 2161a058552ac938f2079b311a2d12f5d1772d01 (diff) | |
parent | e4709c7b56612553fb7cbf16ef2d5099c5b732d0 (diff) | |
download | bitcoin-528e08119fd837dfe73d80d0064409ac03b3bfee.tar.xz |
Merge bitcoin/bitcoin#22219: multiprocess: Start using init makeNode, makeChain, etc methods
e4709c7b56612553fb7cbf16ef2d5099c5b732d0 Start using init makeNode, makeChain, etc methods (Russell Yanofsky)
Pull request description:
Use `interfaces::Init::make*` methods instead of `interfaces::Make*` functions, so interfaces can be constructed differently in different executable without having to change any code. (So for example `bitcoin-gui` can make an `interfaces::Node` pointer that communicates with a `bitcoin-node` subprocess, while `bitcoin-qt` can make an `interfaces::Node` pointer that controls node code in the same process.)
---
This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR #10102.
ACKs for top commit:
jamesob:
reACK https://github.com/bitcoin/bitcoin/commit/e4709c7b56612553fb7cbf16ef2d5099c5b732d0
achow101:
ACK e4709c7b56612553fb7cbf16ef2d5099c5b732d0
benthecarman:
utACK e4709c7b56612553fb7cbf16ef2d5099c5b732d0
Tree-SHA512: 580c1979dbb2ef444157c8e53041e70d15ddeee77e5cbdb34f70b6d228cc2d2fe3843825f172da84e506200c58f7e0932f7cd4c006bb5058c1f4e43259394834
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/bitcoin-node.cpp | 9 | ||||
-rw-r--r-- | src/init/bitcoind.cpp | 11 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/init/bitcoin-node.cpp b/src/init/bitcoin-node.cpp index 6b6157c139..fa56153745 100644 --- a/src/init/bitcoin-node.cpp +++ b/src/init/bitcoin-node.cpp @@ -2,9 +2,12 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <interfaces/chain.h> #include <interfaces/echo.h> #include <interfaces/init.h> #include <interfaces/ipc.h> +#include <interfaces/node.h> +#include <interfaces/wallet.h> #include <node/context.h> #include <util/system.h> @@ -24,6 +27,12 @@ public: m_node.args = &gArgs; m_node.init = this; } + std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); } + std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); } + std::unique_ptr<interfaces::WalletClient> makeWalletClient(interfaces::Chain& chain) override + { + return MakeWalletClient(chain, *Assert(m_node.args)); + } std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); } interfaces::Ipc* ipc() override { return m_ipc.get(); } NodeContext& m_node; diff --git a/src/init/bitcoind.cpp b/src/init/bitcoind.cpp index 1d4504c24f..9c8d5bd9bb 100644 --- a/src/init/bitcoind.cpp +++ b/src/init/bitcoind.cpp @@ -2,7 +2,11 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <interfaces/chain.h> +#include <interfaces/echo.h> #include <interfaces/init.h> +#include <interfaces/node.h> +#include <interfaces/wallet.h> #include <node/context.h> #include <util/system.h> @@ -18,6 +22,13 @@ public: m_node.args = &gArgs; m_node.init = this; } + std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); } + std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); } + std::unique_ptr<interfaces::WalletClient> makeWalletClient(interfaces::Chain& chain) override + { + return MakeWalletClient(chain, *Assert(m_node.args)); + } + std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); } NodeContext& m_node; }; } // namespace |