mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
Rename connections_count to max_out_connection_count
This is needed so that a max_in_connection_count can be added.
This commit is contained in:
parent
ed67e5c001
commit
b927c0fc7a
@ -871,11 +871,11 @@ namespace nodetool
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::try_to_connect_and_handshake_with_new_peer(const epee::net_utils::network_address& na, bool just_take_peerlist, uint64_t last_seen_stamp, PeerType peer_type, uint64_t first_seen_stamp)
|
||||
{
|
||||
if (m_current_number_of_out_peers == m_config.m_net_config.connections_count) // out peers limit
|
||||
if (m_current_number_of_out_peers == m_config.m_net_config.max_out_connection_count) // out peers limit
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (m_current_number_of_out_peers > m_config.m_net_config.connections_count)
|
||||
else if (m_current_number_of_out_peers > m_config.m_net_config.max_out_connection_count)
|
||||
{
|
||||
m_net_server.get_config_object().del_out_connections(1);
|
||||
m_current_number_of_out_peers --; // atomic variable, update time = 1s
|
||||
@ -1164,10 +1164,10 @@ namespace nodetool
|
||||
|
||||
if (!connect_to_peerlist(m_priority_peers)) return false;
|
||||
|
||||
size_t expected_white_connections = (m_config.m_net_config.connections_count*P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT)/100;
|
||||
size_t expected_white_connections = (m_config.m_net_config.max_out_connection_count*P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT)/100;
|
||||
|
||||
size_t conn_count = get_outgoing_connections_count();
|
||||
if(conn_count < m_config.m_net_config.connections_count)
|
||||
if(conn_count < m_config.m_net_config.max_out_connection_count)
|
||||
{
|
||||
if(conn_count < expected_white_connections)
|
||||
{
|
||||
@ -1178,20 +1178,20 @@ namespace nodetool
|
||||
if(!make_expected_connections_count(white, expected_white_connections))
|
||||
return false;
|
||||
//then do grey list
|
||||
if(!make_expected_connections_count(gray, m_config.m_net_config.connections_count))
|
||||
if(!make_expected_connections_count(gray, m_config.m_net_config.max_out_connection_count))
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
//start from grey list
|
||||
if(!make_expected_connections_count(gray, m_config.m_net_config.connections_count))
|
||||
if(!make_expected_connections_count(gray, m_config.m_net_config.max_out_connection_count))
|
||||
return false;
|
||||
//and then do white list
|
||||
if(!make_expected_connections_count(white, m_config.m_net_config.connections_count))
|
||||
if(!make_expected_connections_count(white, m_config.m_net_config.max_out_connection_count))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (start_conn_count == get_outgoing_connections_count() && start_conn_count < m_config.m_net_config.connections_count)
|
||||
if (start_conn_count == get_outgoing_connections_count() && start_conn_count < m_config.m_net_config.max_out_connection_count)
|
||||
{
|
||||
MINFO("Failed to connect to any, trying seeds");
|
||||
if (!connect_to_seed())
|
||||
@ -1779,10 +1779,10 @@ namespace nodetool
|
||||
bool node_server<t_payload_net_handler>::set_max_out_peers(const boost::program_options::variables_map& vm, int64_t max)
|
||||
{
|
||||
if(max == -1) {
|
||||
m_config.m_net_config.connections_count = P2P_DEFAULT_CONNECTIONS_COUNT;
|
||||
m_config.m_net_config.max_out_connection_count = P2P_DEFAULT_CONNECTIONS_COUNT;
|
||||
return true;
|
||||
}
|
||||
m_config.m_net_config.connections_count = max;
|
||||
m_config.m_net_config.max_out_connection_count = max;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -131,13 +131,13 @@ namespace nodetool
|
||||
struct network_config
|
||||
{
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(connections_count)
|
||||
KV_SERIALIZE(max_out_connection_count)
|
||||
KV_SERIALIZE(handshake_interval)
|
||||
KV_SERIALIZE(packet_max_size)
|
||||
KV_SERIALIZE(config_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
||||
uint32_t connections_count;
|
||||
uint32_t max_out_connection_count;
|
||||
uint32_t connection_timeout;
|
||||
uint32_t ping_connection_timeout;
|
||||
uint32_t handshake_interval;
|
||||
|
@ -1596,7 +1596,7 @@ namespace cryptonote
|
||||
PERF_TIMER(on_out_peers);
|
||||
size_t n_connections = m_p2p.get_outgoing_connections_count();
|
||||
size_t n_delete = (n_connections > req.out_peers) ? n_connections - req.out_peers : 0;
|
||||
m_p2p.m_config.m_net_config.connections_count = req.out_peers;
|
||||
m_p2p.m_config.m_net_config.max_out_connection_count = req.out_peers;
|
||||
if (n_delete)
|
||||
m_p2p.delete_connections(n_delete);
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user