mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
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:
parent
608aed3d85
commit
96faa8155e
@ -39,24 +39,31 @@ void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman)
|
||||
}
|
||||
|
||||
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
|
||||
bool fFound = false;
|
||||
for (const auto& dmn : vecDmns) {
|
||||
if (pnode->addr == dmn->pdmnState->addr) {
|
||||
fFound = true;
|
||||
break;
|
||||
}
|
||||
bool fFound = false;
|
||||
for (const auto& dmn : vecDmns) {
|
||||
if (pnode->addr == dmn->pdmnState->addr) {
|
||||
fFound = true;
|
||||
break;
|
||||
}
|
||||
if (fFound) return; // do NOT disconnect mixing masternodes
|
||||
#endif // ENABLE_WALLET
|
||||
if (fLogIPs) {
|
||||
LogPrintf("Closing Masternode connection: peer=%d, addr=%s\n", pnode->GetId(), pnode->addr.ToString());
|
||||
} else {
|
||||
LogPrintf("Closing Masternode connection: peer=%d\n", pnode->GetId());
|
||||
}
|
||||
pnode->fDisconnect = true;
|
||||
}
|
||||
if (fFound) return; // do NOT disconnect mixing masternodes
|
||||
#endif // ENABLE_WALLET
|
||||
if (fLogIPs) {
|
||||
LogPrintf("Closing Masternode connection: peer=%d, addr=%s\n", pnode->GetId(), pnode->addr.ToString());
|
||||
} else {
|
||||
LogPrintf("Closing Masternode connection: peer=%d\n", pnode->GetId());
|
||||
}
|
||||
pnode->fDisconnect = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user