diff --git a/nano/core_test/network.cpp b/nano/core_test/network.cpp index 00e3593ed..21d74fae4 100644 --- a/nano/core_test/network.cpp +++ b/nano/core_test/network.cpp @@ -118,7 +118,7 @@ TEST (network, last_contacted) ASSERT_EQ (0, node0->network.size ()); nano::node_config node1_config = system.default_config (); - node1_config.tcp_incoming_connections_max = 0; // Prevent ephemeral node1->node0 channel repacement with incoming connection + node1_config.tcp.max_inbound_connections = 0; // Prevent ephemeral node1->node0 channel repacement with incoming connection auto node1 (std::make_shared (system.io_ctx, nano::unique_path (), node1_config, system.work)); node1->start (); system.nodes.push_back (node1); diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 7cbef1802..4df9c713d 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -2603,7 +2603,7 @@ TEST (node, bidirectional_tcp) node_config.backlog_scan.enable = false; auto node1 = system.add_node (node_config, node_flags); node_config.peering_port = system.get_available_port (); - node_config.tcp_incoming_connections_max = 0; // Disable incoming TCP connections for node 2 + node_config.tcp.max_inbound_connections = 0; // Disable incoming TCP connections for node 2 auto node2 = system.add_node (node_config, node_flags); // Check network connections ASSERT_EQ (1, node1->network.size ()); diff --git a/nano/core_test/toml.cpp b/nano/core_test/toml.cpp index cb635aecd..9c9eb85c4 100644 --- a/nano/core_test/toml.cpp +++ b/nano/core_test/toml.cpp @@ -305,7 +305,6 @@ TEST (toml_config, daemon_config_deserialize_defaults) ASSERT_EQ (conf.node.preconfigured_representatives, defaults.node.preconfigured_representatives); ASSERT_EQ (conf.node.receive_minimum, defaults.node.receive_minimum); ASSERT_EQ (conf.node.signature_checker_threads, defaults.node.signature_checker_threads); - ASSERT_EQ (conf.node.tcp_incoming_connections_max, defaults.node.tcp_incoming_connections_max); ASSERT_EQ (conf.node.tcp_io_timeout, defaults.node.tcp_io_timeout); ASSERT_EQ (conf.node.unchecked_cutoff_time, defaults.node.unchecked_cutoff_time); ASSERT_EQ (conf.node.use_memory_pools, defaults.node.use_memory_pools); @@ -458,7 +457,6 @@ TEST (toml_config, daemon_config_deserialize_no_defaults) preconfigured_representatives = ["nano_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4"] receive_minimum = "999" signature_checker_threads = 999 - tcp_incoming_connections_max = 999 tcp_io_timeout = 999 unchecked_cutoff_time = 999 use_memory_pools = false @@ -710,7 +708,6 @@ TEST (toml_config, daemon_config_deserialize_no_defaults) ASSERT_NE (conf.node.preconfigured_representatives, defaults.node.preconfigured_representatives); ASSERT_NE (conf.node.receive_minimum, defaults.node.receive_minimum); ASSERT_NE (conf.node.signature_checker_threads, defaults.node.signature_checker_threads); - ASSERT_NE (conf.node.tcp_incoming_connections_max, defaults.node.tcp_incoming_connections_max); ASSERT_NE (conf.node.tcp_io_timeout, defaults.node.tcp_io_timeout); ASSERT_NE (conf.node.unchecked_cutoff_time, defaults.node.unchecked_cutoff_time); ASSERT_NE (conf.node.use_memory_pools, defaults.node.use_memory_pools); diff --git a/nano/node/node.cpp b/nano/node/node.cpp index b1693bc3b..65c8fc1dc 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -607,7 +607,7 @@ void nano::node::start () } bool tcp_enabled = false; - if (config.tcp_incoming_connections_max > 0 && !(flags.disable_bootstrap_listener && flags.disable_tcp_realtime)) + if (!(flags.disable_bootstrap_listener && flags.disable_tcp_realtime)) { tcp_listener.start (); tcp_enabled = true; diff --git a/nano/node/nodeconfig.cpp b/nano/node/nodeconfig.cpp index f6ccdf563..f683d1193 100644 --- a/nano/node/nodeconfig.cpp +++ b/nano/node/nodeconfig.cpp @@ -125,7 +125,6 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const toml.put ("pow_sleep_interval", pow_sleep_interval.count (), "Time to sleep between batch work generation attempts. Reduces max CPU usage at the expense of a longer generation time.\ntype:nanoseconds"); toml.put ("external_address", external_address, "The external address of this node (NAT). If not set, the node will request this information via UPnP.\ntype:string,ip"); toml.put ("external_port", external_port, "The external port number of this node (NAT). Only used if external_address is set.\ntype:uint16"); - toml.put ("tcp_incoming_connections_max", tcp_incoming_connections_max, "Maximum number of incoming TCP connections.\ntype:uint64"); toml.put ("use_memory_pools", use_memory_pools, "If true, allocate memory from memory pools. Enabling this may improve performance. Memory is never released to the OS.\ntype:bool"); toml.put ("bandwidth_limit", bandwidth_limit, "Outbound traffic limit in bytes/sec after which messages will be dropped.\nNote: changing to unlimited bandwidth (0) is not recommended for limited connections.\ntype:uint64"); @@ -538,7 +537,6 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml) toml.get ("external_address", external_address_l); external_address = external_address_l.to_string (); toml.get ("external_port", external_port); - toml.get ("tcp_incoming_connections_max", tcp_incoming_connections_max); auto pow_sleep_interval_l (pow_sleep_interval.count ()); toml.get (pow_sleep_interval_key, pow_sleep_interval_l); diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index 4871b9871..9a8d6bd41 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -109,8 +110,6 @@ public: std::chrono::seconds tcp_io_timeout{ (network_params.network.is_dev_network () && !is_sanitizer_build ()) ? std::chrono::seconds (5) : std::chrono::seconds (15) }; std::chrono::nanoseconds pow_sleep_interval{ 0 }; - /** Default maximum incoming TCP connections, including realtime network & bootstrap */ - unsigned tcp_incoming_connections_max{ 2048 }; bool use_memory_pools{ true }; static std::chrono::minutes constexpr wallet_backup_interval = std::chrono::minutes (5); /** Default outbound traffic shaping is 10MB/s */ diff --git a/nano/node/transport/tcp_config.hpp b/nano/node/transport/tcp_config.hpp index 30fc2be84..82fece240 100644 --- a/nano/node/transport/tcp_config.hpp +++ b/nano/node/transport/tcp_config.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include @@ -21,6 +22,9 @@ public: } } +public: + // TODO: Serialize/deserialize + public: size_t max_inbound_connections{ 2048 }; size_t max_outbound_connections{ 2048 };