@@ -291,7 +291,7 @@ void Shutdown(NodeContext& node)
291291
292292 // Because these depend on each-other, we make sure that neither can be
293293 // 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 ());
295295 if (node.connman ) node.connman ->Stop ();
296296
297297 StopTorControl ();
@@ -317,7 +317,9 @@ void Shutdown(NodeContext& node)
317317 // fee estimator from validation interface.
318318 if (node.fee_estimator ) {
319319 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+ }
321323 }
322324
323325 // FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
@@ -332,7 +334,7 @@ void Shutdown(NodeContext& node)
332334
333335 // After there are no more peers/RPC left to give us new data which may generate
334336 // CValidationInterface callbacks, flush them...
335- GetMainSignals (). FlushBackgroundCallbacks ();
337+ if (node. validation_signals ) node. validation_signals -> FlushBackgroundCallbacks ();
336338
337339 // Stop and delete all indexes only after flushing background callbacks.
338340 if (g_txindex) {
@@ -367,17 +369,20 @@ void Shutdown(NodeContext& node)
367369
368370#if ENABLE_ZMQ
369371 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 ());
371373 g_zmq_notification_interface.reset ();
372374 }
373375#endif
374376
375377 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+ }
378382 node.mempool .reset ();
379383 node.fee_estimator .reset ();
380384 node.chainman .reset ();
385+ node.validation_signals .reset ();
381386 node.scheduler .reset ();
382387 node.kernel .reset ();
383388
@@ -1158,7 +1163,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
11581163 }
11591164 }, std::chrono::minutes{5 });
11601165
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 );
11621170
11631171 // Create client interfaces for wallets that are supposed to be loaded
11641172 // according to -wallet and -disablewallet options. This only constructs
@@ -1264,7 +1272,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
12641272 // Flush estimates to disk periodically
12651273 CBlockPolicyEstimator* fee_estimator = node.fee_estimator .get ();
12661274 node.scheduler ->scheduleEvery ([fee_estimator] { fee_estimator->FlushFeeEstimates (); }, FEE_FLUSH_INTERVAL);
1267- RegisterValidationInterface (fee_estimator);
1275+ validation_signals. RegisterValidationInterface (fee_estimator);
12681276 }
12691277
12701278 // Check port numbers
@@ -1435,7 +1443,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14351443 });
14361444
14371445 if (g_zmq_notification_interface) {
1438- RegisterValidationInterface (g_zmq_notification_interface.get ());
1446+ validation_signals. RegisterValidationInterface (g_zmq_notification_interface.get ());
14391447 }
14401448#endif
14411449
@@ -1449,7 +1457,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14491457 .chainparams = chainparams,
14501458 .datadir = args.GetDataDirNet (),
14511459 .notifications = *node.notifications ,
1452- .signals = &GetMainSignals () ,
1460+ .signals = &validation_signals ,
14531461 };
14541462 Assert (ApplyArgsManOptions (args, chainman_opts)); // no error can happen, already checked in AppInitParameterInteraction
14551463
@@ -1479,7 +1487,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14791487
14801488 CTxMemPool::Options mempool_opts{
14811489 .check_ratio = chainparams.DefaultConsistencyChecks () ? 1 : 0 ,
1482- .signals = &GetMainSignals () ,
1490+ .signals = &validation_signals ,
14831491 };
14841492 auto result{ApplyArgsManOptions (args, chainparams, mempool_opts)};
14851493 if (!result) {
@@ -1507,7 +1515,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15071515
15081516 // Drain the validation interface queue to ensure that the old indexes
15091517 // don't have any pending work.
1510- SyncWithValidationInterfaceQueue ();
1518+ Assert (node. validation_signals )-> SyncWithValidationInterfaceQueue ();
15111519
15121520 for (auto * index : node.indexes ) {
15131521 index->Interrupt ();
@@ -1596,7 +1604,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15961604 node.peerman = PeerManager::make (*node.connman , *node.addrman ,
15971605 node.banman .get (), chainman,
15981606 *node.mempool , peerman_opts);
1599- RegisterValidationInterface (node.peerman .get ());
1607+ validation_signals. RegisterValidationInterface (node.peerman .get ());
16001608
16011609 // ********************************************************* Step 8: start indexers
16021610
0 commit comments