From 60788ce32506ecf6a826dcf3b178822c5d4fdb33 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Tue, 9 Apr 2019 09:13:31 +0200 Subject: [PATCH] Connect to most recently updated address in ThreadOpenMasternodeConnections It's not a good idea to try to connect to an old address of a masternode. This will also skip connection attempts when the masternode is not in the valid set anymore (banned or collateral spent). --- src/net.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index e122da43f3..7c39ea65c6 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2056,6 +2056,8 @@ void CConnman::ThreadOpenMasternodeConnections() } }); + auto mnList = deterministicMNManager->GetListAtChainTip(); + CSemaphoreGrant grant(*semMasternodeOutbound); if (interruptNet) return; @@ -2069,8 +2071,12 @@ void CConnman::ThreadOpenMasternodeConnections() std::vector pending; for (const auto& group : masternodeQuorumNodes) { for (const auto& p : group.second) { - auto& addr2 = p.first; - auto& proRegTxHash = p.second; + const auto& proRegTxHash = p.second; + auto dmn = mnList.GetValidMN(proRegTxHash); + if (!dmn) { + continue; + } + const auto& addr2 = dmn->pdmnState->addr; if (!connectedNodes.count(addr2) && !IsMasternodeOrDisconnectRequested(addr2) && !connectedProRegTxHashes.count(proRegTxHash)) { pending.emplace_back(addr2); }