mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +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)
|
if (interruptNet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// NOTE: Process only one pending masternode at a time
|
||||||
|
|
||||||
LOCK(cs_vPendingMasternodes);
|
LOCK(cs_vPendingMasternodes);
|
||||||
std::vector<CService>::iterator it = vPendingMasternodes.begin();
|
if (vPendingMasternodes.empty()) {
|
||||||
while (it != vPendingMasternodes.end()) {
|
// nothing to do, keep waiting
|
||||||
if (!IsMasternodeOrDisconnectRequested(*it)) {
|
continue;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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