diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index 4ebc9ccb4c34..43c9345e172a 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -11,13 +11,12 @@ #include #include #include -#include #include CDSNotificationInterface::CDSNotificationInterface(CConnman& connman, CDSTXManager& dstxman, CMasternodeSync& mn_sync, CGovernanceManager& govman, const ChainstateManager& chainman, - const std::unique_ptr& dmnman) : + CDeterministicMNManager& dmnman) : m_connman{connman}, m_dstxman{dstxman}, m_mn_sync{mn_sync}, @@ -50,7 +49,7 @@ void CDSNotificationInterface::SynchronousUpdatedBlockTip(const CBlockIndex *pin if (pindexNew == pindexFork) // blocks were disconnected without any new ones return; - Assert(m_dmnman)->UpdatedBlockTip(pindexNew); + m_dmnman.UpdatedBlockTip(pindexNew); } void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) @@ -103,5 +102,3 @@ void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex, m_dstxman.NotifyChainLock(pindex); } } - -std::unique_ptr g_ds_notification_interface; diff --git a/src/dsnotificationinterface.h b/src/dsnotificationinterface.h index 889438397fc5..bb4a42792cde 100644 --- a/src/dsnotificationinterface.h +++ b/src/dsnotificationinterface.h @@ -22,7 +22,7 @@ class CDSNotificationInterface : public CValidationInterface CDSNotificationInterface& operator=(const CDSNotificationInterface&) = delete; explicit CDSNotificationInterface(CConnman& connman, CDSTXManager& dstxman, CMasternodeSync& mn_sync, CGovernanceManager& govman, const ChainstateManager& chainman, - const std::unique_ptr& dmnman); + CDeterministicMNManager& dmnman); virtual ~CDSNotificationInterface(); // CValidationInterface @@ -45,9 +45,7 @@ class CDSNotificationInterface : public CValidationInterface CMasternodeSync& m_mn_sync; CGovernanceManager& m_govman; const ChainstateManager& m_chainman; - const std::unique_ptr& m_dmnman; + CDeterministicMNManager& m_dmnman; }; -extern std::unique_ptr g_ds_notification_interface; - #endif // BITCOIN_DSNOTIFICATIONINTERFACE_H diff --git a/src/init.cpp b/src/init.cpp index 84b5f79a221f..2cb11a7687a0 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -376,9 +376,9 @@ void PrepareShutdown(NodeContext& node) UnregisterValidationInterface(node.cj_walletman.get()); } - if (g_ds_notification_interface) { - UnregisterValidationInterface(g_ds_notification_interface.get()); - g_ds_notification_interface.reset(); + if (node.ds_notification_interface) { + UnregisterValidationInterface(node.ds_notification_interface.get()); + node.ds_notification_interface.reset(); } // After all scheduled tasks have been flushed, destroy pointers @@ -2101,10 +2101,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) node.dmnman, node.cj_walletman, node.llmq_ctx, ignores_incoming_txs); RegisterValidationInterface(node.peerman.get()); - g_ds_notification_interface = std::make_unique( - *node.connman, *node.dstxman, *node.mn_sync, *node.govman, chainman, node.dmnman // todo: replace unique_ptr for dmnman to reference + node.ds_notification_interface = std::make_unique( + *node.connman, *node.dstxman, *node.mn_sync, *node.govman, chainman, *node.dmnman ); - RegisterValidationInterface(g_ds_notification_interface.get()); + RegisterValidationInterface(node.ds_notification_interface.get()); // ********************************************************* Step 7d: Setup other Dash services @@ -2375,7 +2375,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // for quorum connection setup and skShare derivation. // Only kick CDSNotificationInterface here (cached block // height for DS/MN payments/budgets). - g_ds_notification_interface->InitializeCurrentBlockTip(tip, ibd); + node.ds_notification_interface->InitializeCurrentBlockTip(tip, ibd); } else { // Non-masternode nodes (including observer-only): broadcast // to all subscribers now; no proTxHash dependency. diff --git a/src/node/context.cpp b/src/node/context.cpp index 2bd9531e97fd..bb5755d35a5b 100644 --- a/src/node/context.cpp +++ b/src/node/context.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/src/node/context.h b/src/node/context.h index 5d1f1f00d02f..5c9a9398f22c 100644 --- a/src/node/context.h +++ b/src/node/context.h @@ -21,6 +21,7 @@ class AddrMan; class CBlockPolicyEstimator; class CConnman; class CDeterministicMNManager; +class CDSNotificationInterface; class CDSTXManager; class CChainstateHelper; class ChainstateManager; @@ -106,6 +107,7 @@ struct NodeContext { std::unique_ptr chainlocks; std::unique_ptr clhandler; //! Dash contexts + std::unique_ptr ds_notification_interface; std::unique_ptr active_ctx; std::unique_ptr llmq_ctx; std::unique_ptr observer_ctx;