Repository navigation
Expand file tree
/
Copy pathcontext.h
More file actions
146 lines (134 loc) · 5.19 KB
/
Copy pathcontext.h
File metadata and controls
146 lines (134 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Copyright (c) 2019-2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_NODE_CONTEXT_H
#define BITCOIN_NODE_CONTEXT_H
#include <kernel/context.h>
#include <sync.h>
#include <atomic>
#include <cassert>
#include <cstdlib>
#include <functional>
#include <memory>
#include <vector>
class AddressIndex;
class ArgsManager;
class AddrMan;
class BanMan;
class BaseIndex;
class CBlockPolicyEstimator;
class CConnman;
class CDSNotificationInterface;
class CDSTXManager;
class ChainstateManager;
class CGovernanceManager;
class CJWalletManager;
class CMasternodeMetaMan;
class CMasternodeSync;
class CNetFulfilledRequestManager;
class CScheduler;
class CSporkManager;
class CTxMemPool;
class GovCollateralIndex;
class NetGroupManager;
class PeerManager;
class SpentIndex;
class TimestampIndex;
struct ActiveContext;
struct LLMQContext;
namespace chainlock {
class Chainlocks;
class ChainlockHandler;
} // namespace chainlock
namespace governance {
class SuperblockManager;
} // namespace governance
namespace interfaces {
class Chain;
class ChainClient;
class Mining;
class Init;
class WalletLoader;
namespace CoinJoin {
class Loader;
} // namspace CoinJoin
} // namespace interfaces
namespace llmq {
class CInstantSendManager;
struct ObserverContext;
} // namespace llmq
namespace node {
class KernelNotifications;
//! NodeContext struct containing references to chain state and connection
//! state.
//!
//! This is used by init, rpc, and test code to pass object references around
//! without needing to declare the same variables and parameters repeatedly, or
//! to use globals. More variables could be added to this struct (particularly
//! references to validation objects) to eliminate use of globals
//! and make code more modular and testable. The struct isn't intended to have
//! any member functions. It should just be a collection of references that can
//! be used without pulling in unwanted dependencies or functionality.
struct NodeContext {
//! libbitcoin_kernel context
std::unique_ptr<kernel::Context> kernel;
//! Init interface for initializing current process and connecting to other processes.
interfaces::Init* init{nullptr};
//! Interrupt object used to track whether node shutdown was requested.
util::SignalInterrupt* shutdown{nullptr};
std::unique_ptr<AddrMan> addrman;
std::unique_ptr<CConnman> connman;
std::unique_ptr<CTxMemPool> mempool;
std::unique_ptr<const NetGroupManager> netgroupman;
std::unique_ptr<CBlockPolicyEstimator> fee_estimator;
std::unique_ptr<PeerManager> peerman;
std::unique_ptr<ChainstateManager> chainman;
std::unique_ptr<BanMan> banman;
ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
std::vector<BaseIndex*> indexes; // raw pointers because memory is not managed by this struct
//! Startup starts the index threads after the block import. A snapshot
//! completion before then rebinds the indexes and leaves starting them to it.
Mutex index_start_mutex;
bool index_threads_started GUARDED_BY(index_start_mutex){false};
std::unique_ptr<interfaces::Chain> chain;
//! List of all chain clients (wallet processes or other client) connected to node.
std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
//! Reference to chain client that should used to load or create wallets
//! opened by the gui.
std::unique_ptr<interfaces::Mining> mining;
interfaces::WalletLoader* wallet_loader{nullptr};
std::unique_ptr<interfaces::CoinJoin::Loader> coinjoin_loader{nullptr};
std::unique_ptr<CScheduler> scheduler;
std::function<void()> rpc_interruption_point = [] {};
std::atomic<int> exit_status{EXIT_SUCCESS};
std::unique_ptr<KernelNotifications> notifications;
//! Dash managers
std::unique_ptr<CJWalletManager> cj_walletman;
std::unique_ptr<CDSTXManager> dstxman;
std::unique_ptr<llmq::CInstantSendManager> isman;
std::unique_ptr<CGovernanceManager> govman;
std::unique_ptr<CMasternodeMetaMan> mn_metaman;
std::unique_ptr<CMasternodeSync> mn_sync;
std::unique_ptr<CNetFulfilledRequestManager> netfulfilledman;
std::unique_ptr<governance::SuperblockManager> sbman;
std::unique_ptr<CSporkManager> sporkman;
std::unique_ptr<chainlock::Chainlocks> chainlocks;
std::unique_ptr<chainlock::ChainlockHandler> clhandler;
//! Dash contexts
std::unique_ptr<CDSNotificationInterface> ds_notification_interface;
std::unique_ptr<ActiveContext> active_ctx;
std::unique_ptr<LLMQContext> llmq_ctx;
std::unique_ptr<llmq::ObserverContext> observer_ctx;
//! Dash indexes
std::unique_ptr<AddressIndex> address_index;
std::unique_ptr<GovCollateralIndex> gov_collateral_index;
std::unique_ptr<SpentIndex> spent_index;
std::unique_ptr<TimestampIndex> timestamp_index;
//! Declare default constructor and destructor that are not inline, so code
//! instantiating the NodeContext struct doesn't need to #include class
//! definitions for all the unique_ptr members.
NodeContext();
~NodeContext();
};
} // namespace node
#endif // BITCOIN_NODE_CONTEXT_H