Skip to content

Commit

Permalink
resolve boost::bad_any_cast: failed conversion using boost::any_cast:…
Browse files Browse the repository at this point in the history
… {"what":"boost::bad_any_cast: failed conversion using boost::any_cast"} exception

address manager address parse error
  • Loading branch information
bxliu committed Aug 16, 2023
1 parent a0b35b3 commit 4f36306
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ namespace eosio {

// for IPV6 "[::]:port" address
string::size_type p = address_str[0] == '[' ? address_str.find(']') : 0;

//host and port is necessary
if (p == string::npos) {
throw std::invalid_argument(input_address_str);
}

string::size_type colon = address_str.find(':', p);
//host and port is necessary
if (colon == string::npos) {
throw std::invalid_argument(input_address_str);
}
string::size_type colon2 = address_str.find(':', colon + 1);
string::size_type end = colon2 == string::npos
? string::npos : address_str.find_first_of( " :+=.,<>!$%^&(*)|-#@\t", colon2 + 1 );
Expand Down
16 changes: 7 additions & 9 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4255,8 +4255,8 @@ namespace eosio {
" p2p.eos.io:9876\n"
" p2p.trx.eos.io:9876:trx\n"
" p2p.blk.eos.io:9876:blk\n")
( "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")
( "p2p-max-addresses-per-request", bpo::value<int>()->default_value(def_max_address_per_request), "Maximum number of addresses in address request or sync message")
( "p2p-max-nodes-per-host", bpo::value<uint32_t>()->default_value(def_max_nodes_per_host), "Maximum number of client nodes from any single IP address")
( "p2p-max-addresses-per-request", bpo::value<uint32_t>()->default_value(def_max_address_per_request), "Maximum number of addresses in address request or sync message")
( "p2p-accept-transactions", bpo::value<bool>()->default_value(true), "Allow transactions received over p2p network to be evaluated and relayed if valid.")
( "p2p-only-send-manual-addresses", bpo::value<bool>()->default_value(false), "Only send addresses from configuration instead from automated peer discovery")
( "p2p-auto-bp-peer", bpo::value< vector<string> >()->composing(),
Expand Down Expand Up @@ -4310,25 +4310,23 @@ namespace eosio {

peer_log_format = options.at( "peer-log-format" ).as<string>();


//init address manager, timeout function is yet to be implemented
address_master = std::make_unique<address_manager>(0);

max_addresses_per_request = options.at("p2p-max-addresses-per-request").as<int>();
max_addresses_per_request = options.at("p2p-max-addresses-per-request").as<uint32_t>();
p2p_only_send_manual_addresses = options.at("p2p-only-send-manual-addresses").as<bool>();
min_peers_count = options.at( "min-peers" ).as<int>();
min_peers_count = options.at( "min-peers" ).as<uint32_t>();

sync_master = std::make_unique<sync_manager>(
options.at( "sync-fetch-span" ).as<uint32_t>(),
options.at( "sync-peer-limit" ).as<uint32_t>() );

txn_exp_period = def_txn_expire_wait;
p2p_dedup_cache_expire_time_us = fc::seconds( options.at( "p2p-dedup-cache-expire-time-sec" ).as<uint32_t>() );
resp_expected_period = def_resp_expected_wait;
max_nodes_per_host = options.at( "p2p-max-nodes-per-host" ).as<int>();
max_nodes_per_host = options.at( "p2p-max-nodes-per-host" ).as<uint32_t>();
p2p_accept_transactions = options.at( "p2p-accept-transactions" ).as<bool>();


use_socket_read_watermark = options.at( "use-socket-read-watermark" ).as<bool>();
keepalive_interval = std::chrono::milliseconds( options.at( "p2p-keepalive-interval-ms" ).as<int>() );
EOS_ASSERT( keepalive_interval.count() > 0, chain::plugin_config_exception,
Expand All @@ -4339,7 +4337,7 @@ namespace eosio {
std::chrono::seconds( options.at("connection-cleanup-period").as<int>() ),
options.at("max-clients").as<uint32_t>() );

if( options.count( "p2p-listen-endpoint" )) {
if( options.count( "p2p-listen-endpoint" )) {
auto p2ps = options.at("p2p-listen-endpoint").as<vector<string>>();
if (!p2ps.front().empty()) {
p2p_addresses = p2ps;
Expand Down

0 comments on commit 4f36306

Please sign in to comment.