LCOV - code coverage report
Current view: top level - src - dsnotificationinterface.cpp (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 0 58 0.0 %
Date: 2026-06-25 07:23:51 Functions: 0 16 0.0 %

          Line data    Source code
       1             : // Copyright (c) 2014-2025 The Dash Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : 
       6             : #include <dsnotificationinterface.h>
       7             : 
       8             : #include <coinjoin/coinjoin.h>
       9             : #include <evo/deterministicmns.h>
      10             : #include <evo/mnauth.h>
      11             : #include <governance/governance.h>
      12             : #include <instantsend/instantsend.h>
      13             : #include <masternode/sync.h>
      14             : #include <util/check.h>
      15             : #include <validation.h>
      16             : 
      17             : 
      18           0 : CDSNotificationInterface::CDSNotificationInterface(CConnman& connman, CDSTXManager& dstxman, CMasternodeSync& mn_sync,
      19             :                                                    CGovernanceManager& govman, const ChainstateManager& chainman,
      20             :                                                    const std::unique_ptr<CDeterministicMNManager>& dmnman) :
      21           0 :     m_connman{connman},
      22           0 :     m_dstxman{dstxman},
      23           0 :     m_mn_sync{mn_sync},
      24           0 :     m_govman{govman},
      25           0 :     m_chainman{chainman},
      26           0 :     m_dmnman{dmnman}
      27           0 : {
      28           0 : }
      29             : 
      30           0 : CDSNotificationInterface::~CDSNotificationInterface() = default;
      31             : 
      32           0 : void CDSNotificationInterface::InitializeCurrentBlockTip(const CBlockIndex* tip, bool ibd)
      33             : {
      34           0 :     SynchronousUpdatedBlockTip(tip, nullptr, ibd);
      35           0 :     UpdatedBlockTip(tip, nullptr, ibd);
      36           0 : }
      37             : 
      38           0 : void CDSNotificationInterface::AcceptedBlockHeader(const CBlockIndex *pindexNew)
      39             : {
      40           0 :     m_mn_sync.AcceptedBlockHeader(pindexNew);
      41           0 : }
      42             : 
      43           0 : void CDSNotificationInterface::NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload)
      44             : {
      45           0 :     m_mn_sync.NotifyHeaderTip(pindexNew, fInitialDownload);
      46           0 : }
      47             : 
      48           0 : void CDSNotificationInterface::SynchronousUpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
      49             : {
      50           0 :     if (pindexNew == pindexFork) // blocks were disconnected without any new ones
      51           0 :         return;
      52             : 
      53           0 :     Assert(m_dmnman)->UpdatedBlockTip(pindexNew);
      54           0 : }
      55             : 
      56           0 : void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
      57             : {
      58           0 :     if (pindexNew == pindexFork) // blocks were disconnected without any new ones
      59           0 :         return;
      60             : 
      61           0 :     m_mn_sync.UpdatedBlockTip(WITH_LOCK(::cs_main, return m_chainman.m_best_header), pindexNew, fInitialDownload);
      62             : 
      63           0 :     if (fInitialDownload)
      64           0 :         return;
      65             : 
      66           0 :     if (m_mn_sync.IsBlockchainSynced()) {
      67           0 :         m_dstxman.UpdatedBlockTip(pindexNew);
      68           0 :     }
      69             : 
      70           0 :     if (m_govman.IsValid()) {
      71           0 :         m_govman.UpdatedBlockTip(pindexNew);
      72           0 :     }
      73           0 : }
      74             : 
      75           0 : void CDSNotificationInterface::TransactionAddedToMempool(const CTransactionRef& ptx, int64_t nAcceptTime,
      76             :                                                          uint64_t mempool_sequence)
      77             : {
      78           0 :     m_dstxman.TransactionAddedToMempool(ptx);
      79           0 : }
      80             : 
      81           0 : void CDSNotificationInterface::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
      82             : {
      83           0 :     m_dstxman.BlockConnected(pblock, pindex);
      84           0 : }
      85             : 
      86           0 : void CDSNotificationInterface::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected)
      87             : {
      88           0 :     m_dstxman.BlockDisconnected(pblock, pindexDisconnected);
      89           0 : }
      90             : 
      91           0 : void CDSNotificationInterface::NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff)
      92             : {
      93           0 :     CMNAuth::NotifyMasternodeListChanged(undo, oldMNList, diff, m_connman);
      94           0 :     if (m_govman.IsValid()) {
      95           0 :         m_govman.CheckAndRemove();
      96           0 :     }
      97           0 : }
      98             : 
      99           0 : void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex,
     100             :                                                const std::shared_ptr<const chainlock::ChainLockSig>& clsig)
     101             : {
     102           0 :     if (m_mn_sync.IsBlockchainSynced()) {
     103           0 :         m_dstxman.NotifyChainLock(pindex);
     104           0 :     }
     105           0 : }
     106             : 
     107             : std::unique_ptr<CDSNotificationInterface> g_ds_notification_interface;

Generated by: LCOV version 1.16