diff --git a/src/evo/mnauth.cpp b/src/evo/mnauth.cpp index dff552d4e3e8a3..8162371a069a0c 100644 --- a/src/evo/mnauth.cpp +++ b/src/evo/mnauth.cpp @@ -147,12 +147,14 @@ void CMNAuth::ProcessMessage(CNode& peer, PeerManager& peerman, CConnman& connma LogPrint(BCLog::NET_NETCONN, "CMNAuth::ProcessMessage -- Masternode %s has already verified as peer %d, deterministicOutbound=%s. peer=%d\n", mnauth.proRegTxHash.ToString(), pnode2->GetId(), deterministicOutbound.ToString(), peer.GetId()); if (deterministicOutbound == myProTxHash) { + // NOTE: do not drop inbound nodes here, mark them as probes so that + // they would be disconnected later in CMasternodeUtils::DoMaintenance if (pnode2->fInbound) { - LogPrint(BCLog::NET_NETCONN, "CMNAuth::ProcessMessage -- dropping old inbound, peer=%d\n", pnode2->GetId()); - pnode2->fDisconnect = true; + LogPrint(BCLog::NET_NETCONN, "CMNAuth::ProcessMessage -- marking old inbound for dropping it later, peer=%d\n", pnode2->GetId()); + pnode2->m_masternode_probe_connection = true; } else if (peer.fInbound) { - LogPrint(BCLog::NET_NETCONN, "CMNAuth::ProcessMessage -- dropping new inbound, peer=%d\n", peer.GetId()); - peer.fDisconnect = true; + LogPrint(BCLog::NET_NETCONN, "CMNAuth::ProcessMessage -- marking new inbound for dropping it later, peer=%d\n", peer.GetId()); + peer.m_masternode_probe_connection = true; } } else { if (!pnode2->fInbound) { diff --git a/src/masternode/utils.cpp b/src/masternode/utils.cpp index 03fba7cec67135..b2c4dc55ab591c 100644 --- a/src/masternode/utils.cpp +++ b/src/masternode/utils.cpp @@ -46,30 +46,33 @@ void CMasternodeUtils::DoMaintenance(CConnman& connman, const CMasternodeSync& m } connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) { - // we're only disconnecting m_masternode_connection connections - if (!pnode->m_masternode_connection) return; - if (!pnode->GetVerifiedProRegTxHash().IsNull()) { - // keep _verified_ LLMQ connections - if (connman.IsMasternodeQuorumNode(pnode)) { - return; - } - // keep _verified_ LLMQ relay connections - if (connman.IsMasternodeQuorumRelayMember(pnode->GetVerifiedProRegTxHash())) { + if (pnode->m_masternode_probe_connection) { + // we're not disconnecting masternode probes for at least a few seconds + if (GetSystemTimeInSeconds() - pnode->nTimeConnected < 5) return; + } else { + // we're only disconnecting m_masternode_connection connections + if (!pnode->m_masternode_connection) return; + if (!pnode->GetVerifiedProRegTxHash().IsNull()) { + // keep _verified_ LLMQ connections + if (connman.IsMasternodeQuorumNode(pnode)) { + return; + } + // keep _verified_ LLMQ relay connections + if (connman.IsMasternodeQuorumRelayMember(pnode->GetVerifiedProRegTxHash())) { + return; + } + // keep _verified_ inbound connections + if (pnode->fInbound) { + return; + } + } else if (GetSystemTimeInSeconds() - pnode->nTimeConnected < 5) { + // non-verified, give it some time to verify itself return; - } - // keep _verified_ inbound connections - if (pnode->fInbound) { + } else if (pnode->qwatch) { + // keep watching nodes return; } - } else if (GetSystemTimeInSeconds() - pnode->nTimeConnected < 5) { - // non-verified, give it some time to verify itself - return; - } else if (pnode->qwatch) { - // keep watching nodes - return; } - // we're not disconnecting masternode probes for at least a few seconds - if (pnode->m_masternode_probe_connection && GetSystemTimeInSeconds() - pnode->nTimeConnected < 5) return; #ifdef ENABLE_WALLET bool fFound = ranges::any_of(vecDmns, [&pnode](const auto& dmn){ return pnode->addr == dmn->pdmnState->addr; });