Don't disconnect masternode connections when we have less then the desired amount of outbound nodes (#3255)

This commit is contained in:
Alexander Block 2020-01-01 15:13:14 +01:00 committed by UdjinM6
parent cecbbab3cd
commit 31afa9c0fc
3 changed files with 17 additions and 0 deletions

View File

@ -27,6 +27,17 @@ void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman)
privateSendClient.GetMixingMasternodesInfo(vecDmns);
#endif // ENABLE_WALLET
// Don't disconnect masternode connections when we have less then the desired amount of outbound nodes
int nonMasternodeCount = 0;
connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) {
if (!pnode->fInbound && !pnode->fFeeler && !pnode->m_manual_connection && !pnode->fMasternode) {
nonMasternodeCount++;
}
});
if (nonMasternodeCount < connman.GetMaxOutboundNodeCount()) {
return;
}
connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) {
if (pnode->fMasternode && !connman.IsMasternodeQuorumNode(pnode)) {
#ifdef ENABLE_WALLET

View File

@ -2924,6 +2924,11 @@ size_t CConnman::GetNodeCount(NumConnections flags)
return nNum;
}
size_t CConnman::GetMaxOutboundNodeCount()
{
return nMaxOutbound;
}
void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats)
{
vstats.clear();

View File

@ -407,6 +407,7 @@ public:
bool IsMasternodeQuorumNode(const CNode* pnode);
size_t GetNodeCount(NumConnections num);
size_t GetMaxOutboundNodeCount();
void GetNodeStats(std::vector<CNodeStats>& vstats);
bool DisconnectNode(const std::string& node);
bool DisconnectNode(NodeId id);