Bitcoin Core  24.99.0
P2P Digital Currency
bitcoind.cpp
Go to the documentation of this file.
1 // Copyright (c) 2021-2022 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/check.h>
12 #include <util/system.h>
13 
14 #include <memory>
15 
16 using node::NodeContext;
17 
18 namespace init {
19 namespace {
20 class BitcoindInit : public interfaces::Init
21 {
22 public:
23  BitcoindInit(NodeContext& node) : m_node(node)
24  {
25  m_node.args = &gArgs;
26  m_node.init = this;
27  }
28  std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
29  std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
30  std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
31  {
32  return MakeWalletLoader(chain, *Assert(m_node.args));
33  }
34  std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
36 };
37 } // namespace
38 } // namespace init
39 
40 namespace interfaces {
41 std::unique_ptr<Init> MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status)
42 {
43  return std::make_unique<init::BitcoindInit>(node);
44 }
45 } // namespace interfaces
int exit_status
Definition: bitcoind.cpp:267
#define Assert(val)
Identity function.
Definition: check.h:73
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:119
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:30
NodeContext & m_node
Definition: bitcoind.cpp:35
std::unique_ptr< Node > MakeNode(node::NodeContext &context)
Return implementation of Node interface.
Definition: interfaces.cpp:795
std::unique_ptr< Echo > MakeEcho()
Return implementation of Echo interface.
Definition: interfaces.cpp:52
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
Definition: dummywallet.cpp:62
std::unique_ptr< Init > MakeNodeInit(node::NodeContext &node, int argc, char *argv[], int &exit_status)
Return implementation of Init interface for the node process.
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
Definition: interfaces.cpp:796
Definition: init.h:25
NodeContext struct containing references to chain state and connection state.
Definition: context.h:43
ArgsManager * args
Definition: context.h:56
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:47
ArgsManager gArgs
Definition: system.cpp:73