mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
ThreadOpenMasternodeConnections should process only one mn at a time (#2080)
This commit is contained in:
parent
7ac4b972ab
commit
c60079b594
36
src/net.cpp
36
src/net.cpp
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user