Bitcoin Core  26.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 <kernel/context.h>
9 
10 #include <atomic>
11 #include <cassert>
12 #include <cstdlib>
13 #include <functional>
14 #include <memory>
15 #include <vector>
16 
17 class ArgsManager;
18 class AddrMan;
19 class BanMan;
20 class BaseIndex;
22 class CConnman;
23 class CScheduler;
24 class CTxMemPool;
25 class ChainstateManager;
26 class NetGroupManager;
27 class PeerManager;
28 namespace interfaces {
29 class Chain;
30 class ChainClient;
31 class Init;
32 class WalletLoader;
33 } // namespace interfaces
34 
35 namespace node {
36 class KernelNotifications;
37 
48 struct NodeContext {
50  std::unique_ptr<kernel::Context> kernel;
53  std::unique_ptr<AddrMan> addrman;
54  std::unique_ptr<CConnman> connman;
55  std::unique_ptr<CTxMemPool> mempool;
56  std::unique_ptr<const NetGroupManager> netgroupman;
57  std::unique_ptr<CBlockPolicyEstimator> fee_estimator;
58  std::unique_ptr<PeerManager> peerman;
59  std::unique_ptr<ChainstateManager> chainman;
60  std::unique_ptr<BanMan> banman;
61  ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
62  std::vector<BaseIndex*> indexes; // raw pointers because memory is not managed by this struct
63  std::unique_ptr<interfaces::Chain> chain;
65  std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
69  std::unique_ptr<CScheduler> scheduler;
70  std::function<void()> rpc_interruption_point = [] {};
71  std::unique_ptr<KernelNotifications> notifications;
72  std::atomic<int> exit_status{EXIT_SUCCESS};
73 
77  NodeContext();
78  ~NodeContext();
79 };
80 } // namespace node
81 
82 #endif // BITCOIN_NODE_CONTEXT_H
std::unique_ptr< interfaces::Chain > chain
Definition: context.h:63
return EXIT_SUCCESS
Definition: banman.h:58
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:827
std::atomic< int > exit_status
Definition: context.h:72
std::function< void()> rpc_interruption_point
Definition: context.h:70
std::unique_ptr< const NetGroupManager > netgroupman
Definition: context.h:56
std::unique_ptr< CScheduler > scheduler
Definition: context.h:69
std::unique_ptr< AddrMan > addrman
Definition: context.h:53
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:87
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:55
std::unique_ptr< BanMan > banman
Definition: context.h:60
NodeContext struct containing references to chain state and connection state.
Definition: context.h:48
std::unique_ptr< CBlockPolicyEstimator > fee_estimator
Definition: context.h:57
Base class for indices of blockchain data.
Definition: base.h:40
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
Definition: fees.h:146
ArgsManager * args
Definition: context.h:61
Definition: net.h:1041
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:322
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:65
Definition: init.h:25
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:301
std::vector< BaseIndex * > indexes
Definition: context.h:62
std::unique_ptr< KernelNotifications > notifications
Definition: context.h:71
std::unique_ptr< kernel::Context > kernel
libbitcoin_kernel context
Definition: context.h:50
std::unique_ptr< CConnman > connman
Definition: context.h:54
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:29
Simple class for background tasks that should be run periodically or once "after a while"...
Definition: scheduler.h:38
interfaces::WalletLoader * wallet_loader
Reference to chain client that should used to load or create wallets opened by the gui...
Definition: context.h:68
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:59
std::unique_ptr< PeerManager > peerman
Definition: context.h:58