// Copyright (c) 2014-2025 The Dash Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include #include #include CDSNotificationInterface::CDSNotificationInterface(CConnman& connman, CDSTXManager& dstxman, CMasternodeSync& mn_sync, CGovernanceManager& govman, const ChainstateManager& chainman, CDeterministicMNManager& dmnman) : m_connman{connman}, m_dstxman{dstxman}, m_mn_sync{mn_sync}, m_govman{govman}, m_chainman{chainman}, m_dmnman{dmnman} { } CDSNotificationInterface::~CDSNotificationInterface() = default; void CDSNotificationInterface::InitializeCurrentBlockTip(const CBlockIndex* tip, bool ibd) { SynchronousUpdatedBlockTip(tip, nullptr, ibd); UpdatedBlockTip(tip, nullptr, ibd); } void CDSNotificationInterface::AcceptedBlockHeader(const CBlockIndex *pindexNew) { m_mn_sync.AcceptedBlockHeader(pindexNew); } void CDSNotificationInterface::NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload) { m_mn_sync.NotifyHeaderTip(pindexNew, fInitialDownload); } void CDSNotificationInterface::SynchronousUpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) { if (pindexNew == pindexFork) // blocks were disconnected without any new ones return; m_dmnman.UpdatedBlockTip(pindexNew); } void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) { if (pindexNew == pindexFork) // blocks were disconnected without any new ones return; m_mn_sync.UpdatedBlockTip(WITH_LOCK(::cs_main, return m_chainman.m_best_header), pindexNew, fInitialDownload); if (fInitialDownload) return; if (m_mn_sync.IsBlockchainSynced()) { m_dstxman.UpdatedBlockTip(pindexNew); } if (m_govman.IsValid()) { m_govman.UpdatedBlockTip(pindexNew); } } void CDSNotificationInterface::TransactionAddedToMempool(const CTransactionRef& ptx, int64_t nAcceptTime, uint64_t mempool_sequence) { m_dstxman.TransactionAddedToMempool(ptx); } void CDSNotificationInterface::BlockConnected(const std::shared_ptr& pblock, const CBlockIndex* pindex) { m_dstxman.BlockConnected(pblock, pindex); } void CDSNotificationInterface::BlockDisconnected(const std::shared_ptr& pblock, const CBlockIndex* pindexDisconnected) { m_dstxman.BlockDisconnected(pblock, pindexDisconnected); } void CDSNotificationInterface::NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff) { CMNAuth::NotifyMasternodeListChanged(undo, oldMNList, diff, m_connman); if (m_govman.IsValid()) { m_govman.CheckAndRemove(); } } void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr& clsig) { if (m_mn_sync.IsBlockchainSynced()) { m_dstxman.NotifyChainLock(pindex); } }