Skip to content

Commit ff181f1

Browse files
committed
TierTwo: Only relay data if we aren't on the initial synchronization phase.
It simply makes no sense to relay mnb, votes, proposals, etc. to the peers from where we are synchronizing our initial state while we are doing it.
1 parent bf5f78e commit ff181f1

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/budget/budgetmanager.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,10 @@ int CBudgetManager::ProcessProposal(CBudgetProposal& proposal)
10151015
if (!AddProposal(proposal)) {
10161016
return 0;
10171017
}
1018-
proposal.Relay();
1018+
1019+
// Relay only if we are synchronized
1020+
// Makes no sense to relay proposals to the peers from where we are syncing them.
1021+
if (masternodeSync.IsSynced()) proposal.Relay();
10191022
masternodeSync.AddedBudgetItem(nHash);
10201023

10211024
LogPrint(BCLog::MNBUDGET, "mprop (new) %s\n", nHash.ToString());
@@ -1058,7 +1061,9 @@ bool CBudgetManager::ProcessProposalVote(CBudgetVote& vote, CNode* pfrom, CValid
10581061
return state.DoS(0, false, REJECT_INVALID, "bad-mvote", false, strprintf("%s (%s)", err, mn_protx_id));
10591062
}
10601063

1061-
vote.Relay();
1064+
// Relay only if we are synchronized
1065+
// Makes no sense to relay votes to the peers from where we are syncing them.
1066+
if (masternodeSync.IsSynced()) vote.Relay();
10621067
masternodeSync.AddedBudgetItem(voteID);
10631068
LogPrint(BCLog::MNBUDGET, "mvote - new vote (%s) for proposal %s from dmn %s\n",
10641069
voteID.ToString(), vote.GetProposalHash().ToString(), mn_protx_id);
@@ -1093,7 +1098,9 @@ bool CBudgetManager::ProcessProposalVote(CBudgetVote& vote, CNode* pfrom, CValid
10931098
return state.DoS(0, false, REJECT_INVALID, "bad-mvote", false, err);
10941099
}
10951100

1096-
vote.Relay();
1101+
// Relay only if we are synchronized
1102+
// Makes no sense to relay votes to the peers from where we are syncing them.
1103+
if (masternodeSync.IsSynced()) vote.Relay();
10971104
masternodeSync.AddedBudgetItem(voteID);
10981105
LogPrint(BCLog::MNBUDGET, "mvote - new vote (%s) for proposal %s from dmn %s\n",
10991106
voteID.ToString(), vote.GetProposalHash().ToString(), voteVin.prevout.ToString());
@@ -1111,7 +1118,10 @@ int CBudgetManager::ProcessFinalizedBudget(CFinalizedBudget& finalbudget, CNode*
11111118
if (!AddFinalizedBudget(finalbudget, pfrom)) {
11121119
return 0;
11131120
}
1114-
finalbudget.Relay();
1121+
1122+
// Relay only if we are synchronized
1123+
// Makes no sense to relay finalizations to the peers from where we are syncing them.
1124+
if (masternodeSync.IsSynced()) finalbudget.Relay();
11151125
masternodeSync.AddedBudgetItem(nHash);
11161126

11171127
LogPrint(BCLog::MNBUDGET, "fbs (new) %s\n", nHash.ToString());
@@ -1153,7 +1163,9 @@ bool CBudgetManager::ProcessFinalizedBudgetVote(CFinalizedBudgetVote& vote, CNod
11531163
return state.DoS(0, false, REJECT_INVALID, "bad-fbvote", false, strprintf("%s (%s)", err, mn_protx_id));
11541164
}
11551165

1156-
vote.Relay();
1166+
// Relay only if we are synchronized
1167+
// Makes no sense to relay votes to the peers from where we are syncing them.
1168+
if (masternodeSync.IsSynced()) vote.Relay();
11571169
masternodeSync.AddedBudgetItem(voteID);
11581170
LogPrint(BCLog::MNBUDGET, "fbvote - new vote (%s) for budget %s from dmn %s\n",
11591171
voteID.ToString(), vote.GetBudgetHash().ToString(), mn_protx_id);
@@ -1187,7 +1199,9 @@ bool CBudgetManager::ProcessFinalizedBudgetVote(CFinalizedBudgetVote& vote, CNod
11871199
return state.DoS(0, false, REJECT_INVALID, "bad-fbvote", false, err);
11881200
}
11891201

1190-
vote.Relay();
1202+
// Relay only if we are synchronized
1203+
// Makes no sense to relay votes to the peers from where we are syncing them.
1204+
if (masternodeSync.IsSynced()) vote.Relay();
11911205
masternodeSync.AddedBudgetItem(voteID);
11921206
LogPrint(BCLog::MNBUDGET, "fbvote - new vote (%s) for budget %s from mn %s\n",
11931207
voteID.ToString(), vote.GetBudgetHash().ToString(), voteVin.prevout.ToString());

src/masternode-payments.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,9 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
517517
}
518518

519519
if (masternodePayments.AddWinningMasternode(winner)) {
520-
winner.Relay();
520+
// Relay only if we are synchronized.
521+
// Makes no sense to relay MNWinners to the peers from where we are syncing them.
522+
if (masternodeSync.IsSynced()) winner.Relay();
521523
masternodeSync.AddedMasternodeWinner(winner.GetHash());
522524
}
523525
}

src/masternode.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,10 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int nChainHeight, int& nDoS)
544544
activeMasternode.EnableHotColdMasterNode(vin, addr);
545545
}
546546

547+
// Relay only if we are synchronized and if the mnb address is not local.
548+
// Makes no sense to relay MNBs to the peers from where we are syncing them.
547549
bool isLocal = (addr.IsRFC1918() || addr.IsLocal()) && !Params().IsRegTestNet();
548-
549-
if (!isLocal) Relay();
550+
if (!isLocal && masternodeSync.IsSynced()) Relay();
550551

551552
return true;
552553
}

0 commit comments

Comments
 (0)