Skip to content

Commit 85e066b

Browse files
committed
GH-1155 Update p2p-peer-limit assert and warning
1 parent 1ad869c commit 85e066b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

plugins/net_plugin/net_plugin.cpp

+7-11
Original file line numberDiff line numberDiff line change
@@ -4364,7 +4364,7 @@ namespace eosio {
43644364
" p2p.trx.eos.io:9876:trx\n"
43654365
" p2p.blk.eos.io:9876:blk\n")
43664366
( "p2p-peer-limit", bpo::value<uint16_t>()->default_value(6),
4367-
"Soft limit on the number of p2p-peer-address to remain connected to. Selects the best peers of p2p-peer-address-list.")
4367+
"Soft limit on the number of p2p-peer-address to remain connected to. Selects the best peers of p2p-peer-address list.")
43684368
( "p2p-max-nodes-per-host", bpo::value<int>()->default_value(def_max_nodes_per_host), "Maximum number of client nodes from any single IP address")
43694369
( "p2p-accept-transactions", bpo::value<bool>()->default_value(true), "Allow transactions received over p2p network to be evaluated and relayed if valid.")
43704370
( "p2p-disable-block-nack", bpo::value<bool>()->default_value(false),
@@ -4427,19 +4427,10 @@ namespace eosio {
44274427
resp_expected_period = def_resp_expected_wait;
44284428
max_nodes_per_host = options.at( "p2p-max-nodes-per-host" ).as<int>();
44294429
p2p_peer_limit = options.at("p2p-peer-limit").as<uint16_t>();
4430+
EOS_ASSERT( p2p_peer_limit >= 1, chain::plugin_config_exception, "p2p-peer-limit should be >= 1");
44304431
p2p_accept_transactions = options.at( "p2p-accept-transactions" ).as<bool>();
44314432
p2p_disable_block_nack = options.at( "p2p-disable-block-nack" ).as<bool>();
44324433

4433-
if (p2p_accept_transactions || chain_plug->accept_votes()) {
4434-
if (p2p_accept_transactions && chain_plug->accept_votes()) {
4435-
EOS_ASSERT( p2p_peer_limit >= 6, chain::plugin_config_exception,
4436-
"p2p-peer-limit with vote processing and trx processing should be >= 6, two connections each reserved for votes and trxs.");
4437-
} else {
4438-
EOS_ASSERT( p2p_peer_limit >= 4, chain::plugin_config_exception,
4439-
"p2p-peer-limit with vote processing or trx processing should be >= 4, two connections reserved for vote or trx processing");
4440-
}
4441-
}
4442-
44434434
use_socket_read_watermark = options.at( "use-socket-read-watermark" ).as<bool>();
44444435
keepalive_interval = std::chrono::milliseconds( options.at( "p2p-keepalive-interval-ms" ).as<int>() );
44454436
EOS_ASSERT( keepalive_interval.count() > 0, chain::plugin_config_exception,
@@ -4505,6 +4496,11 @@ namespace eosio {
45054496
}
45064497
connections.add_supplied_peers(peers);
45074498
}
4499+
4500+
if (peers.size() > p2p_peer_limit && p2p_accept_transactions) {
4501+
fc_wlog(logger, "p2p-peer-limit=${n} ignored due to p2p-accept-transactions=true", ("n", p2p_peer_limit));
4502+
}
4503+
45084504
if( options.count( "agent-name" )) {
45094505
user_agent_name = options.at( "agent-name" ).as<string>();
45104506
EOS_ASSERT( user_agent_name.length() <= max_handshake_str_length, chain::plugin_config_exception,

0 commit comments

Comments
 (0)