@@ -98,6 +98,34 @@ bool CGovernanceManager::LoadCache(bool load_cache)
9898 return is_valid;
9999}
100100
101+ void CGovernanceManager::RelayMessage (PeerManager& peerman, const CGovernanceObject& obj) const
102+ {
103+ if (!m_mn_sync.IsSynced ()) {
104+ LogPrint (BCLog::GOBJECT, " %s -- won't relay until fully synced\n " , __func__);
105+ return ;
106+ }
107+
108+ CInv inv (MSG_GOVERNANCE_OBJECT, obj.GetHash ());
109+ peerman.RelayInv (inv);
110+ }
111+
112+ void CGovernanceManager::RelayMessage (PeerManager& peerman, const CGovernanceVote& vote) const
113+ {
114+ if (!m_mn_sync.IsSynced ()) {
115+ LogPrint (BCLog::GOBJECT, " %s -- won't relay until fully synced\n " , __func__);
116+ return ;
117+ }
118+
119+ const auto tip_mn_list = Assert (m_dmnman)->GetListAtChainTip ();
120+ auto dmn = tip_mn_list.GetMNByCollateral (vote.GetMasternodeOutpoint ());
121+ if (!dmn) {
122+ return ;
123+ }
124+
125+ CInv inv (MSG_GOVERNANCE_OBJECT_VOTE, vote.GetHash ());
126+ peerman.RelayInv (inv);
127+ }
128+
101129// Accessors for thread-safe access to maps
102130bool CGovernanceManager::HaveObjectForHash (const uint256& nHash) const
103131{
@@ -273,7 +301,7 @@ MessageProcessingResult CGovernanceManager::ProcessMessage(CNode& peer, CConnman
273301 if (ProcessVote (&peer, vote, exception, connman)) {
274302 LogPrint (BCLog::GOBJECT, " MNGOVERNANCEOBJECTVOTE -- %s new\n " , strHash);
275303 m_mn_sync.BumpAssetLastTime (" MNGOVERNANCEOBJECTVOTE" );
276- vote. Relay (peerman, m_mn_sync, tip_mn_list );
304+ RelayMessage (peerman, vote );
277305 } else {
278306 LogPrint (BCLog::GOBJECT, " MNGOVERNANCEOBJECTVOTE -- Rejected vote, error = %s\n " , exception.what ());
279307 if ((exception.GetNodePenalty () != 0 ) && m_mn_sync.IsSynced ()) {
@@ -305,7 +333,7 @@ void CGovernanceManager::CheckOrphanVotes(CGovernanceObject& govobj, PeerManager
305333 if (pairVote.second < nNow) {
306334 fRemove = true ;
307335 } else if (govobj.ProcessVote (m_mn_metaman, *this , tip_mn_list, vote, e)) {
308- vote. Relay (peerman, m_mn_sync, tip_mn_list );
336+ RelayMessage (peerman, vote );
309337 fRemove = true ;
310338 }
311339 if (fRemove ) {
@@ -359,7 +387,7 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, PeerMana
359387 }
360388
361389 LogPrint (BCLog::GOBJECT, " CGovernanceManager::AddGovernanceObject -- %s new, received from peer %s\n " , strHash, pfrom ? pfrom->GetLogString () : " nullptr" );
362- govobj. Relay (peerman, m_mn_sync );
390+ RelayMessage (peerman, govobj );
363391
364392 // Update the rate buffer
365393 MasternodeRateUpdate (govobj);
@@ -852,9 +880,9 @@ bool CGovernanceManager::MasternodeRateCheck(const CGovernanceObject& govobj, bo
852880
853881bool CGovernanceManager::ProcessVoteAndRelay (const CGovernanceVote& vote, CGovernanceException& exception, CConnman& connman, PeerManager& peerman)
854882{
855- bool fOK = ProcessVote (/* pfrom = */ nullptr , vote, exception, connman);
883+ bool fOK = ProcessVote (/* pfrom= */ nullptr , vote, exception, connman);
856884 if (fOK ) {
857- vote. Relay (peerman, m_mn_sync, Assert (m_dmnman)-> GetListAtChainTip () );
885+ RelayMessage (peerman, vote );
858886 }
859887 return fOK ;
860888}
@@ -962,7 +990,7 @@ void CGovernanceManager::CheckPostponedObjects(PeerManager& peerman)
962990 if (fValid ) {
963991 if (fReady ) {
964992 LogPrint (BCLog::GOBJECT, " CGovernanceManager::CheckPostponedObjects -- additional relay: hash = %s\n " , govobj.GetHash ().ToString ());
965- govobj. Relay (peerman, m_mn_sync );
993+ RelayMessage (peerman, govobj );
966994 } else {
967995 it++;
968996 continue ;
0 commit comments