/Users/mcomp/contrib/bitcoin/src/interfaces/init.h
Line | Count | Source (jump to first uncovered line) |
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 | | #ifndef BITCOIN_INTERFACES_INIT_H |
6 | | #define BITCOIN_INTERFACES_INIT_H |
7 | | |
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 | | |
14 | | #include <memory> |
15 | | |
16 | | namespace node { |
17 | | struct NodeContext; |
18 | | } // namespace node |
19 | | |
20 | | namespace interfaces { |
21 | | class Ipc; |
22 | | |
23 | | //! Initial interface created when a process is first started, and used to give |
24 | | //! and get access to other interfaces (Node, Chain, Wallet, etc). |
25 | | //! |
26 | | //! There is a different Init interface implementation for each process |
27 | | //! (bitcoin-gui, bitcoin-node, bitcoin-wallet, bitcoind, bitcoin-qt) and each |
28 | | //! implementation can implement the make methods for interfaces it supports. |
29 | | //! The default make methods all return null. |
30 | | class Init |
31 | | { |
32 | | public: |
33 | | virtual ~Init() = default; |
34 | 0 | virtual std::unique_ptr<Node> makeNode() { return nullptr; } |
35 | 0 | virtual std::unique_ptr<Chain> makeChain() { return nullptr; } |
36 | 0 | virtual std::unique_ptr<Mining> makeMining() { return nullptr; } |
37 | 0 | virtual std::unique_ptr<WalletLoader> makeWalletLoader(Chain& chain) { return nullptr; } |
38 | 0 | virtual std::unique_ptr<Echo> makeEcho() { return nullptr; } |
39 | 0 | virtual Ipc* ipc() { return nullptr; } |
40 | 0 | virtual bool canListenIpc() { return false; } |
41 | | }; |
42 | | |
43 | | //! Return implementation of Init interface for the node process. If the argv |
44 | | //! indicates that this is a child process spawned to handle requests from a |
45 | | //! parent process, this blocks and handles requests, then returns null and a |
46 | | //! status code to exit with. If this returns non-null, the caller can start up |
47 | | //! normally and use the Init object to spawn and connect to other processes |
48 | | //! while it is running. |
49 | | std::unique_ptr<Init> MakeNodeInit(node::NodeContext& node, int argc, char* argv[], int& exit_status); |
50 | | |
51 | | //! Return implementation of Init interface for the wallet process. |
52 | | std::unique_ptr<Init> MakeWalletInit(int argc, char* argv[], int& exit_status); |
53 | | |
54 | | //! Return implementation of Init interface for the gui process. |
55 | | std::unique_ptr<Init> MakeGuiInit(int argc, char* argv[]); |
56 | | } // namespace interfaces |
57 | | |
58 | | #endif // BITCOIN_INTERFACES_INIT_H |