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 <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 ValidationSignals;
24 class CScheduler;
25 class CTxMemPool;
26 class ChainstateManager;
27 class NetGroupManager;
28 class PeerManager;
29 namespace interfaces {
30 class Chain;
31 class ChainClient;
32 class Init;
33 class WalletLoader;
34 } // namespace interfaces
35 
36 namespace node {
37 class KernelNotifications;
38 
49 struct NodeContext {
51  std::unique_ptr<kernel::Context> kernel;
56  std::unique_ptr<AddrMan> addrman;
57  std::unique_ptr<CConnman> connman;
58  std::unique_ptr<CTxMemPool> mempool;
59  std::unique_ptr<const NetGroupManager> netgroupman;
60  std::unique_ptr<CBlockPolicyEstimator> fee_estimator;
61  std::unique_ptr<PeerManager> peerman;
62  std::unique_ptr<ChainstateManager> chainman;
63  std::unique_ptr<BanMan> banman;
64  ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
65  std::vector<BaseIndex*> indexes; // raw pointers because memory is not managed by this struct
66  std::unique_ptr<interfaces::Chain> chain;
68  std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
72  std::unique_ptr<CScheduler> scheduler;
73  std::function<void()> rpc_interruption_point = [] {};
75  std::unique_ptr<KernelNotifications> notifications;
77  std::unique_ptr<ValidationSignals> validation_signals;
78  std::atomic<int> exit_status{EXIT_SUCCESS};
79 
85 };
86 } // namespace node
87 
88 #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:1036
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:302
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:850
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:30
Wallet chain client that in addition to having chain client methods for starting up,...
Definition: wallet.h:323
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
Definition: init.h:25
NodeContext struct containing references to chain state and connection state.
Definition: context.h:49
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
Definition: context.h:77
std::unique_ptr< CConnman > connman
Definition: context.h:57
std::unique_ptr< kernel::Context > kernel
libbitcoin_kernel context
Definition: context.h:51
std::vector< BaseIndex * > indexes
Definition: context.h:65
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:68
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:58
std::unique_ptr< BanMan > banman
Definition: context.h:63
std::unique_ptr< AddrMan > addrman
Definition: context.h:56
std::function< void()> rpc_interruption_point
Definition: context.h:73
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:62
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:75
std::unique_ptr< CScheduler > scheduler
Definition: context.h:72
std::unique_ptr< CBlockPolicyEstimator > fee_estimator
Definition: context.h:60
std::unique_ptr< PeerManager > peerman
Definition: context.h:61
ArgsManager * args
Definition: context.h:64
std::atomic< int > exit_status
Definition: context.h:78
std::unique_ptr< const NetGroupManager > netgroupman
Definition: context.h:59
interfaces::WalletLoader * wallet_loader
Reference to chain client that should used to load or create wallets opened by the gui.
Definition: context.h:71
util::SignalInterrupt * shutdown
Interrupt object used to track whether node shutdown was requested.
Definition: context.h:55
std::unique_ptr< interfaces::Chain > chain
Definition: context.h:66