Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,22 +1950,30 @@ void CConnman::ThreadOpenMasternodeConnections()
if (interruptNet)
return;

// NOTE: Process only one pending masternode at a time

LOCK(cs_vPendingMasternodes);
std::vector<CService>::iterator it = vPendingMasternodes.begin();
while (it != vPendingMasternodes.end()) {
if (!IsMasternodeOrDisconnectRequested(*it)) {
OpenMasternodeConnection(CAddress(*it, NODE_NETWORK));
// should be in the list now if connection was opened
ForNode(*it, CConnman::AllNodes, [&](CNode* pnode) {
if (pnode->fDisconnect) {
return false;
}
grant.MoveTo(pnode->grantMasternodeOutbound);
return true;
});
}
it = vPendingMasternodes.erase(it);
if (vPendingMasternodes.empty()) {
// nothing to do, keep waiting
continue;
}

const CService addr = vPendingMasternodes.front();
vPendingMasternodes.erase(vPendingMasternodes.begin());
if (IsMasternodeOrDisconnectRequested(addr)) {
// nothing to do, try the next one
continue;
}

OpenMasternodeConnection(CAddress(addr, NODE_NETWORK));
// should be in the list now if connection was opened
ForNode(addr, CConnman::AllNodes, [&](CNode* pnode) {
if (pnode->fDisconnect) {
return false;
}
grant.MoveTo(pnode->grantMasternodeOutbound);
return true;
});
}
}

Expand Down