File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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+
29272932void CConnman::GetNodeStats (std::vector<CNodeStats>& vstats)
29282933{
29292934 vstats.clear ();
Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments