Bitcoin Core 31.99.0
P2P Digital Currency
bitcoind.cpp
Go to the documentation of this file.
1// Copyright (c) 2021-present 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/init.h> // IWYU pragma: associated
6
7#include <init.h>
8#include <interfaces/chain.h>
9#include <interfaces/echo.h>
10#include <interfaces/mining.h>
11#include <interfaces/node.h>
12#include <interfaces/wallet.h>
13#include <node/context.h>
14#include <util/check.h>
15
16#include <memory>
17
19
20namespace init {
21namespace {
22const char* EXE_NAME = "bitcoind";
23
24class BitcoindInit : public interfaces::Init
25{
26public:
27 BitcoindInit(NodeContext& node) : m_node(node)
28 {
30 m_node.init = this;
31 }
32 std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
33 std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
34 std::unique_ptr<interfaces::Mining> makeMining() override { return interfaces::MakeMining(m_node); }
35 std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
36 {
37 return MakeWalletLoader(chain, *Assert(m_node.args));
38 }
39 std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
40 const char* exeName() override { return EXE_NAME; }
42};
43} // namespace
44} // namespace init
45
46namespace interfaces {
47std::unique_ptr<Init> MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status)
48{
49 return std::make_unique<init::BitcoindInit>(node);
50}
51} // namespace interfaces
int exit_status
Definition: bitcoind.cpp:266
#define Assert(val)
Identity function.
Definition: check.h:116
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:117
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:39
NodeContext & m_node
Definition: bitcoind.cpp:41
void InitContext(NodeContext &node)
Initialize node context shutdown and args variables.
Definition: init.cpp:234
Definition: basic.cpp:11
std::unique_ptr< Node > MakeNode(node::NodeContext &context)
Return implementation of Node interface.
std::unique_ptr< Echo > MakeEcho()
Return implementation of Echo interface.
Definition: interfaces.cpp:53
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
Definition: dummywallet.cpp:59
std::unique_ptr< Mining > MakeMining(const node::NodeContext &node, bool wait_loaded=true)
Return implementation of Mining interface.
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: messages.h:21
NodeContext struct containing references to chain state and connection state.
Definition: context.h:59
ArgsManager * args
Definition: context.h:78
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:64