diff --git a/nano/node/nodeconfig.cpp b/nano/node/nodeconfig.cpp index ca9bda367..ee5d2c531 100644 --- a/nano/node/nodeconfig.cpp +++ b/nano/node/nodeconfig.cpp @@ -34,6 +34,7 @@ nano::node_config::node_config (const std::optional & peering_port_a, ipc_config{ network_params.network }, external_address{ boost::asio::ip::address_v6{}.to_string () }, rep_crawler{ network_params.network }, + active_transactions{ network_params.network }, block_processor{ network_params.network }, peer_history{ network_params.network }, tcp{ network_params.network } @@ -119,9 +120,7 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const 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 ("confirmation_history_size", confirmation_history_size, "Maximum confirmation history size. If tracking the rate of block confirmations, the websocket feature is recommended instead.\ntype:uint64"); - toml.put ("active_elections_size", active_elections_size, "Number of active elections. Elections beyond this limit have limited survival time.\nWarning: modifying this value may result in a lower confirmation rate.\ntype:uint64,[250..]"); - + 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"); toml.put ("bandwidth_limit_burst_ratio", bandwidth_limit_burst_ratio, "Burst ratio for outbound traffic shaping.\ntype:double"); @@ -218,6 +217,10 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const rep_crawler.serialize (rep_crawler_l); toml.put_child ("rep_crawler", rep_crawler_l); + nano::tomlconfig active_transactions_l; + active_transactions.serialize (active_transactions_l); + toml.put_child ("active_transactions", active_transactions_l); + nano::tomlconfig block_processor_l; block_processor.serialize (block_processor_l); toml.put_child ("block_processor", block_processor_l); @@ -311,6 +314,12 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml) rep_crawler.deserialize (config_l); } + if (toml.has_key ("active_transactions")) + { + auto config_l = toml.get_required_child ("active_transactions"); + active_transactions.deserialize (config_l); + } + if (toml.has_key ("block_processor")) { auto config_l = toml.get_required_child ("block_processor"); @@ -459,9 +468,7 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml) toml.get (pow_sleep_interval_key, pow_sleep_interval_l); pow_sleep_interval = std::chrono::nanoseconds (pow_sleep_interval_l); toml.get ("use_memory_pools", use_memory_pools); - toml.get ("confirmation_history_size", confirmation_history_size); - toml.get ("active_elections_size", active_elections_size); - + toml.get ("bandwidth_limit", bandwidth_limit); toml.get ("bandwidth_limit_burst_ratio", bandwidth_limit_burst_ratio); @@ -524,9 +531,9 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml) { toml.get_error ().set ("io_threads must be non-zero"); } - if (active_elections_size <= 250 && !network_params.network.is_dev_network ()) + if (active_transactions.size <= 250 && !network_params.network.is_dev_network ()) { - toml.get_error ().set ("active_elections_size must be greater than 250"); + toml.get_error ().set ("active_transactions.size must be greater than 250"); } if (bandwidth_limit > std::numeric_limits::max ()) { diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index 8f2defda7..a8ec08b4b 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -90,7 +91,6 @@ public: uint32_t bootstrap_frontier_request_count{ 1024 * 1024 }; nano::websocket::config websocket_config; nano::diagnostics_config diagnostics_config; - std::size_t confirmation_history_size{ 2048 }; std::string callback_address; uint16_t callback_port{ 0 }; std::string callback_target; @@ -104,12 +104,7 @@ public: /** Timeout for initiated async operations */ 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 }; - // TODO: Move related settings to `active_transactions_config` class - std::size_t active_elections_size{ 5000 }; - /** Limit of hinted elections as percentage of `active_elections_size` */ - std::size_t active_elections_hinted_limit_percentage{ 20 }; - /** Limit of optimistic elections as percentage of `active_elections_size` */ - std::size_t active_elections_optimistic_limit_percentage{ 10 }; + /** Default maximum incoming TCP connections, including realtime network & bootstrap */ unsigned tcp_incoming_connections_max{ 2048 }; bool use_memory_pools{ true }; @@ -142,6 +137,7 @@ public: nano::vote_cache_config vote_cache; nano::rep_crawler_config rep_crawler; nano::block_processor_config block_processor; + nano::active_transactions_config active_transactions; nano::vote_processor_config vote_processor; nano::peer_history_config peer_history; nano::transport::tcp_config tcp;