Don't disconnect masternode probes for a few seconds (#3449)

* Refactor CMasternodeUtils::ProcessMasternodeConnections to be more readable

* Don't disconnect masternode probes for a few seconds
This commit is contained in:
Alexander Block 2020-04-21 16:44:18 +02:00 committed by GitHub
parent 608aed3d85
commit 96faa8155e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,15 @@ void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman)
} }
connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) { connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) {
if (!pnode->fInbound && pnode->fMasternode && !connman.IsMasternodeQuorumNode(pnode)) { // we're only disconnecting fMasternode connections
if (!pnode->fMasternode) return;
// we're only disconnecting outbound connections
if (pnode->fInbound) return;
// we're not disconnecting LLMQ connections
if (connman.IsMasternodeQuorumNode(pnode)) return;
// we're not disconnecting masternode probes for at least a few seconds
if (pnode->fMasternodeProbe && GetSystemTimeInSeconds() - pnode->nTimeConnected < 5) return;
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
bool fFound = false; bool fFound = false;
for (const auto& dmn : vecDmns) { for (const auto& dmn : vecDmns) {
@ -56,7 +64,6 @@ void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman)
LogPrintf("Closing Masternode connection: peer=%d\n", pnode->GetId()); LogPrintf("Closing Masternode connection: peer=%d\n", pnode->GetId());
} }
pnode->fDisconnect = true; pnode->fDisconnect = true;
}
}); });
} }