ThreadOpenMasternodeConnections should process only one mn at a time (#2080)

This commit is contained in:
UdjinM6 2018-05-26 21:03:49 +03:00 committed by GitHub
parent 7ac4b972ab
commit c60079b594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
});
}
}