Skip to content

Commit 31afa9c

Browse files
codablockUdjinM6
authored andcommitted
Don't disconnect masternode connections when we have less then the desired amount of outbound nodes (#3255)
1 parent cecbbab commit 31afa9c

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/masternode/masternode-utils.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman)
2727
privateSendClient.GetMixingMasternodesInfo(vecDmns);
2828
#endif // ENABLE_WALLET
2929

30+
// Don't disconnect masternode connections when we have less then the desired amount of outbound nodes
31+
int nonMasternodeCount = 0;
32+
connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) {
33+
if (!pnode->fInbound && !pnode->fFeeler && !pnode->m_manual_connection && !pnode->fMasternode) {
34+
nonMasternodeCount++;
35+
}
36+
});
37+
if (nonMasternodeCount < connman.GetMaxOutboundNodeCount()) {
38+
return;
39+
}
40+
3041
connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) {
3142
if (pnode->fMasternode && !connman.IsMasternodeQuorumNode(pnode)) {
3243
#ifdef ENABLE_WALLET

src/net.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,6 +2924,11 @@ size_t CConnman::GetNodeCount(NumConnections flags)
29242924
return nNum;
29252925
}
29262926

2927+
size_t CConnman::GetMaxOutboundNodeCount()
2928+
{
2929+
return nMaxOutbound;
2930+
}
2931+
29272932
void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats)
29282933
{
29292934
vstats.clear();

src/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ class CConnman
407407
bool IsMasternodeQuorumNode(const CNode* pnode);
408408

409409
size_t GetNodeCount(NumConnections num);
410+
size_t GetMaxOutboundNodeCount();
410411
void GetNodeStats(std::vector<CNodeStats>& vstats);
411412
bool DisconnectNode(const std::string& node);
412413
bool DisconnectNode(NodeId id);

0 commit comments

Comments
 (0)