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 : #ifndef BITCOIN_NODE_SYNC_MANAGER_H 6 : #define BITCOIN_NODE_SYNC_MANAGER_H 7 : 8 : #include <masternode/sync.h> 9 : #include <net_processing.h> 10 : 11 : class CGovernanceManager; 12 : class CMasternodeSync; 13 : class CNetFulfilledRequestManager; 14 : 15 : class SyncManager final : public NetHandler 16 : { 17 : public: 18 5714 : SyncManager(PeerManagerInternal* peer_manager, CGovernanceManager& gov_manager, CMasternodeSync& node_sync, CConnman& connman, 19 : CNetFulfilledRequestManager& netfulfilledman) : 20 2857 : NetHandler(peer_manager), 21 2857 : m_gov_manager(gov_manager), 22 2857 : m_node_sync(node_sync), 23 2857 : m_connman(connman), 24 2857 : m_netfulfilledman(netfulfilledman) 25 5714 : { 26 5714 : } 27 : void Schedule(CScheduler& scheduler) override; 28 : void ProcessMessage(CNode& peer, const std::string& msg_type, CDataStream& vRecv) override; 29 : 30 : private: 31 : void SendGovernanceSyncRequest(CNode* pnode) const; 32 : void SendGovernanceObjectSyncRequest(CNode* pnode, const uint256& nHash, bool fUseFilter) const; 33 : int RequestGovernanceObjectVotes(const std::vector<CNode*>& vNodesCopy) const; 34 : void ProcessTick(); 35 : 36 : CGovernanceManager& m_gov_manager; 37 : CMasternodeSync& m_node_sync; 38 : CConnman& m_connman; 39 : CNetFulfilledRequestManager& m_netfulfilledman; 40 : }; 41 : 42 : class NodeSyncNotifierImpl : public NodeSyncNotifier 43 : { 44 : public: 45 6138 : NodeSyncNotifierImpl(CConnman& connman, CNetFulfilledRequestManager& netfulfilledman) : 46 3069 : m_connman(connman), 47 3069 : m_netfulfilledman(netfulfilledman) 48 9207 : {} 49 : 50 : void SyncReset() override; 51 : void SyncFinished() override; 52 : private: 53 : CConnman& m_connman; 54 : CNetFulfilledRequestManager& m_netfulfilledman; 55 : }; 56 : #endif // BITCOIN_NODE_SYNC_MANAGER_H