Skip ping connections in outgoing count

This commit is contained in:
Lee *!* Clagett
2025-06-20 20:45:30 -04:00
committed by t1amak
parent a66b1d22e1
commit a660e9a6dc
4 changed files with 20 additions and 12 deletions

View File

@@ -109,15 +109,17 @@ namespace nodetool
template<class base_type>
struct p2p_connection_context_t: base_type //t_payload_net_handler::connection_context //public net_utils::connection_context_base
{
p2p_connection_context_t()
explicit p2p_connection_context_t(bool is_ping = false)
: peer_id(0),
support_flags(0),
is_ping(is_ping),
m_in_timedsync(false)
{}
peerid_type peer_id;
uint32_t support_flags;
bool m_in_timedsync;
bool is_ping;
std::set<epee::net_utils::network_address> sent_addresses;
};

View File

@@ -1045,7 +1045,7 @@ namespace nodetool
{
++number_of_in_peers;
}
else
else if (!cntxt.is_ping)
{
++number_of_out_peers;
}
@@ -1956,7 +1956,7 @@ namespace nodetool
size_t count = 0;
zone.m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt)
{
if(!cntxt.m_is_income)
if(!cntxt.m_is_income && !cntxt.is_ping)
++count;
return true;
});
@@ -2429,7 +2429,7 @@ namespace nodetool
return false;
}
return true;
}, "0.0.0.0", m_ssl_support);
}, "0.0.0.0", m_ssl_support, p2p_connection_context{true /* is_ping */});
if(!r)
{
LOG_WARNING_CC(context, "Failed to call connect_async, network error.");