Skip to content

Commit

Permalink
masternodesync: reset last budget item time before start syncing it.
Browse files Browse the repository at this point in the history
if we received for example a single proposal +50 seconds ago, then once the budget sync starts (right after this call),
it will look like the sync is finished. Will not wait to receive any budget data and declare the sync over.

Github-Pull: #2659
Rebased-From: 7349750
  • Loading branch information
furszy committed Dec 14, 2021
1 parent 94f1c52 commit cfc15b6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/masternode-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ bool CMasternodeSync::SyncWithNode(CNode* pnode, bool fLegacyMnObsolete)

if (lastMasternodeWinner > 0 && lastMasternodeWinner < GetTime() - MASTERNODE_SYNC_TIMEOUT * 2 && RequestedMasternodeAttempt >= MASTERNODE_SYNC_THRESHOLD) { //hasn't received a new item in the last five seconds, so we'll move to the
SwitchToNextAsset();
// in case we received a budget item while we were syncing the mnw, let's reset the last budget item received time.
// reason: if we received for example a single proposal +50 seconds ago, then once the budget sync starts (right after this call),
// it will look like the sync is finished, and will not wait to receive any budget data and declare the sync over.
lastBudgetItem = 0;
return false;
}

Expand All @@ -412,6 +416,11 @@ bool CMasternodeSync::SyncWithNode(CNode* pnode, bool fLegacyMnObsolete)
syncTimeout("MASTERNODE_SYNC_MNW");
} else {
SwitchToNextAsset();
// Same as above (future: remove all of this duplicated code in v6.0.)
// in case we received a budget item while we were syncing the mnw, let's reset the last budget item received time.
// reason: if we received for example a single proposal +50 seconds ago, then once the budget sync starts (right after this call),
// it will look like the sync is finished, and will not wait to receive any budget data and declare the sync over.
lastBudgetItem = 0;
}
return false;
}
Expand Down

0 comments on commit cfc15b6

Please sign in to comment.