Bitcoin Core  0.20.99
P2P Digital Currency
context.h
Go to the documentation of this file.
1 // Copyright (c) 2019-2020 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 <cassert>
9 #include <memory>
10 #include <vector>
11 
12 class ArgsManager;
13 class BanMan;
14 class CConnman;
15 class CScheduler;
16 class CTxMemPool;
17 class ChainstateManager;
19 namespace interfaces {
20 class Chain;
21 class ChainClient;
22 } // namespace interfaces
23 
34 struct NodeContext {
35  std::unique_ptr<CConnman> connman;
36  CTxMemPool* mempool{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
37  std::unique_ptr<PeerLogicValidation> peer_logic;
38  ChainstateManager* chainman{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
39  std::unique_ptr<BanMan> banman;
40  ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
41  std::unique_ptr<interfaces::Chain> chain;
42  std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
43  std::unique_ptr<CScheduler> scheduler;
44 
48  NodeContext();
49  ~NodeContext();
50 };
51 
53 {
54  assert(node.chainman);
55  return *node.chainman;
56 }
57 
58 #endif // BITCOIN_NODE_CONTEXT_H
CTxMemPool mempool
std::vector< std::unique_ptr< interfaces::ChainClient > > chain_clients
Definition: context.h:42
Definition: banman.h:41
std::unique_ptr< BanMan > banman
Definition: context.h:39
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:726
std::unique_ptr< interfaces::Chain > chain
Definition: context.h:41
ChainstateManager & EnsureChainman(const NodeContext &node)
Definition: context.h:52
ChainstateManager * chainman
Definition: context.h:38
NodeContext struct containing references to chain state and connection state.
Definition: context.h:34
std::unique_ptr< CConnman > connman
Definition: context.h:35
Definition: net.h:118
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:443
std::unique_ptr< PeerLogicValidation > peer_logic
Definition: context.h:37
std::unique_ptr< CScheduler > scheduler
Definition: context.h:43