Skip to content

Commit

Permalink
Masternode-sync: Only mark tier two messages sync requests as fulfill…
Browse files Browse the repository at this point in the history
…ed if the messages are broadcast.

e.g: do not mark them as fulfilled before fail for a timeout.

Github-Pull: #2560
Rebased-From: 88704c4
  • Loading branch information
furszy committed Sep 20, 2021
1 parent 2f98acf commit 17fa0eb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/masternode-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,6 @@ bool CMasternodeSync::SyncWithNode(CNode* pnode, bool fLegacyMnObsolete)
return false;
}

if (pnode->HasFulfilledRequest("mnsync")) return true;
pnode->FulfilledRequest("mnsync");

// timeout
if (lastMasternodeList == 0 &&
(RequestedMasternodeAttempt >= MASTERNODE_SYNC_THRESHOLD * 3 || GetTime() - nAssetSyncStarted > MASTERNODE_SYNC_TIMEOUT * 5)) {
Expand All @@ -363,6 +360,10 @@ bool CMasternodeSync::SyncWithNode(CNode* pnode, bool fLegacyMnObsolete)

if (RequestedMasternodeAttempt >= MASTERNODE_SYNC_THRESHOLD * 3) return false;

// Request mnb sync if we haven't requested it yet.
if (pnode->HasFulfilledRequest("mnsync")) return true;
pnode->FulfilledRequest("mnsync");

mnodeman.DsegUpdate(pnode);
RequestedMasternodeAttempt++;
return false;
Expand All @@ -379,9 +380,6 @@ bool CMasternodeSync::SyncWithNode(CNode* pnode, bool fLegacyMnObsolete)
return false;
}

if (pnode->HasFulfilledRequest("mnwsync")) return true;
pnode->FulfilledRequest("mnwsync");

// timeout
if (lastMasternodeWinner == 0 &&
(RequestedMasternodeAttempt >= MASTERNODE_SYNC_THRESHOLD * 3 || GetTime() - nAssetSyncStarted > MASTERNODE_SYNC_TIMEOUT * 5)) {
Expand All @@ -399,6 +397,10 @@ bool CMasternodeSync::SyncWithNode(CNode* pnode, bool fLegacyMnObsolete)

if (RequestedMasternodeAttempt >= MASTERNODE_SYNC_THRESHOLD * 3) return false;

// Request mnw sync if we haven't requested it yet.
if (pnode->HasFulfilledRequest("mnwsync")) return true;
pnode->FulfilledRequest("mnwsync");

int nMnCount = mnodeman.CountEnabled();
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::GETMNWINNERS, nMnCount)); //sync payees
RequestedMasternodeAttempt++;
Expand All @@ -425,11 +427,12 @@ bool CMasternodeSync::SyncWithNode(CNode* pnode, bool fLegacyMnObsolete)
return false;
}

if (RequestedMasternodeAttempt >= MASTERNODE_SYNC_THRESHOLD * 3) return false;

// Request bud sync if we haven't requested it yet.
if (pnode->HasFulfilledRequest("busync")) return true;
pnode->FulfilledRequest("busync");

if (RequestedMasternodeAttempt >= MASTERNODE_SYNC_THRESHOLD * 3) return false;

uint256 n;
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::BUDGETVOTESYNC, n)); //sync masternode votes
RequestedMasternodeAttempt++;
Expand Down

0 comments on commit 17fa0eb

Please sign in to comment.