Bitcoin Core  22.99.0
P2P Digital Currency
bitcoind.cpp
Go to the documentation of this file.
1 // Copyright (c) 2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <interfaces/chain.h>
6 #include <interfaces/echo.h>
7 #include <interfaces/init.h>
8 #include <interfaces/node.h>
9 #include <interfaces/wallet.h>
10 #include <node/context.h>
11 #include <util/system.h>
12 
13 #include <memory>
14 
15 namespace init {
16 namespace {
17 class BitcoindInit : public interfaces::Init
18 {
19 public:
20  BitcoindInit(NodeContext& node) : m_node(node)
21  {
22  m_node.args = &gArgs;
23  m_node.init = this;
24  }
25  std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
26  std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
27  std::unique_ptr<interfaces::WalletClient> makeWalletClient(interfaces::Chain& chain) override
28  {
29  return MakeWalletClient(chain, *Assert(m_node.args));
30  }
31  std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
33 };
34 } // namespace
35 } // namespace init
36 
37 namespace interfaces {
38 std::unique_ptr<Init> MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status)
39 {
40  return std::make_unique<init::BitcoindInit>(node);
41 }
42 } // namespace interfaces
interfaces
Definition: dummywallet.cpp:11
NodeContext::args
ArgsManager * args
Definition: context.h:49
interfaces::MakeChain
std::unique_ptr< Chain > MakeChain(NodeContext &node)
Return implementation of Chain interface.
Definition: interfaces.cpp:714
interfaces::Init
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:26
chain.h
m_node
NodeContext & m_node
Definition: bitcoind.cpp:32
interfaces::MakeWalletClient
std::unique_ptr< WalletClient > MakeWalletClient(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet client.
Definition: dummywallet.cpp:69
context.h
Assert
#define Assert(val)
Identity function.
Definition: check.h:57
interfaces::Chain
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:92
NodeContext::init
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:41
echo.h
node.h
init.h
interfaces::MakeEcho
std::unique_ptr< Echo > MakeEcho()
Return implementation of Echo interface.
Definition: echo.cpp:17
gArgs
ArgsManager gArgs
Definition: system.cpp:84
system.h
init
Definition: bitcoin-node.cpp:16
interfaces::MakeNode
std::unique_ptr< Node > MakeNode(NodeContext &context)
Return implementation of Node interface.
Definition: interfaces.cpp:713
node
Definition: interfaces.cpp:68
wallet.h
interfaces::MakeNodeInit
std::unique_ptr< Init > MakeNodeInit(NodeContext &node, int argc, char *argv[], int &exit_status)
Return implementation of Init interface for the node process.
Definition: bitcoin-node.cpp:45
NodeContext
NodeContext struct containing references to chain state and connection state.
Definition: context.h:39