From cfc15b65af488a247b797b8e3c71cd7960be2866 Mon Sep 17 00:00:00 2001 From: furszy Date: Wed, 1 Dec 2021 22:40:05 -0300 Subject: [PATCH] masternodesync: reset last budget item time before start syncing it. 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: 734975059c00d6a014f732d21c85f36ab3025836 --- src/masternode-sync.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index 06f2da988c4a0..6dfdeb62273e2 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -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; } @@ -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; }