Skip to content

Commit

Permalink
masternodesync: fix extra RequestedMNAttempt increment in the spork…
Browse files Browse the repository at this point in the history
…s flow.

As we are increase the `RequestedMNAttempt` right after calling `SwitchToNextAsset()`, the mn list sync starts with an invalid extra sync attempt.

Github-Pull: #2659
Rebased-From: 2c3b0e8
  • Loading branch information
furszy committed Dec 14, 2021
1 parent d95fb9b commit 281c061
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/masternode-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,18 @@ bool CMasternodeSync::SyncWithNode(CNode* pnode, bool fLegacyMnObsolete)

//set to synced
if (RequestedMasternodeAssets == MASTERNODE_SYNC_SPORKS) {

// Sync sporks from at least 2 peers
if (RequestedMasternodeAttempt >= MASTERNODE_SYNC_THRESHOLD) {
SwitchToNextAsset();
return false;
}

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

g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::GETSPORKS)); //get current network sporks
if (RequestedMasternodeAttempt >= 2) SwitchToNextAsset();
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::GETSPORKS));
RequestedMasternodeAttempt++;
return false;
}
Expand Down

0 comments on commit 281c061

Please sign in to comment.