Bitcoin Core 32.99.0
P2P Digital Currency
context.h
Go to the documentation of this file.
1// Copyright (c) 2019-present 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
15class ArgsManager;
16class AddrMan;
17class BanMan;
18class BaseIndex;
19class CConnman;
22class CScheduler;
23class CTxMemPool;
25class ECC_Context;
26class NetGroupManager;
27class PeerManager;
28class TorController;
29namespace interfaces {
30class Chain;
31class ChainClient;
32class Init;
33class WalletLoader;
34} // namespace interfaces
35namespace kernel {
36struct Context;
37}
38namespace util {
39class SignalInterrupt;
40}
41
42namespace node {
43class BlockTemplateManager;
44class KernelNotifications;
45class Warnings;
46
59 std::unique_ptr<kernel::Context> kernel;
60 std::unique_ptr<ECC_Context> ecc_context;
64 std::function<bool()> shutdown_request;
67 std::unique_ptr<AddrMan> addrman;
68 std::unique_ptr<CConnman> connman;
69 std::unique_ptr<CTxMemPool> mempool;
70 std::unique_ptr<const NetGroupManager> netgroupman;
71 std::unique_ptr<FeeRateEstimatorManager> fee_estimator_man;
72 std::unique_ptr<PeerManager> peerman;
73 std::unique_ptr<TorController> tor_controller;
74 std::unique_ptr<ChainstateManager> chainman;
75 std::unique_ptr<BanMan> banman;
76 ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
77 std::vector<BaseIndex*> indexes; // raw pointers because memory is not managed by this struct
78 std::unique_ptr<interfaces::Chain> chain;
80 std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
82 std::unique_ptr<CScheduler> scheduler;
83 std::function<void()> rpc_interruption_point = [] {};
85 std::unique_ptr<KernelNotifications> notifications;
87 std::unique_ptr<BlockTemplateManager> block_template_manager;
89 std::unique_ptr<ValidationSignals> validation_signals;
90 std::atomic<int> exit_status{EXIT_SUCCESS};
92 std::unique_ptr<node::Warnings> warnings;
94
100};
101} // namespace node
102
103#endif // BITCOIN_NODE_CONTEXT_H
return EXIT_SUCCESS
Stochastic address manager.
Definition: addrman.h:110
Definition: banman.h:64
Base class for indices of blockchain data.
Definition: base.h:55
Definition: net.h:1085
Simple class for background tasks that should be run periodically or once "after a while".
Definition: scheduler.h:39
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:187
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainsta...
Definition: validation.h:950
RAII class initializing and deinitializing global state for elliptic curve support.
Definition: key.h:364
Manages fee rate estimators.
Definition: estimator_man.h:31
Definition: init.h:13
Netgroup manager.
Definition: netgroup.h:17
Controller that connects to Tor control socket, authenticate, then create and maintain an ephemeral o...
Definition: torcontrol.h:123
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:39
Wallet chain client that in addition to having chain client methods for starting up,...
Definition: wallet.h:325
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
std::thread thread
Thread variable should be after other struct members so the thread does not start until the other mem...
Definition: basic.cpp:11
Definition: messages.h:21
NodeContext struct containing references to chain state and connection state.
Definition: context.h:57
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
Definition: context.h:89
std::unique_ptr< TorController > tor_controller
Definition: context.h:73
std::unique_ptr< CConnman > connman
Definition: context.h:68
std::unique_ptr< kernel::Context > kernel
libbitcoin_kernel context
Definition: context.h:59
std::vector< BaseIndex * > indexes
Definition: context.h:77
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:80
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:69
std::unique_ptr< BanMan > banman
Definition: context.h:75
std::unique_ptr< BlockTemplateManager > block_template_manager
Must be destroyed before its dependencies (holds references to them).
Definition: context.h:87
std::unique_ptr< AddrMan > addrman
Definition: context.h:67
std::function< void()> rpc_interruption_point
Definition: context.h:83
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:74
std::unique_ptr< node::Warnings > warnings
Manages all the node warnings.
Definition: context.h:92
std::unique_ptr< FeeRateEstimatorManager > fee_estimator_man
Definition: context.h:71
NodeContext()
Declare default constructor and destructor that are not inline, so code instantiating the NodeContext...
std::function< bool()> shutdown_request
Function to request a shutdown.
Definition: context.h:64
std::unique_ptr< KernelNotifications > notifications
Issues blocking calls about sync status, errors and warnings.
Definition: context.h:85
std::unique_ptr< CScheduler > scheduler
Definition: context.h:82
util::SignalInterrupt * shutdown_signal
Interrupt object used to track whether node shutdown was requested.
Definition: context.h:66
std::unique_ptr< PeerManager > peerman
Definition: context.h:72
ArgsManager * args
Definition: context.h:76
std::atomic< int > exit_status
Definition: context.h:90
std::unique_ptr< const NetGroupManager > netgroupman
Definition: context.h:70
interfaces::WalletLoader * wallet_loader
Definition: context.h:81
std::thread background_init_thread
Definition: context.h:93
std::unique_ptr< ECC_Context > ecc_context
Definition: context.h:60
std::unique_ptr< interfaces::Chain > chain
Definition: context.h:78