Bitcoin Core  29.1.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 <thread>
13 #include <vector>
14 
15 class ArgsManager;
16 class AddrMan;
17 class BanMan;
18 class BaseIndex;
20 class CConnman;
21 class ValidationSignals;
22 class CScheduler;
23 class CTxMemPool;
24 class ChainstateManager;
25 class ECC_Context;
26 class NetGroupManager;
27 class PeerManager;
28 namespace interfaces {
29 class Chain;
30 class ChainClient;
31 class Mining;
32 class Init;
33 class WalletLoader;
34 } // namespace interfaces
35 namespace kernel {
36 struct Context;
37 }
38 namespace util {
39 class SignalInterrupt;
40 }
41 
42 namespace node {
43 class KernelNotifications;
44 class Warnings;
45 
56 struct NodeContext {
58  std::unique_ptr<kernel::Context> kernel;
59  std::unique_ptr<ECC_Context> ecc_context;
63  std::function<bool()> shutdown_request;
66  std::unique_ptr<AddrMan> addrman;
67  std::unique_ptr<CConnman> connman;
68  std::unique_ptr<CTxMemPool> mempool;
69  std::unique_ptr<const NetGroupManager> netgroupman;
70  std::unique_ptr<CBlockPolicyEstimator> fee_estimator;
71  std::unique_ptr<PeerManager> peerman;
72  std::unique_ptr<ChainstateManager> chainman;
73  std::unique_ptr<BanMan> banman;
74  ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
75  std::vector<BaseIndex*> indexes; // raw pointers because memory is not managed by this struct
76  std::unique_ptr<interfaces::Chain> chain;
78  std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
81  std::unique_ptr<interfaces::Mining> mining;
83  std::unique_ptr<CScheduler> scheduler;
84  std::function<void()> rpc_interruption_point = [] {};
86  std::unique_ptr<KernelNotifications> notifications;
88  std::unique_ptr<ValidationSignals> validation_signals;
89  std::atomic<int> exit_status{EXIT_SUCCESS};
91  std::unique_ptr<node::Warnings> warnings;
93 
97  NodeContext();
98  ~NodeContext();
99 };
100 } // namespace node
101 
102 #endif // BITCOIN_NODE_CONTEXT_H
std::unique_ptr< interfaces::Chain > chain
Definition: context.h:76
return EXIT_SUCCESS
std::unique_ptr< node::Warnings > warnings
Manages all the node warnings.
Definition: context.h:91
Definition: banman.h:58
RAII class initializing and deinitializing global state for elliptic curve support.
Definition: key.h:321
util::SignalInterrupt * shutdown_signal
Interrupt object used to track whether node shutdown was requested.
Definition: context.h:65
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:865
std::atomic< int > exit_status
Definition: context.h:89
std::function< void()> rpc_interruption_point
Definition: context.h:84
std::unique_ptr< const NetGroupManager > netgroupman
Definition: context.h:69
std::unique_ptr< CScheduler > scheduler
Definition: context.h:83
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
Definition: context.h:88
std::unique_ptr< AddrMan > addrman
Definition: context.h:66
NodeContext()
Declare default constructor and destructor that are not inline, so code instantiating the NodeContext...
Netgroup manager.
Definition: netgroup.h:16
Stochastic address manager.
Definition: addrman.h:88
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:68
std::unique_ptr< BanMan > banman
Definition: context.h:73
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:81
NodeContext struct containing references to chain state and connection state.
Definition: context.h:56
std::unique_ptr< CBlockPolicyEstimator > fee_estimator
Definition: context.h:70
Base class for indices of blockchain data.
Definition: base.h:42
std::unique_ptr< ECC_Context > ecc_context
Definition: context.h:59
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
Definition: fees.h:148
ArgsManager * args
Definition: context.h:74
Definition: net.h:1051
Wallet chain client that in addition to having chain client methods for starting up, shutting down, and registering RPCs, also has additional methods (called by the GUI) to load and create wallets.
Definition: wallet.h:327
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:78
Definition: messages.h:20
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
std::thread background_init_thread
Definition: context.h:92
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:303
std::vector< BaseIndex * > indexes
Definition: context.h:75
std::unique_ptr< KernelNotifications > notifications
Issues blocking calls about sync status, errors and warnings.
Definition: context.h:86
std::unique_ptr< kernel::Context > kernel
libbitcoin_kernel context
Definition: context.h:58
std::unique_ptr< CConnman > connman
Definition: context.h:67
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:30
Simple class for background tasks that should be run periodically or once "after a while"...
Definition: scheduler.h:39
interfaces::WalletLoader * wallet_loader
Definition: context.h:82
std::function< bool()> shutdown_request
Function to request a shutdown.
Definition: context.h:63
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:72
std::unique_ptr< PeerManager > peerman
Definition: context.h:71