Bitcoin Core  27.99.0
P2P Digital Currency
context.h
Go to the documentation of this file.
1 // Copyright (c) 2019-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_NODE_CONTEXT_H
6 #define BITCOIN_NODE_CONTEXT_H
7 
8 #include <atomic>
9 #include <cstdlib>
10 #include <functional>
11 #include <memory>
12 #include <vector>
13 
14 class ArgsManager;
15 class AddrMan;
16 class BanMan;
17 class BaseIndex;
19 class CConnman;
20 class ValidationSignals;
21 class CScheduler;
22 class CTxMemPool;
23 class ChainstateManager;
24 class ECC_Context;
25 class NetGroupManager;
26 class PeerManager;
27 namespace interfaces {
28 class Chain;
29 class ChainClient;
30 class Mining;
31 class Init;
32 class WalletLoader;
33 } // namespace interfaces
34 namespace kernel {
35 struct Context;
36 }
37 namespace util {
38 class SignalInterrupt;
39 }
40 
41 namespace node {
42 class KernelNotifications;
43 class Warnings;
44 
55 struct NodeContext {
57  std::unique_ptr<kernel::Context> kernel;
58  std::unique_ptr<ECC_Context> ecc_context;
63  std::unique_ptr<AddrMan> addrman;
64  std::unique_ptr<CConnman> connman;
65  std::unique_ptr<CTxMemPool> mempool;
66  std::unique_ptr<const NetGroupManager> netgroupman;
67  std::unique_ptr<CBlockPolicyEstimator> fee_estimator;
68  std::unique_ptr<PeerManager> peerman;
69  std::unique_ptr<ChainstateManager> chainman;
70  std::unique_ptr<BanMan> banman;
71  ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
72  std::vector<BaseIndex*> indexes; // raw pointers because memory is not managed by this struct
73  std::unique_ptr<interfaces::Chain> chain;
75  std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
78  std::unique_ptr<interfaces::Mining> mining;
80  std::unique_ptr<CScheduler> scheduler;
81  std::function<void()> rpc_interruption_point = [] {};
83  std::unique_ptr<KernelNotifications> notifications;
85  std::unique_ptr<ValidationSignals> validation_signals;
86  std::atomic<int> exit_status{EXIT_SUCCESS};
88  std::unique_ptr<node::Warnings> warnings;
89 
95 };
96 } // namespace node
97 
98 #endif // BITCOIN_NODE_CONTEXT_H
return EXIT_SUCCESS
Stochastic address manager.
Definition: addrman.h:88
Definition: banman.h:59
Base class for indices of blockchain data.
Definition: base.h:41
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
Definition: fees.h:149
Definition: net.h:1033
Simple class for background tasks that should be run periodically or once "after a while".
Definition: scheduler.h:40
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:304
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:871
RAII class initializing and deinitializing global state for elliptic curve support.
Definition: key.h:249
Netgroup manager.
Definition: netgroup.h:16
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:31
Wallet chain client that in addition to having chain client methods for starting up,...
Definition: wallet.h:328
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
Definition: messages.h:20
NodeContext struct containing references to chain state and connection state.
Definition: context.h:55
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
Definition: context.h:85
std::unique_ptr< CConnman > connman
Definition: context.h:64
std::unique_ptr< kernel::Context > kernel
libbitcoin_kernel context
Definition: context.h:57
std::vector< BaseIndex * > indexes
Definition: context.h:72
std::vector< std::unique_ptr< interfaces::ChainClient > > chain_clients
List of all chain clients (wallet processes or other client) connected to node.
Definition: context.h:75
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:65
std::unique_ptr< BanMan > banman
Definition: context.h:70
std::unique_ptr< interfaces::Mining > mining
Reference to chain client that should used to load or create wallets opened by the gui.
Definition: context.h:78
std::unique_ptr< AddrMan > addrman
Definition: context.h:63
std::function< void()> rpc_interruption_point
Definition: context.h:81
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:69
std::unique_ptr< node::Warnings > warnings
Manages all the node warnings.
Definition: context.h:88
NodeContext()
Declare default constructor and destructor that are not inline, so code instantiating the NodeContext...
std::unique_ptr< KernelNotifications > notifications
Issues blocking calls about sync status, errors and warnings.
Definition: context.h:83
std::unique_ptr< CScheduler > scheduler
Definition: context.h:80
std::unique_ptr< CBlockPolicyEstimator > fee_estimator
Definition: context.h:67
std::unique_ptr< PeerManager > peerman
Definition: context.h:68
ArgsManager * args
Definition: context.h:71
std::atomic< int > exit_status
Definition: context.h:86
std::unique_ptr< const NetGroupManager > netgroupman
Definition: context.h:66
interfaces::WalletLoader * wallet_loader
Definition: context.h:79
std::unique_ptr< ECC_Context > ecc_context
Definition: context.h:58
util::SignalInterrupt * shutdown
Interrupt object used to track whether node shutdown was requested.
Definition: context.h:62
std::unique_ptr< interfaces::Chain > chain
Definition: context.h:73