Skip to content

Commit

Permalink
Connect to most recently updated address in ThreadOpenMasternodeConne…
Browse files Browse the repository at this point in the history
…ctions

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).
  • Loading branch information
codablock committed Apr 9, 2019
1 parent 93b1b3d commit 60788ce
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,8 @@ void CConnman::ThreadOpenMasternodeConnections()
}
});

auto mnList = deterministicMNManager->GetListAtChainTip();

CSemaphoreGrant grant(*semMasternodeOutbound);
if (interruptNet)
return;
Expand All @@ -2069,8 +2071,12 @@ void CConnman::ThreadOpenMasternodeConnections()
std::vector<CService> 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);
}
Expand Down

0 comments on commit 60788ce

Please sign in to comment.