22
22
std::string RemovalReasonToString (const MemPoolRemovalReason& r) noexcept ;
23
23
24
24
/* *
25
- * MainSignalsImpl manages a list of shared_ptr<CValidationInterface> callbacks.
25
+ * ValidationSignalsImpl manages a list of shared_ptr<CValidationInterface> callbacks.
26
26
*
27
27
* A std::unordered_map is used to track what callbacks are currently
28
28
* registered, and a std::list is used to store the callbacks that are
29
29
* currently registered as well as any callbacks that are just unregistered
30
30
* and about to be deleted when they are done executing.
31
31
*/
32
- class MainSignalsImpl
32
+ class ValidationSignalsImpl
33
33
{
34
34
private:
35
35
Mutex m_mutex;
@@ -47,7 +47,7 @@ class MainSignalsImpl
47
47
// our own queue here :(
48
48
SerialTaskRunner m_task_runner;
49
49
50
- explicit MainSignalsImpl (CScheduler& scheduler LIFETIMEBOUND) : m_task_runner(scheduler) {}
50
+ explicit ValidationSignalsImpl (CScheduler& scheduler LIFETIMEBOUND) : m_task_runner(scheduler) {}
51
51
52
52
void Register (std::shared_ptr<CValidationInterface> callbacks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
53
53
{
@@ -94,56 +94,56 @@ class MainSignalsImpl
94
94
}
95
95
};
96
96
97
- CMainSignals::CMainSignals (CScheduler& scheduler)
98
- : m_internals{std::make_unique<MainSignalsImpl >(scheduler)} {}
97
+ ValidationSignals::ValidationSignals (CScheduler& scheduler)
98
+ : m_internals{std::make_unique<ValidationSignalsImpl >(scheduler)} {}
99
99
100
- CMainSignals ::~CMainSignals () {}
100
+ ValidationSignals ::~ValidationSignals () {}
101
101
102
- void CMainSignals ::FlushBackgroundCallbacks ()
102
+ void ValidationSignals ::FlushBackgroundCallbacks ()
103
103
{
104
104
m_internals->m_task_runner .flush ();
105
105
}
106
106
107
- size_t CMainSignals ::CallbacksPending ()
107
+ size_t ValidationSignals ::CallbacksPending ()
108
108
{
109
109
return m_internals->m_task_runner .size ();
110
110
}
111
111
112
- void CMainSignals ::RegisterSharedValidationInterface (std::shared_ptr<CValidationInterface> callbacks)
112
+ void ValidationSignals ::RegisterSharedValidationInterface (std::shared_ptr<CValidationInterface> callbacks)
113
113
{
114
114
// Each connection captures the shared_ptr to ensure that each callback is
115
115
// executed before the subscriber is destroyed. For more details see #18338.
116
116
m_internals->Register (std::move (callbacks));
117
117
}
118
118
119
- void CMainSignals ::RegisterValidationInterface (CValidationInterface* callbacks)
119
+ void ValidationSignals ::RegisterValidationInterface (CValidationInterface* callbacks)
120
120
{
121
121
// Create a shared_ptr with a no-op deleter - CValidationInterface lifecycle
122
122
// is managed by the caller.
123
123
RegisterSharedValidationInterface ({callbacks, [](CValidationInterface*){}});
124
124
}
125
125
126
- void CMainSignals ::UnregisterSharedValidationInterface (std::shared_ptr<CValidationInterface> callbacks)
126
+ void ValidationSignals ::UnregisterSharedValidationInterface (std::shared_ptr<CValidationInterface> callbacks)
127
127
{
128
128
UnregisterValidationInterface (callbacks.get ());
129
129
}
130
130
131
- void CMainSignals ::UnregisterValidationInterface (CValidationInterface* callbacks)
131
+ void ValidationSignals ::UnregisterValidationInterface (CValidationInterface* callbacks)
132
132
{
133
133
m_internals->Unregister (callbacks);
134
134
}
135
135
136
- void CMainSignals ::UnregisterAllValidationInterfaces ()
136
+ void ValidationSignals ::UnregisterAllValidationInterfaces ()
137
137
{
138
138
m_internals->Clear ();
139
139
}
140
140
141
- void CMainSignals ::CallFunctionInValidationInterfaceQueue (std::function<void ()> func)
141
+ void ValidationSignals ::CallFunctionInValidationInterfaceQueue (std::function<void ()> func)
142
142
{
143
143
m_internals->m_task_runner .insert (std::move (func));
144
144
}
145
145
146
- void CMainSignals ::SyncWithValidationInterfaceQueue ()
146
+ void ValidationSignals ::SyncWithValidationInterfaceQueue ()
147
147
{
148
148
AssertLockNotHeld (cs_main);
149
149
// Block until the validation queue drains
@@ -171,7 +171,7 @@ void CMainSignals::SyncWithValidationInterfaceQueue()
171
171
#define LOG_EVENT (fmt, ...) \
172
172
LogPrint (BCLog::VALIDATION, fmt " \n " , __VA_ARGS__)
173
173
174
- void CMainSignals ::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload ) {
174
+ void ValidationSignals ::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload ) {
175
175
// Dependencies exist that require UpdatedBlockTip events to be delivered in the order in which
176
176
// the chain actually updates. One way to ensure this is for the caller to invoke this signal
177
177
// in the same critical section where the chain is updated
@@ -185,7 +185,7 @@ void CMainSignals::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInd
185
185
fInitialDownload );
186
186
}
187
187
188
- void CMainSignals ::TransactionAddedToMempool (const NewMempoolTransactionInfo& tx, uint64_t mempool_sequence)
188
+ void ValidationSignals ::TransactionAddedToMempool (const NewMempoolTransactionInfo& tx, uint64_t mempool_sequence)
189
189
{
190
190
auto event = [tx, mempool_sequence, this ] {
191
191
m_internals->Iterate ([&](CValidationInterface& callbacks) { callbacks.TransactionAddedToMempool (tx, mempool_sequence); });
@@ -195,7 +195,7 @@ void CMainSignals::TransactionAddedToMempool(const NewMempoolTransactionInfo& tx
195
195
tx.info .m_tx ->GetWitnessHash ().ToString ());
196
196
}
197
197
198
- void CMainSignals ::TransactionRemovedFromMempool (const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) {
198
+ void ValidationSignals ::TransactionRemovedFromMempool (const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) {
199
199
auto event = [tx, reason, mempool_sequence, this ] {
200
200
m_internals->Iterate ([&](CValidationInterface& callbacks) { callbacks.TransactionRemovedFromMempool (tx, reason, mempool_sequence); });
201
201
};
@@ -205,7 +205,7 @@ void CMainSignals::TransactionRemovedFromMempool(const CTransactionRef& tx, MemP
205
205
RemovalReasonToString (reason));
206
206
}
207
207
208
- void CMainSignals ::BlockConnected (ChainstateRole role, const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex) {
208
+ void ValidationSignals ::BlockConnected (ChainstateRole role, const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex) {
209
209
auto event = [role, pblock, pindex, this ] {
210
210
m_internals->Iterate ([&](CValidationInterface& callbacks) { callbacks.BlockConnected (role, pblock, pindex); });
211
211
};
@@ -214,7 +214,7 @@ void CMainSignals::BlockConnected(ChainstateRole role, const std::shared_ptr<con
214
214
pindex->nHeight );
215
215
}
216
216
217
- void CMainSignals ::MempoolTransactionsRemovedForBlock (const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block, unsigned int nBlockHeight)
217
+ void ValidationSignals ::MempoolTransactionsRemovedForBlock (const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block, unsigned int nBlockHeight)
218
218
{
219
219
auto event = [txs_removed_for_block, nBlockHeight, this ] {
220
220
m_internals->Iterate ([&](CValidationInterface& callbacks) { callbacks.MempoolTransactionsRemovedForBlock (txs_removed_for_block, nBlockHeight); });
@@ -224,7 +224,7 @@ void CMainSignals::MempoolTransactionsRemovedForBlock(const std::vector<RemovedM
224
224
txs_removed_for_block.size ());
225
225
}
226
226
227
- void CMainSignals ::BlockDisconnected (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
227
+ void ValidationSignals ::BlockDisconnected (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
228
228
{
229
229
auto event = [pblock, pindex, this ] {
230
230
m_internals->Iterate ([&](CValidationInterface& callbacks) { callbacks.BlockDisconnected (pblock, pindex); });
@@ -234,21 +234,21 @@ void CMainSignals::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock
234
234
pindex->nHeight );
235
235
}
236
236
237
- void CMainSignals ::ChainStateFlushed (ChainstateRole role, const CBlockLocator &locator) {
237
+ void ValidationSignals ::ChainStateFlushed (ChainstateRole role, const CBlockLocator &locator) {
238
238
auto event = [role, locator, this ] {
239
239
m_internals->Iterate ([&](CValidationInterface& callbacks) { callbacks.ChainStateFlushed (role, locator); });
240
240
};
241
241
ENQUEUE_AND_LOG_EVENT (event, " %s: block hash=%s" , __func__,
242
242
locator.IsNull () ? " null" : locator.vHave .front ().ToString ());
243
243
}
244
244
245
- void CMainSignals ::BlockChecked (const CBlock& block, const BlockValidationState& state) {
245
+ void ValidationSignals ::BlockChecked (const CBlock& block, const BlockValidationState& state) {
246
246
LOG_EVENT (" %s: block hash=%s state=%s" , __func__,
247
247
block.GetHash ().ToString (), state.ToString ());
248
248
m_internals->Iterate ([&](CValidationInterface& callbacks) { callbacks.BlockChecked (block, state); });
249
249
}
250
250
251
- void CMainSignals ::NewPoWValidBlock (const CBlockIndex *pindex, const std::shared_ptr<const CBlock> &block) {
251
+ void ValidationSignals ::NewPoWValidBlock (const CBlockIndex *pindex, const std::shared_ptr<const CBlock> &block) {
252
252
LOG_EVENT (" %s: block hash=%s" , __func__, block->GetHash ().ToString ());
253
253
m_internals->Iterate ([&](CValidationInterface& callbacks) { callbacks.NewPoWValidBlock (pindex, block); });
254
254
}
0 commit comments