@@ -291,7 +291,7 @@ void Shutdown(NodeContext& node)
291
291
292
292
// Because these depend on each-other, we make sure that neither can be
293
293
// using the other before destroying them.
294
- if (node.peerman ) UnregisterValidationInterface (node.peerman .get ());
294
+ if (node.peerman && node. validation_signals ) node. validation_signals -> UnregisterValidationInterface (node.peerman .get ());
295
295
if (node.connman ) node.connman ->Stop ();
296
296
297
297
StopTorControl ();
@@ -317,7 +317,9 @@ void Shutdown(NodeContext& node)
317
317
// fee estimator from validation interface.
318
318
if (node.fee_estimator ) {
319
319
node.fee_estimator ->Flush ();
320
- UnregisterValidationInterface (node.fee_estimator .get ());
320
+ if (node.validation_signals ) {
321
+ node.validation_signals ->UnregisterValidationInterface (node.fee_estimator .get ());
322
+ }
321
323
}
322
324
323
325
// FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
@@ -332,7 +334,7 @@ void Shutdown(NodeContext& node)
332
334
333
335
// After there are no more peers/RPC left to give us new data which may generate
334
336
// CValidationInterface callbacks, flush them...
335
- GetMainSignals (). FlushBackgroundCallbacks ();
337
+ if (node. validation_signals ) node. validation_signals -> FlushBackgroundCallbacks ();
336
338
337
339
// Stop and delete all indexes only after flushing background callbacks.
338
340
if (g_txindex) {
@@ -367,17 +369,20 @@ void Shutdown(NodeContext& node)
367
369
368
370
#if ENABLE_ZMQ
369
371
if (g_zmq_notification_interface) {
370
- UnregisterValidationInterface (g_zmq_notification_interface.get ());
372
+ if (node. validation_signals ) node. validation_signals -> UnregisterValidationInterface (g_zmq_notification_interface.get ());
371
373
g_zmq_notification_interface.reset ();
372
374
}
373
375
#endif
374
376
375
377
node.chain_clients .clear ();
376
- UnregisterAllValidationInterfaces ();
377
- GetMainSignals ().UnregisterBackgroundSignalScheduler ();
378
+ if (node.validation_signals ) {
379
+ node.validation_signals ->UnregisterAllValidationInterfaces ();
380
+ node.validation_signals ->UnregisterBackgroundSignalScheduler ();
381
+ }
378
382
node.mempool .reset ();
379
383
node.fee_estimator .reset ();
380
384
node.chainman .reset ();
385
+ node.validation_signals .reset ();
381
386
node.scheduler .reset ();
382
387
node.kernel .reset ();
383
388
@@ -1158,7 +1163,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1158
1163
}
1159
1164
}, std::chrono::minutes{5 });
1160
1165
1161
- GetMainSignals ().RegisterBackgroundSignalScheduler (*node.scheduler );
1166
+ assert (!node.validation_signals );
1167
+ node.validation_signals = std::make_unique<CMainSignals>();
1168
+ auto & validation_signals = *node.validation_signals ;
1169
+ validation_signals.RegisterBackgroundSignalScheduler (*node.scheduler );
1162
1170
1163
1171
// Create client interfaces for wallets that are supposed to be loaded
1164
1172
// according to -wallet and -disablewallet options. This only constructs
@@ -1264,7 +1272,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1264
1272
// Flush estimates to disk periodically
1265
1273
CBlockPolicyEstimator* fee_estimator = node.fee_estimator .get ();
1266
1274
node.scheduler ->scheduleEvery ([fee_estimator] { fee_estimator->FlushFeeEstimates (); }, FEE_FLUSH_INTERVAL);
1267
- RegisterValidationInterface (fee_estimator);
1275
+ validation_signals. RegisterValidationInterface (fee_estimator);
1268
1276
}
1269
1277
1270
1278
// Check port numbers
@@ -1435,7 +1443,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1435
1443
});
1436
1444
1437
1445
if (g_zmq_notification_interface) {
1438
- RegisterValidationInterface (g_zmq_notification_interface.get ());
1446
+ validation_signals. RegisterValidationInterface (g_zmq_notification_interface.get ());
1439
1447
}
1440
1448
#endif
1441
1449
@@ -1449,7 +1457,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1449
1457
.chainparams = chainparams,
1450
1458
.datadir = args.GetDataDirNet (),
1451
1459
.notifications = *node.notifications ,
1452
- .signals = &GetMainSignals () ,
1460
+ .signals = &validation_signals ,
1453
1461
};
1454
1462
Assert (ApplyArgsManOptions (args, chainman_opts)); // no error can happen, already checked in AppInitParameterInteraction
1455
1463
@@ -1479,7 +1487,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1479
1487
1480
1488
CTxMemPool::Options mempool_opts{
1481
1489
.check_ratio = chainparams.DefaultConsistencyChecks () ? 1 : 0 ,
1482
- .signals = &GetMainSignals () ,
1490
+ .signals = &validation_signals ,
1483
1491
};
1484
1492
auto result{ApplyArgsManOptions (args, chainparams, mempool_opts)};
1485
1493
if (!result) {
@@ -1507,7 +1515,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1507
1515
1508
1516
// Drain the validation interface queue to ensure that the old indexes
1509
1517
// don't have any pending work.
1510
- SyncWithValidationInterfaceQueue ();
1518
+ Assert (node. validation_signals )-> SyncWithValidationInterfaceQueue ();
1511
1519
1512
1520
for (auto * index : node.indexes ) {
1513
1521
index ->Interrupt ();
@@ -1596,7 +1604,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1596
1604
node.peerman = PeerManager::make (*node.connman , *node.addrman ,
1597
1605
node.banman .get (), chainman,
1598
1606
*node.mempool , peerman_opts);
1599
- RegisterValidationInterface (node.peerman .get ());
1607
+ validation_signals. RegisterValidationInterface (node.peerman .get ());
1600
1608
1601
1609
// ********************************************************* Step 8: start indexers
1602
1610
0 commit comments