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 using node::NodeContext;
16 
17 namespace init {
18 namespace {
19 class BitcoindInit : public interfaces::Init
20 {
21 public:
22  BitcoindInit(NodeContext& node) : m_node(node)
23  {
24  m_node.args = &gArgs;
25  m_node.init = this;
26  }
27  std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
28  std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
29  std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
30  {
31  return MakeWalletLoader(chain, *Assert(m_node.args));
32  }
33  std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
35 };
36 } // namespace
37 } // namespace init
38 
39 namespace interfaces {
40 std::unique_ptr<Init> MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status)
41 {
42  return std::make_unique<init::BitcoindInit>(node);
43 }
44 } // namespace interfaces
interfaces::MakeChain
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
Definition: interfaces.cpp:733
interfaces
Definition: dummywallet.cpp:10
node::NodeContext
NodeContext struct containing references to chain state and connection state.
Definition: context.h:40
interfaces::Init
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:28
interfaces::MakeNodeInit
std::unique_ptr< Init > MakeNodeInit(node::NodeContext &node, int argc, char *argv[], int &exit_status)
Return implementation of Init interface for the node process.
Definition: bitcoin-node.cpp:45
chain.h
m_node
NodeContext & m_node
Definition: bitcoind.cpp:34
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:94
echo.h
node.h
interfaces::MakeNode
std::unique_ptr< Node > MakeNode(node::NodeContext &context)
Return implementation of Node interface.
Definition: interfaces.cpp:732
init.h
node::NodeContext::init
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:42
interfaces::MakeEcho
std::unique_ptr< Echo > MakeEcho()
Return implementation of Echo interface.
Definition: echo.cpp:17
gArgs
ArgsManager gArgs
Definition: system.cpp:80
node::NodeContext::args
ArgsManager * args
Definition: context.h:50
system.h
init
Definition: bitcoin-gui.cpp:16
node
Definition: init.h:22
wallet.h
interfaces::MakeWalletLoader
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
Definition: dummywallet.cpp:61