mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Fix ThreadOpenMasternodeConnections to not drop pending MN connections
The way it was implemented caused vPendingMasternodes entries to be popped but not necessarily connected to when at the same time quorum connections were pending.
This commit is contained in:
parent
0fa2e14065
commit
0adef2cf7a
24
src/net.cpp
24
src/net.cpp
@ -2130,6 +2130,15 @@ void CConnman::ThreadOpenMasternodeConnections()
|
||||
{ // don't hold lock while calling OpenMasternodeConnection as cs_main is locked deep inside
|
||||
LOCK2(cs_vNodes, cs_vPendingMasternodes);
|
||||
|
||||
if (!vPendingMasternodes.empty()) {
|
||||
auto addr2 = vPendingMasternodes.front();
|
||||
vPendingMasternodes.erase(vPendingMasternodes.begin());
|
||||
if (!connectedNodes.count(addr2) && !IsMasternodeOrDisconnectRequested(addr2)) {
|
||||
addr = addr2;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr == CService()) {
|
||||
std::vector<CService> pending;
|
||||
for (const auto& group : masternodeQuorumNodes) {
|
||||
for (const auto& proRegTxHash : group.second) {
|
||||
@ -2149,23 +2158,16 @@ void CConnman::ThreadOpenMasternodeConnections()
|
||||
}
|
||||
}
|
||||
|
||||
if (!vPendingMasternodes.empty()) {
|
||||
auto addr2 = vPendingMasternodes.front();
|
||||
vPendingMasternodes.erase(vPendingMasternodes.begin());
|
||||
if (!connectedNodes.count(addr2) && !IsMasternodeOrDisconnectRequested(addr2)) {
|
||||
pending.emplace_back(addr2);
|
||||
if (!pending.empty()) {
|
||||
addr = pending[GetRandInt(pending.size())];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pending.empty()) {
|
||||
// nothing to do, keep waiting
|
||||
if (addr == CService()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::random_shuffle(pending.begin(), pending.end());
|
||||
addr = pending.front();
|
||||
}
|
||||
|
||||
OpenMasternodeConnection(CAddress(addr, NODE_NETWORK));
|
||||
// should be in the list now if connection was opened
|
||||
ForNode(addr, CConnman::AllNodes, [&](CNode* pnode) {
|
||||
|
Loading…
Reference in New Issue
Block a user