Merging protocol_constants in to network_constants.
This commit is contained in:
parent
20828e615c
commit
7230b1fad9
25 changed files with 88 additions and 107 deletions
|
|
@ -533,7 +533,7 @@ TEST (bootstrap_processor, lazy_hash)
|
|||
node0->block_processor.flush ();
|
||||
// Start lazy bootstrap with last block in chain known
|
||||
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.logging, system.work));
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
node1->bootstrap_initiator.bootstrap_lazy (receive2->hash (), true);
|
||||
{
|
||||
auto lazy_attempt (node1->bootstrap_initiator.current_lazy_attempt ());
|
||||
|
|
@ -607,7 +607,7 @@ TEST (bootstrap_processor, lazy_hash_bootstrap_id)
|
|||
node0->block_processor.flush ();
|
||||
// Start lazy bootstrap with last block in chain known
|
||||
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.logging, system.work));
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
node1->bootstrap_initiator.bootstrap_lazy (receive2->hash (), true, true, "123456");
|
||||
{
|
||||
auto lazy_attempt (node1->bootstrap_initiator.current_lazy_attempt ());
|
||||
|
|
@ -745,7 +745,7 @@ TEST (bootstrap_processor, lazy_hash_pruning)
|
|||
ASSERT_EQ (5, node1->ledger.cache.block_count);
|
||||
ASSERT_EQ (3, node1->ledger.cache.pruned_count);
|
||||
// Start lazy bootstrap with last block in chain known
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
node1->bootstrap_initiator.bootstrap_lazy (receive3->hash (), true);
|
||||
// Check processed blocks
|
||||
ASSERT_TIMELY (10s, node1->ledger.cache.block_count == 9);
|
||||
|
|
@ -848,7 +848,7 @@ TEST (bootstrap_processor, lazy_max_pull_count)
|
|||
node0->block_processor.flush ();
|
||||
// Start lazy bootstrap with last block in chain known
|
||||
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.logging, system.work));
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
node1->bootstrap_initiator.bootstrap_lazy (change3->hash ());
|
||||
// Check processed blocks
|
||||
ASSERT_TIMELY (10s, node1->block (change3->hash ()));
|
||||
|
|
@ -906,7 +906,7 @@ TEST (bootstrap_processor, lazy_unclear_state_link)
|
|||
ASSERT_EQ (nano::process_result::progress, node1->process (*receive).code);
|
||||
// Start lazy bootstrap with last block in chain known
|
||||
auto node2 = system.add_node (nano::node_config (nano::get_available_port (), system.logging), node_flags);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
node2->bootstrap_initiator.bootstrap_lazy (receive->hash ());
|
||||
// Check processed blocks
|
||||
ASSERT_TIMELY (10s, !node2->bootstrap_initiator.in_progress ());
|
||||
|
|
@ -958,7 +958,7 @@ TEST (bootstrap_processor, lazy_unclear_state_link_not_existing)
|
|||
|
||||
// Start lazy bootstrap with last block in chain known
|
||||
auto node2 = system.add_node (nano::node_config (nano::get_available_port (), system.logging), node_flags);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
node2->bootstrap_initiator.bootstrap_lazy (send2->hash ());
|
||||
// Check processed blocks
|
||||
ASSERT_TIMELY (15s, !node2->bootstrap_initiator.in_progress ());
|
||||
|
|
@ -1020,7 +1020,7 @@ TEST (bootstrap_processor, DISABLED_lazy_destinations)
|
|||
|
||||
// Start lazy bootstrap with last block in sender chain
|
||||
auto node2 = system.add_node (nano::node_config (nano::get_available_port (), system.logging), node_flags);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
node2->bootstrap_initiator.bootstrap_lazy (send2->hash ());
|
||||
// Check processed blocks
|
||||
ASSERT_TIMELY (10s, !node2->bootstrap_initiator.in_progress ());
|
||||
|
|
@ -1098,7 +1098,7 @@ TEST (bootstrap_processor, lazy_pruning_missing_block)
|
|||
// Start lazy bootstrap with last block in sender chain
|
||||
config.peering_port = nano::get_available_port ();
|
||||
auto node2 (std::make_shared<nano::node> (system.io_ctx, nano::unique_path (), config, system.work, node_flags, 1));
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
node2->bootstrap_initiator.bootstrap_lazy (send2->hash ());
|
||||
// Check processed blocks
|
||||
auto lazy_attempt (node2->bootstrap_initiator.current_lazy_attempt ());
|
||||
|
|
@ -1153,7 +1153,7 @@ TEST (bootstrap_processor, lazy_cancel)
|
|||
|
||||
// Start lazy bootstrap with last block in chain known
|
||||
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.logging, system.work));
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
node1->bootstrap_initiator.bootstrap_lazy (send1->hash (), true); // Start "confirmed" block bootstrap
|
||||
{
|
||||
auto lazy_attempt (node1->bootstrap_initiator.current_lazy_attempt ());
|
||||
|
|
@ -1228,7 +1228,7 @@ TEST (bootstrap_processor, wallet_lazy_frontier)
|
|||
node0->block_processor.flush ();
|
||||
// Start wallet lazy bootstrap
|
||||
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.logging, system.work));
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
auto wallet (node1->wallets.create (nano::random_wallet_id ()));
|
||||
ASSERT_NE (nullptr, wallet);
|
||||
wallet->insert_adhoc (key2.prv);
|
||||
|
|
@ -1295,7 +1295,7 @@ TEST (bootstrap_processor, wallet_lazy_pending)
|
|||
node0->block_processor.flush ();
|
||||
// Start wallet lazy bootstrap
|
||||
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.logging, system.work));
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
auto wallet (node1->wallets.create (nano::random_wallet_id ()));
|
||||
ASSERT_NE (nullptr, wallet);
|
||||
wallet->insert_adhoc (key2.prv);
|
||||
|
|
@ -1369,7 +1369,7 @@ TEST (bootstrap_processor, multiple_attempts)
|
|||
nano::node_config node_config (nano::get_available_port (), system.logging);
|
||||
node_config.bootstrap_initiator_threads = 3;
|
||||
auto node2 (std::make_shared<nano::node> (system.io_ctx, nano::unique_path (), node_config, system.work));
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node2->network_params.protocol.protocol_version);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node2->network_params.network.protocol_version);
|
||||
node2->bootstrap_initiator.bootstrap_lazy (receive2->hash (), true);
|
||||
node2->bootstrap_initiator.bootstrap ();
|
||||
auto lazy_attempt (node2->bootstrap_initiator.current_lazy_attempt ());
|
||||
|
|
|
|||
|
|
@ -67,8 +67,8 @@ TEST (message_parser, exact_confirm_ack_size)
|
|||
nano::network_filter filter (1);
|
||||
nano::block_uniquer block_uniquer;
|
||||
nano::vote_uniquer vote_uniquer (block_uniquer);
|
||||
nano::protocol_constants protocol;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, protocol);
|
||||
nano::network_constants network;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, network);
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1))));
|
||||
auto vote (std::make_shared<nano::vote> (0, nano::keypair ().prv, 0, std::move (block)));
|
||||
nano::confirm_ack message (vote);
|
||||
|
|
@ -102,8 +102,8 @@ TEST (message_parser, exact_confirm_req_size)
|
|||
nano::network_filter filter (1);
|
||||
nano::block_uniquer block_uniquer;
|
||||
nano::vote_uniquer vote_uniquer (block_uniquer);
|
||||
nano::protocol_constants protocol;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, protocol);
|
||||
nano::network_constants network;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, network);
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1))));
|
||||
nano::confirm_req message (std::move (block));
|
||||
std::vector<uint8_t> bytes;
|
||||
|
|
@ -136,8 +136,8 @@ TEST (message_parser, exact_confirm_req_hash_size)
|
|||
nano::network_filter filter (1);
|
||||
nano::block_uniquer block_uniquer;
|
||||
nano::vote_uniquer vote_uniquer (block_uniquer);
|
||||
nano::protocol_constants protocol;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, protocol);
|
||||
nano::network_constants network;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, network);
|
||||
nano::send_block block (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1)));
|
||||
nano::confirm_req message (block.hash (), block.root ());
|
||||
std::vector<uint8_t> bytes;
|
||||
|
|
@ -170,8 +170,8 @@ TEST (message_parser, exact_publish_size)
|
|||
nano::network_filter filter (1);
|
||||
nano::block_uniquer block_uniquer;
|
||||
nano::vote_uniquer vote_uniquer (block_uniquer);
|
||||
nano::protocol_constants protocol;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, protocol);
|
||||
nano::network_constants network;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, network);
|
||||
auto block (std::make_shared<nano::send_block> (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1))));
|
||||
nano::publish message (std::move (block));
|
||||
std::vector<uint8_t> bytes;
|
||||
|
|
@ -204,8 +204,8 @@ TEST (message_parser, exact_keepalive_size)
|
|||
nano::network_filter filter (1);
|
||||
nano::block_uniquer block_uniquer;
|
||||
nano::vote_uniquer vote_uniquer (block_uniquer);
|
||||
nano::protocol_constants protocol;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, protocol);
|
||||
nano::network_constants network;
|
||||
nano::message_parser parser (filter, block_uniquer, vote_uniquer, visitor, system.work, network);
|
||||
nano::keepalive message;
|
||||
std::vector<uint8_t> bytes;
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ TEST (network, send_node_id_handshake)
|
|||
system.nodes.push_back (node1);
|
||||
auto initial (node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in));
|
||||
auto initial_node1 (node1->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in));
|
||||
auto channel (std::make_shared<nano::transport::channel_udp> (node0->network.udp_channels, node1->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
auto channel (std::make_shared<nano::transport::channel_udp> (node0->network.udp_channels, node1->network.endpoint (), node1->network_params.network.protocol_version));
|
||||
node0->network.send_keepalive (channel);
|
||||
ASSERT_EQ (0, node0->network.size ());
|
||||
ASSERT_EQ (0, node1->network.size ());
|
||||
|
|
@ -305,7 +305,7 @@ TEST (network, send_insufficient_work_udp)
|
|||
auto & node2 = *system.add_node (node_flags);
|
||||
auto block (std::make_shared<nano::send_block> (0, 1, 20, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0));
|
||||
nano::publish publish (block);
|
||||
nano::transport::channel_udp channel (node1.network.udp_channels, node2.network.endpoint (), node1.network_params.protocol.protocol_version);
|
||||
nano::transport::channel_udp channel (node1.network.udp_channels, node2.network.endpoint (), node1.network_params.network.protocol_version);
|
||||
channel.send (publish, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, node1.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work) != 0);
|
||||
|
|
@ -878,14 +878,14 @@ TEST (network, replace_port)
|
|||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
auto wrong_endpoint = nano::endpoint (node1->network.endpoint ().address (), nano::get_available_port ());
|
||||
auto channel0 (node0->network.udp_channels.insert (wrong_endpoint, node1->network_params.protocol.protocol_version));
|
||||
auto channel0 (node0->network.udp_channels.insert (wrong_endpoint, node1->network_params.network.protocol_version));
|
||||
ASSERT_NE (nullptr, channel0);
|
||||
node0->network.udp_channels.modify (channel0, [&node1] (std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
channel_a->set_node_id (node1->node_id.pub);
|
||||
});
|
||||
auto peers_list (node0->network.list (std::numeric_limits<size_t>::max ()));
|
||||
ASSERT_EQ (peers_list[0]->get_node_id (), node1->node_id.pub);
|
||||
auto channel1 (std::make_shared<nano::transport::channel_udp> (node0->network.udp_channels, node1->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
auto channel1 (std::make_shared<nano::transport::channel_udp> (node0->network.udp_channels, node1->network.endpoint (), node1->network_params.network.protocol_version));
|
||||
ASSERT_EQ (node0->network.udp_channels.size (), 1);
|
||||
node0->network.send_keepalive (channel1);
|
||||
// On handshake, the channel is replaced
|
||||
|
|
@ -941,7 +941,7 @@ TEST (network, duplicate_detection)
|
|||
node_flags.disable_udp = false;
|
||||
auto & node0 (*system.add_node (node_flags));
|
||||
auto & node1 (*system.add_node (node_flags));
|
||||
auto udp_channel (std::make_shared<nano::transport::channel_udp> (node0.network.udp_channels, node1.network.endpoint (), node1.network_params.protocol.protocol_version));
|
||||
auto udp_channel (std::make_shared<nano::transport::channel_udp> (node0.network.udp_channels, node1.network.endpoint (), node1.network_params.network.protocol_version));
|
||||
nano::publish publish (nano::dev::genesis);
|
||||
|
||||
// Publish duplicate detection through UDP
|
||||
|
|
@ -1206,7 +1206,7 @@ TEST (network, cleanup_purge)
|
|||
node1.network.cleanup (test_start);
|
||||
ASSERT_EQ (0, node1.network.size ());
|
||||
|
||||
node1.network.udp_channels.insert (node2->network.endpoint (), node1.network_params.protocol.protocol_version);
|
||||
node1.network.udp_channels.insert (node2->network.endpoint (), node1.network_params.network.protocol_version);
|
||||
ASSERT_EQ (1, node1.network.size ());
|
||||
node1.network.cleanup (test_start);
|
||||
ASSERT_EQ (1, node1.network.size ());
|
||||
|
|
@ -1239,7 +1239,7 @@ TEST (network, loopback_channel)
|
|||
ASSERT_EQ (channel1.get_type (), nano::transport::transport_type::loopback);
|
||||
ASSERT_EQ (channel1.get_endpoint (), node1.network.endpoint ());
|
||||
ASSERT_EQ (channel1.get_tcp_endpoint (), nano::transport::map_endpoint_to_tcp (node1.network.endpoint ()));
|
||||
ASSERT_EQ (channel1.get_network_version (), node1.network_params.protocol.protocol_version);
|
||||
ASSERT_EQ (channel1.get_network_version (), node1.network_params.network.protocol_version);
|
||||
ASSERT_EQ (channel1.get_node_id (), node1.node_id.pub);
|
||||
ASSERT_EQ (channel1.get_node_id_optional ().value_or (0), node1.node_id.pub);
|
||||
nano::transport::channel_loopback channel2 (node2);
|
||||
|
|
|
|||
|
|
@ -536,12 +536,12 @@ TEST (node, connect_after_junk)
|
|||
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.logging, system.work, node_flags));
|
||||
std::vector<uint8_t> junk_buffer;
|
||||
junk_buffer.push_back (0);
|
||||
auto channel1 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
auto channel1 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node1->network_params.network.protocol_version));
|
||||
channel1->send_buffer (nano::shared_const_buffer (std::move (junk_buffer)), [] (boost::system::error_code const &, size_t) {});
|
||||
ASSERT_TIMELY (10s, node0->stats.count (nano::stat::type::error) != 0);
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
auto channel2 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
auto channel2 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node1->network_params.network.protocol_version));
|
||||
node1->network.send_keepalive (channel2);
|
||||
ASSERT_TIMELY (10s, !node1->network.empty ());
|
||||
node1->stop ();
|
||||
|
|
@ -1020,7 +1020,7 @@ TEST (node_flags, disable_udp)
|
|||
ASSERT_EQ (nano::endpoint (boost::asio::ip::address_v6::loopback (), 0), node2->network.udp_channels.get_local_endpoint ());
|
||||
ASSERT_NE (nano::endpoint (boost::asio::ip::address_v6::loopback (), 0), node2->network.endpoint ());
|
||||
// Send UDP message
|
||||
auto channel (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node2->network.endpoint (), node2->network_params.protocol.protocol_version));
|
||||
auto channel (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node2->network.endpoint (), node2->network_params.network.protocol_version));
|
||||
node1->network.send_keepalive (channel);
|
||||
std::this_thread::sleep_for (std::chrono::milliseconds (500));
|
||||
// Check empty network
|
||||
|
|
@ -1618,7 +1618,7 @@ TEST (node, DISABLED_fork_stale)
|
|||
auto & node1 (*system1.nodes[0]);
|
||||
auto & node2 (*system2.nodes[0]);
|
||||
node2.bootstrap_initiator.bootstrap (node1.network.endpoint (), false);
|
||||
std::shared_ptr<nano::transport::channel> channel (std::make_shared<nano::transport::channel_udp> (node2.network.udp_channels, node1.network.endpoint (), node2.network_params.protocol.protocol_version));
|
||||
std::shared_ptr<nano::transport::channel> channel (std::make_shared<nano::transport::channel_udp> (node2.network.udp_channels, node1.network.endpoint (), node2.network_params.network.protocol_version));
|
||||
auto vote = std::make_shared<nano::vote> (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, std::vector<nano::block_hash> ());
|
||||
node2.rep_crawler.response (channel, vote);
|
||||
nano::keypair key1;
|
||||
|
|
@ -2252,8 +2252,8 @@ TEST (node, rep_remove)
|
|||
}
|
||||
// Add inactive UDP representative channel
|
||||
nano::endpoint endpoint0 (boost::asio::ip::address_v6::loopback (), nano::get_available_port ());
|
||||
std::shared_ptr<nano::transport::channel> channel0 (std::make_shared<nano::transport::channel_udp> (node.network.udp_channels, endpoint0, node.network_params.protocol.protocol_version));
|
||||
auto channel_udp = node.network.udp_channels.insert (endpoint0, node.network_params.protocol.protocol_version);
|
||||
std::shared_ptr<nano::transport::channel> channel0 (std::make_shared<nano::transport::channel_udp> (node.network.udp_channels, endpoint0, node.network_params.network.protocol_version));
|
||||
auto channel_udp = node.network.udp_channels.insert (endpoint0, node.network_params.network.protocol_version);
|
||||
auto vote1 = std::make_shared<nano::vote> (keypair1.pub, keypair1.prv, 0, nano::dev::genesis);
|
||||
ASSERT_FALSE (node.rep_crawler.response (channel0, vote1));
|
||||
ASSERT_TIMELY (5s, node.rep_crawler.representative_count () == 1);
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ TEST (peer_container, no_recontact)
|
|||
ASSERT_EQ (0, network.size ());
|
||||
network.channel_observer = [&observed_peer] (std::shared_ptr<nano::transport::channel> const &) { ++observed_peer; };
|
||||
node1.network.disconnect_observer = [&observed_disconnect] () { observed_disconnect = true; };
|
||||
auto channel (network.udp_channels.insert (endpoint1, node1.network_params.protocol.protocol_version));
|
||||
auto channel (network.udp_channels.insert (endpoint1, node1.network_params.network.protocol_version));
|
||||
ASSERT_EQ (1, network.size ());
|
||||
ASSERT_EQ (channel, network.udp_channels.insert (endpoint1, node1.network_params.protocol.protocol_version));
|
||||
ASSERT_EQ (channel, network.udp_channels.insert (endpoint1, node1.network_params.network.protocol_version));
|
||||
node1.network.cleanup (std::chrono::steady_clock::now () + std::chrono::seconds (5));
|
||||
ASSERT_TRUE (network.empty ());
|
||||
ASSERT_EQ (1, observed_peer);
|
||||
|
|
@ -126,7 +126,7 @@ TEST (peer_container, list_fanout)
|
|||
auto list1 (node.network.list (node.network.fanout ()));
|
||||
ASSERT_TRUE (list1.empty ());
|
||||
auto add_peer = [&node] (const uint16_t port_a) {
|
||||
ASSERT_NE (nullptr, node.network.udp_channels.insert (nano::endpoint (boost::asio::ip::address_v6::loopback (), port_a), node.network_params.protocol.protocol_version));
|
||||
ASSERT_NE (nullptr, node.network.udp_channels.insert (nano::endpoint (boost::asio::ip::address_v6::loopback (), port_a), node.network_params.network.protocol_version));
|
||||
};
|
||||
add_peer (9998);
|
||||
ASSERT_EQ (1, node.network.size ());
|
||||
|
|
@ -161,7 +161,7 @@ TEST (peer_container, reachout)
|
|||
auto & node1 = *system.add_node (node_flags);
|
||||
nano::endpoint endpoint0 (boost::asio::ip::address_v6::loopback (), nano::get_available_port ());
|
||||
// Make sure having been contacted by them already indicates we shouldn't reach out
|
||||
node1.network.udp_channels.insert (endpoint0, node1.network_params.protocol.protocol_version);
|
||||
node1.network.udp_channels.insert (endpoint0, node1.network_params.network.protocol_version);
|
||||
ASSERT_TRUE (node1.network.reachout (endpoint0));
|
||||
nano::endpoint endpoint1 (boost::asio::ip::address_v6::loopback (), nano::get_available_port ());
|
||||
ASSERT_FALSE (node1.network.reachout (endpoint1));
|
||||
|
|
|
|||
|
|
@ -604,8 +604,8 @@ TEST (telemetry, remove_peer_different_genesis_udp)
|
|||
node1->network_params.ledger.genesis = junk;
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
auto channel0 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node0->network_params.protocol.protocol_version));
|
||||
auto channel1 (std::make_shared<nano::transport::channel_udp> (node0->network.udp_channels, node1->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
auto channel0 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node0->network_params.network.protocol_version));
|
||||
auto channel1 (std::make_shared<nano::transport::channel_udp> (node0->network.udp_channels, node1->network.endpoint (), node1->network_params.network.protocol_version));
|
||||
node0->network.send_keepalive (channel1);
|
||||
node1->network.send_keepalive (channel0);
|
||||
|
||||
|
|
|
|||
|
|
@ -240,6 +240,10 @@ public:
|
|||
|
||||
/** Initial value is ACTIVE_NETWORK compile flag, but can be overridden by a CLI flag */
|
||||
static nano::networks active_network;
|
||||
/** Current protocol version */
|
||||
uint8_t const protocol_version = 0x12;
|
||||
/** Minimum accepted protocol version */
|
||||
uint8_t const protocol_version_min = 0x12;
|
||||
};
|
||||
|
||||
std::string get_config_path (boost::filesystem::path const & data_path);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ void nano::bootstrap_initiator::bootstrap (nano::endpoint const & endpoint_a, bo
|
|||
{
|
||||
if (!node.flags.disable_udp)
|
||||
{
|
||||
node.network.udp_channels.insert (nano::transport::map_endpoint_to_v6 (endpoint_a), node.network_params.protocol.protocol_version);
|
||||
node.network.udp_channels.insert (nano::transport::map_endpoint_to_v6 (endpoint_a), node.network_params.network.protocol_version);
|
||||
}
|
||||
else if (!node.flags.disable_tcp_realtime)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -670,9 +670,9 @@ public:
|
|||
debug_assert (!nano::validate_message (response->first, *message_a.query, response->second));
|
||||
auto cookie (connection->node->network.syn_cookies.assign (nano::transport::map_tcp_to_endpoint (connection->remote_endpoint)));
|
||||
nano::node_id_handshake response_message (cookie, response);
|
||||
response_message.header.version_max = connection->node->network_params.protocol.protocol_version;
|
||||
response_message.header.version_using = connection->node->network_params.protocol.protocol_version;
|
||||
response_message.header.version_min = connection->node->network_params.protocol.protocol_version_min ();
|
||||
response_message.header.version_max = connection->node->network_params.network.protocol_version;
|
||||
response_message.header.version_using = connection->node->network_params.network.protocol_version;
|
||||
response_message.header.version_min = connection->node->network_params.network.protocol_version_min;
|
||||
auto shared_const_buffer = response_message.to_shared_const_buffer ();
|
||||
connection->socket->async_write (shared_const_buffer, [connection = std::weak_ptr<nano::bootstrap_server> (connection)] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (auto connection_l = connection.lock ())
|
||||
|
|
|
|||
|
|
@ -313,14 +313,14 @@ std::string nano::message_parser::status_string ()
|
|||
return "[unknown parse_status]";
|
||||
}
|
||||
|
||||
nano::message_parser::message_parser (nano::network_filter & publish_filter_a, nano::block_uniquer & block_uniquer_a, nano::vote_uniquer & vote_uniquer_a, nano::message_visitor & visitor_a, nano::work_pool & pool_a, nano::protocol_constants const & protocol) :
|
||||
nano::message_parser::message_parser (nano::network_filter & publish_filter_a, nano::block_uniquer & block_uniquer_a, nano::vote_uniquer & vote_uniquer_a, nano::message_visitor & visitor_a, nano::work_pool & pool_a, nano::network_constants const & network) :
|
||||
publish_filter (publish_filter_a),
|
||||
block_uniquer (block_uniquer_a),
|
||||
vote_uniquer (vote_uniquer_a),
|
||||
visitor (visitor_a),
|
||||
pool (pool_a),
|
||||
status (parse_status::success),
|
||||
protocol{ protocol }
|
||||
network{ network }
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -335,7 +335,7 @@ void nano::message_parser::deserialize_buffer (uint8_t const * buffer_a, size_t
|
|||
nano::message_header header (error, stream);
|
||||
if (!error)
|
||||
{
|
||||
if (header.version_using < protocol.protocol_version_min ())
|
||||
if (header.version_using < network.protocol_version_min)
|
||||
{
|
||||
status = parse_status::outdated_version;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,6 +236,7 @@ public:
|
|||
nano::message_header header;
|
||||
};
|
||||
class work_pool;
|
||||
class network_constants;
|
||||
class message_parser final
|
||||
{
|
||||
public:
|
||||
|
|
@ -255,7 +256,7 @@ public:
|
|||
outdated_version,
|
||||
duplicate_publish_message
|
||||
};
|
||||
message_parser (nano::network_filter &, nano::block_uniquer &, nano::vote_uniquer &, nano::message_visitor &, nano::work_pool &, nano::protocol_constants const & protocol);
|
||||
message_parser (nano::network_filter &, nano::block_uniquer &, nano::vote_uniquer &, nano::message_visitor &, nano::work_pool &, nano::network_constants const & protocol);
|
||||
void deserialize_buffer (uint8_t const *, size_t);
|
||||
void deserialize_keepalive (nano::stream &, nano::message_header const &);
|
||||
void deserialize_publish (nano::stream &, nano::message_header const &, nano::uint128_t const & = 0);
|
||||
|
|
@ -271,7 +272,7 @@ public:
|
|||
nano::message_visitor & visitor;
|
||||
nano::work_pool & pool;
|
||||
parse_status status;
|
||||
nano::protocol_constants const & protocol;
|
||||
nano::network_constants const & network;
|
||||
std::string status_string ();
|
||||
static const size_t max_safe_udp_message_size;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4182,7 +4182,7 @@ void nano::json_handler::version ()
|
|||
{
|
||||
response_l.put ("rpc_version", "1");
|
||||
response_l.put ("store_version", std::to_string (node.store_version ()));
|
||||
response_l.put ("protocol_version", std::to_string (node.network_params.protocol.protocol_version));
|
||||
response_l.put ("protocol_version", std::to_string (node.network_params.network.protocol_version));
|
||||
response_l.put ("node_vendor", boost::str (boost::format ("Nano %1%") % NANO_VERSION_STRING));
|
||||
response_l.put ("store_vendor", node.store.vendor_get ());
|
||||
response_l.put ("network", node.network_params.network.get_current_network_as_string ());
|
||||
|
|
|
|||
|
|
@ -699,11 +699,11 @@ nano::tcp_endpoint nano::network::bootstrap_peer (bool lazy_bootstrap)
|
|||
bool use_udp_peer (nano::random_pool::generate_word32 (0, 1));
|
||||
if (use_udp_peer || tcp_channels.size () == 0)
|
||||
{
|
||||
result = udp_channels.bootstrap_peer (node.network_params.protocol.protocol_version_min ());
|
||||
result = udp_channels.bootstrap_peer (node.network_params.network.protocol_version_min);
|
||||
}
|
||||
if (result == nano::tcp_endpoint (boost::asio::ip::address_v6::any (), 0))
|
||||
{
|
||||
result = tcp_channels.bootstrap_peer (node.network_params.protocol.protocol_version_min ());
|
||||
result = tcp_channels.bootstrap_peer (node.network_params.network.protocol_version_min);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,9 +324,9 @@ void nano::rep_crawler::update_weights ()
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<nano::representative> nano::rep_crawler::representatives (size_t count_a, nano::uint128_t const weight_a, boost::optional<decltype (nano::protocol_constants::protocol_version)> const & opt_version_min_a)
|
||||
std::vector<nano::representative> nano::rep_crawler::representatives (size_t count_a, nano::uint128_t const weight_a, boost::optional<decltype (nano::network_constants::protocol_version)> const & opt_version_min_a)
|
||||
{
|
||||
auto version_min (opt_version_min_a.value_or (node.network_params.protocol.protocol_version_min ()));
|
||||
auto version_min (opt_version_min_a.value_or (node.network_params.network.protocol_version_min));
|
||||
std::vector<representative> result;
|
||||
nano::lock_guard<nano::mutex> lock (probable_reps_mutex);
|
||||
for (auto i (probable_reps.get<tag_weight> ().begin ()), n (probable_reps.get<tag_weight> ().end ()); i != n && result.size () < count_a; ++i)
|
||||
|
|
@ -339,7 +339,7 @@ std::vector<nano::representative> nano::rep_crawler::representatives (size_t cou
|
|||
return result;
|
||||
}
|
||||
|
||||
std::vector<nano::representative> nano::rep_crawler::principal_representatives (size_t count_a, boost::optional<decltype (nano::protocol_constants::protocol_version)> const & opt_version_min_a)
|
||||
std::vector<nano::representative> nano::rep_crawler::principal_representatives (size_t count_a, boost::optional<decltype (nano::network_constants::protocol_version)> const & opt_version_min_a)
|
||||
{
|
||||
return representatives (count_a, node.minimum_principal_weight (), opt_version_min_a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,10 +106,10 @@ public:
|
|||
nano::uint128_t total_weight () const;
|
||||
|
||||
/** Request a list of the top \p count_a known representatives in descending order of weight, with at least \p weight_a voting weight, and optionally with a minimum version \p opt_version_min_a */
|
||||
std::vector<representative> representatives (size_t count_a = std::numeric_limits<size_t>::max (), nano::uint128_t const weight_a = 0, boost::optional<decltype (nano::protocol_constants::protocol_version)> const & opt_version_min_a = boost::none);
|
||||
std::vector<representative> representatives (size_t count_a = std::numeric_limits<size_t>::max (), nano::uint128_t const weight_a = 0, boost::optional<decltype (nano::network_constants::protocol_version)> const & opt_version_min_a = boost::none);
|
||||
|
||||
/** Request a list of the top \p count_a known principal representatives in descending order of weight, optionally with a minimum version \p opt_version_min_a */
|
||||
std::vector<representative> principal_representatives (size_t count_a = std::numeric_limits<size_t>::max (), boost::optional<decltype (nano::protocol_constants::protocol_version)> const & opt_version_min_a = boost::none);
|
||||
std::vector<representative> principal_representatives (size_t count_a = std::numeric_limits<size_t>::max (), boost::optional<decltype (nano::network_constants::protocol_version)> const & opt_version_min_a = boost::none);
|
||||
|
||||
/** Request a list of the top \p count_a known representative endpoints. */
|
||||
std::vector<std::shared_ptr<nano::transport::channel>> representative_endpoints (size_t count_a);
|
||||
|
|
|
|||
|
|
@ -631,7 +631,7 @@ nano::telemetry_data nano::local_telemetry_data (nano::ledger const & ledger_a,
|
|||
telemetry_data.block_count = ledger_a.cache.block_count;
|
||||
telemetry_data.cemented_count = ledger_a.cache.cemented_count;
|
||||
telemetry_data.bandwidth_cap = bandwidth_limit_a;
|
||||
telemetry_data.protocol_version = network_params_a.protocol.protocol_version;
|
||||
telemetry_data.protocol_version = network_params_a.network.protocol_version;
|
||||
telemetry_data.uptime = std::chrono::duration_cast<std::chrono::seconds> (std::chrono::steady_clock::now () - statup_time_a).count ();
|
||||
telemetry_data.unchecked_count = ledger_a.store.unchecked.count (ledger_a.store.tx_begin_read ());
|
||||
telemetry_data.genesis_block = network_params_a.ledger.genesis->hash ();
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ void nano::transport::tcp_channels::process_messages ()
|
|||
void nano::transport::tcp_channels::process_message (nano::message const & message_a, nano::tcp_endpoint const & endpoint_a, nano::account const & node_id_a, std::shared_ptr<nano::socket> const & socket_a)
|
||||
{
|
||||
auto type_a = socket_a->type ();
|
||||
if (!stopped && message_a.header.version_using >= protocol_constants ().protocol_version_min ())
|
||||
if (!stopped && message_a.header.version_using >= node.network_params.network.protocol_version_min)
|
||||
{
|
||||
auto channel (node.network.find_channel (nano::transport::map_tcp_to_endpoint (endpoint_a)));
|
||||
if (channel)
|
||||
|
|
@ -433,7 +433,7 @@ void nano::transport::tcp_channels::purge (std::chrono::steady_clock::time_point
|
|||
attempts.get<last_attempt_tag> ().erase (attempts.get<last_attempt_tag> ().begin (), attempts_cutoff);
|
||||
|
||||
// Check if any tcp channels belonging to old protocol versions which may still be alive due to async operations
|
||||
auto lower_bound = channels.get<version_tag> ().lower_bound (node.network_params.protocol.protocol_version_min ());
|
||||
auto lower_bound = channels.get<version_tag> ().lower_bound (node.network_params.network.protocol_version_min);
|
||||
channels.get<version_tag> ().erase (channels.get<version_tag> ().begin (), lower_bound);
|
||||
|
||||
// Cleanup any sockets which may still be existing from failed node id handshakes
|
||||
|
|
@ -467,7 +467,7 @@ void nano::transport::tcp_channels::ongoing_keepalive ()
|
|||
size_t random_count (std::min (static_cast<size_t> (6), static_cast<size_t> (std::ceil (std::sqrt (node.network.udp_channels.size ())))));
|
||||
for (auto i (0); i <= random_count; ++i)
|
||||
{
|
||||
auto tcp_endpoint (node.network.udp_channels.bootstrap_peer (node.network_params.protocol.protocol_version_min ()));
|
||||
auto tcp_endpoint (node.network.udp_channels.bootstrap_peer (node.network_params.network.protocol_version_min));
|
||||
if (tcp_endpoint != invalid_endpoint && find_channel (tcp_endpoint) == nullptr && !node.network.excluded_peers.check (tcp_endpoint))
|
||||
{
|
||||
start_tcp (nano::transport::map_tcp_to_endpoint (tcp_endpoint));
|
||||
|
|
@ -646,7 +646,7 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
|||
nano::message_header header (error, stream);
|
||||
if (!error && header.type == nano::message_type::node_id_handshake)
|
||||
{
|
||||
if (header.version_using >= node_l->network_params.protocol.protocol_version_min ())
|
||||
if (header.version_using >= node_l->network_params.network.protocol_version_min)
|
||||
{
|
||||
nano::node_id_handshake message (error, stream, header);
|
||||
if (!error && message.response && message.query)
|
||||
|
|
|
|||
|
|
@ -97,14 +97,14 @@ boost::asio::ip::address nano::transport::ipv4_address_or_ipv6_subnet (boost::as
|
|||
nano::transport::channel::channel (nano::node & node_a) :
|
||||
node (node_a)
|
||||
{
|
||||
set_network_version (node_a.network_params.protocol.protocol_version);
|
||||
set_network_version (node_a.network_params.network.protocol_version);
|
||||
}
|
||||
|
||||
void nano::transport::channel::send (nano::message & message_a, std::function<void (boost::system::error_code const &, size_t)> const & callback_a, nano::buffer_drop_policy drop_policy_a)
|
||||
{
|
||||
message_a.header.version_max = node.network_params.protocol.protocol_version;
|
||||
message_a.header.version_using = node.network_params.protocol.protocol_version;
|
||||
message_a.header.version_min = node.network_params.protocol.protocol_version_min ();
|
||||
message_a.header.version_max = node.network_params.network.protocol_version;
|
||||
message_a.header.version_using = node.network_params.network.protocol_version;
|
||||
message_a.header.version_min = node.network_params.network.protocol_version_min;
|
||||
callback_visitor visitor;
|
||||
message_a.visit (visitor);
|
||||
auto buffer (message_a.to_shared_const_buffer ());
|
||||
|
|
@ -138,7 +138,7 @@ nano::transport::channel_loopback::channel_loopback (nano::node & node_a) :
|
|||
channel (node_a), endpoint (node_a.network.endpoint ())
|
||||
{
|
||||
set_node_id (node_a.node_id.pub);
|
||||
set_network_version (node_a.network_params.protocol.protocol_version);
|
||||
set_network_version (node_a.network_params.network.protocol_version);
|
||||
}
|
||||
|
||||
size_t nano::transport::channel_loopback::hash_code () const
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ public:
|
|||
else if (!node.network.tcp_channels.find_channel (nano::transport::map_endpoint_to_tcp (endpoint)))
|
||||
{
|
||||
// Don't start connection if TCP channel to same IP:port exists
|
||||
find_channel = std::make_shared<nano::transport::channel_udp> (node.network.udp_channels, endpoint, node.network_params.protocol.protocol_version);
|
||||
find_channel = std::make_shared<nano::transport::channel_udp> (node.network.udp_channels, endpoint, node.network_params.network.protocol_version);
|
||||
node.network.send_node_id_handshake (find_channel, *cookie, boost::none);
|
||||
}
|
||||
}
|
||||
|
|
@ -500,7 +500,7 @@ public:
|
|||
auto find_channel (node.network.udp_channels.channel (endpoint));
|
||||
if (!find_channel)
|
||||
{
|
||||
find_channel = std::make_shared<nano::transport::channel_udp> (node.network.udp_channels, endpoint, node.network_params.protocol.protocol_version);
|
||||
find_channel = std::make_shared<nano::transport::channel_udp> (node.network.udp_channels, endpoint, node.network_params.network.protocol_version);
|
||||
}
|
||||
node.network.send_node_id_handshake (find_channel, out_query, out_respond_to);
|
||||
}
|
||||
|
|
@ -541,7 +541,7 @@ void nano::transport::udp_channels::receive_action (nano::message_buffer * data_
|
|||
if (allowed_sender)
|
||||
{
|
||||
udp_message_visitor visitor (node, data_a->endpoint, sink);
|
||||
nano::message_parser parser (node.network.publish_filter, node.block_uniquer, node.vote_uniquer, visitor, node.work, node.network_params.protocol);
|
||||
nano::message_parser parser (node.network.publish_filter, node.block_uniquer, node.vote_uniquer, visitor, node.work, node.network_params.network);
|
||||
parser.deserialize_buffer (data_a->buffer, data_a->size);
|
||||
if (parser.status == nano::message_parser::parse_status::success)
|
||||
{
|
||||
|
|
@ -625,7 +625,7 @@ void nano::transport::udp_channels::process_packets ()
|
|||
|
||||
std::shared_ptr<nano::transport::channel> nano::transport::udp_channels::create (nano::endpoint const & endpoint_a)
|
||||
{
|
||||
return std::make_shared<nano::transport::channel_udp> (*this, endpoint_a, node.network_params.protocol.protocol_version);
|
||||
return std::make_shared<nano::transport::channel_udp> (*this, endpoint_a, node.network_params.network.protocol_version);
|
||||
}
|
||||
|
||||
bool nano::transport::udp_channels::max_ip_connections (nano::endpoint const & endpoint_a)
|
||||
|
|
|
|||
|
|
@ -1688,18 +1688,18 @@ TEST (rpc, peers)
|
|||
auto port = nano::get_available_port ();
|
||||
system.add_node (nano::node_config (port, system.logging));
|
||||
nano::endpoint endpoint (boost::asio::ip::make_address_v6 ("fc00::1"), 4000);
|
||||
node->network.udp_channels.insert (endpoint, node->network_params.protocol.protocol_version);
|
||||
node->network.udp_channels.insert (endpoint, node->network_params.network.protocol_version);
|
||||
auto [rpc, rpc_ctx] = add_rpc (system, node);
|
||||
boost::property_tree::ptree request;
|
||||
request.put ("action", "peers");
|
||||
auto response (wait_response (system, rpc, request));
|
||||
auto & peers_node (response.get_child ("peers"));
|
||||
ASSERT_EQ (2, peers_node.size ());
|
||||
ASSERT_EQ (std::to_string (node->network_params.protocol.protocol_version), peers_node.get<std::string> ((boost::format ("[::1]:%1%") % port).str ()));
|
||||
ASSERT_EQ (std::to_string (node->network_params.network.protocol_version), peers_node.get<std::string> ((boost::format ("[::1]:%1%") % port).str ()));
|
||||
// Previously "[::ffff:80.80.80.80]:4000", but IPv4 address cause "No such node thrown in the test body" issue with peers_node.get
|
||||
std::stringstream endpoint_text;
|
||||
endpoint_text << endpoint;
|
||||
ASSERT_EQ (std::to_string (node->network_params.protocol.protocol_version), peers_node.get<std::string> (endpoint_text.str ()));
|
||||
ASSERT_EQ (std::to_string (node->network_params.network.protocol_version), peers_node.get<std::string> (endpoint_text.str ()));
|
||||
}
|
||||
|
||||
TEST (rpc, peers_node_id)
|
||||
|
|
@ -1709,7 +1709,7 @@ TEST (rpc, peers_node_id)
|
|||
auto port = nano::get_available_port ();
|
||||
system.add_node (nano::node_config (port, system.logging));
|
||||
nano::endpoint endpoint (boost::asio::ip::make_address_v6 ("fc00::1"), 4000);
|
||||
node->network.udp_channels.insert (endpoint, node->network_params.protocol.protocol_version);
|
||||
node->network.udp_channels.insert (endpoint, node->network_params.network.protocol_version);
|
||||
auto [rpc, rpc_ctx] = add_rpc (system, node);
|
||||
boost::property_tree::ptree request;
|
||||
request.put ("action", "peers");
|
||||
|
|
@ -1718,12 +1718,12 @@ TEST (rpc, peers_node_id)
|
|||
auto & peers_node (response.get_child ("peers"));
|
||||
ASSERT_EQ (2, peers_node.size ());
|
||||
auto tree1 (peers_node.get_child ((boost::format ("[::1]:%1%") % port).str ()));
|
||||
ASSERT_EQ (std::to_string (node->network_params.protocol.protocol_version), tree1.get<std::string> ("protocol_version"));
|
||||
ASSERT_EQ (std::to_string (node->network_params.network.protocol_version), tree1.get<std::string> ("protocol_version"));
|
||||
ASSERT_EQ (system.nodes[1]->node_id.pub.to_node_id (), tree1.get<std::string> ("node_id"));
|
||||
std::stringstream endpoint_text;
|
||||
endpoint_text << endpoint;
|
||||
auto tree2 (peers_node.get_child (endpoint_text.str ()));
|
||||
ASSERT_EQ (std::to_string (node->network_params.protocol.protocol_version), tree2.get<std::string> ("protocol_version"));
|
||||
ASSERT_EQ (std::to_string (node->network_params.network.protocol_version), tree2.get<std::string> ("protocol_version"));
|
||||
ASSERT_EQ ("", tree2.get<std::string> ("node_id"));
|
||||
}
|
||||
|
||||
|
|
@ -1909,7 +1909,7 @@ TEST (rpc, version)
|
|||
auto transaction (node1->store.tx_begin_read ());
|
||||
ASSERT_EQ (std::to_string (node1->store.version.get (transaction)), response1.json.get<std::string> ("store_version"));
|
||||
}
|
||||
ASSERT_EQ (std::to_string (node1->network_params.protocol.protocol_version), response1.json.get<std::string> ("protocol_version"));
|
||||
ASSERT_EQ (std::to_string (node1->network_params.network.protocol_version), response1.json.get<std::string> ("protocol_version"));
|
||||
ASSERT_EQ (boost::str (boost::format ("Nano %1%") % NANO_VERSION_STRING), response1.json.get<std::string> ("node_vendor"));
|
||||
ASSERT_EQ (node1->store.vendor_get (), response1.json.get<std::string> ("store_vendor"));
|
||||
auto network_label (node1->network_params.network.get_current_network_as_string ());
|
||||
|
|
@ -5828,7 +5828,7 @@ TEST (rpc, account_lazy_start)
|
|||
node_config.ipc_config.transport_tcp.enabled = true;
|
||||
node_config.ipc_config.transport_tcp.port = nano::get_available_port ();
|
||||
auto node2 = system.add_node (node_config, node_flags);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.network.protocol_version);
|
||||
auto [rpc, rpc_ctx] = add_rpc (system, node2);
|
||||
boost::property_tree::ptree request;
|
||||
request.put ("action", "account_info");
|
||||
|
|
|
|||
|
|
@ -93,11 +93,6 @@ nano::network_params::network_params (nano::networks network_a) :
|
|||
kdf_work = network.is_dev_network () ? kdf_dev_work : kdf_full_work;
|
||||
}
|
||||
|
||||
uint8_t nano::protocol_constants::protocol_version_min () const
|
||||
{
|
||||
return protocol_version_min_m;
|
||||
}
|
||||
|
||||
nano::ledger_constants::ledger_constants (nano::network_constants & network_constants) :
|
||||
ledger_constants (network_constants.network ())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -336,24 +336,6 @@ enum class tally_result
|
|||
|
||||
class network_params;
|
||||
|
||||
/** Protocol versions whose value may depend on the active network */
|
||||
class protocol_constants
|
||||
{
|
||||
public:
|
||||
/** Current protocol version */
|
||||
uint8_t const protocol_version = 0x12;
|
||||
|
||||
/** Minimum accepted protocol version */
|
||||
uint8_t protocol_version_min () const;
|
||||
|
||||
private:
|
||||
/* Minimum protocol version we will establish connections to */
|
||||
uint8_t const protocol_version_min_m = 0x12;
|
||||
};
|
||||
|
||||
// Some places use the decltype of protocol_version instead of protocol_version_min. To keep those checks simpler we check that the decltypes match ignoring differences in const
|
||||
static_assert (std::is_same<std::remove_const_t<decltype (protocol_constants ().protocol_version)>, decltype (protocol_constants ().protocol_version_min ())>::value, "protocol_min should match");
|
||||
|
||||
/** Genesis keys and ledger constants for network variants */
|
||||
class ledger_constants
|
||||
{
|
||||
|
|
@ -458,7 +440,6 @@ public:
|
|||
|
||||
unsigned kdf_work;
|
||||
network_constants network;
|
||||
protocol_constants protocol;
|
||||
ledger_constants ledger;
|
||||
random_constants random;
|
||||
voting_constants voting;
|
||||
|
|
|
|||
|
|
@ -1483,7 +1483,7 @@ TEST (telemetry, many_nodes)
|
|||
ASSERT_LE (data.peer_count, 9U);
|
||||
ASSERT_EQ (data.account_count, 1);
|
||||
ASSERT_TRUE (data.block_count == 2);
|
||||
ASSERT_EQ (data.protocol_version, nano::dev::network_params.protocol.protocol_version);
|
||||
ASSERT_EQ (data.protocol_version, nano::dev::network_params.network.protocol_version);
|
||||
ASSERT_GE (data.bandwidth_cap, 100000);
|
||||
ASSERT_LT (data.bandwidth_cap, 100000 + system.nodes.size ());
|
||||
ASSERT_EQ (data.major_version, nano::get_major_node_version ());
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ std::shared_ptr<nano::node> nano::system::add_node (nano::node_config const & no
|
|||
else
|
||||
{
|
||||
// UDP connection
|
||||
auto channel (std::make_shared<nano::transport::channel_udp> ((*j)->network.udp_channels, (*i)->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
auto channel (std::make_shared<nano::transport::channel_udp> ((*j)->network.udp_channels, (*i)->network.endpoint (), node1->network_params.network.protocol_version));
|
||||
(*j)->network.send_keepalive (channel);
|
||||
}
|
||||
do
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ void nano::compare_default_telemetry_response_data_excluding_signature (nano::te
|
|||
ASSERT_EQ (telemetry_data_a.cemented_count, 1);
|
||||
ASSERT_EQ (telemetry_data_a.bandwidth_cap, bandwidth_limit_a);
|
||||
ASSERT_EQ (telemetry_data_a.peer_count, 1);
|
||||
ASSERT_EQ (telemetry_data_a.protocol_version, network_params_a.protocol.protocol_version);
|
||||
ASSERT_EQ (telemetry_data_a.protocol_version, network_params_a.network.protocol_version);
|
||||
ASSERT_EQ (telemetry_data_a.unchecked_count, 0);
|
||||
ASSERT_EQ (telemetry_data_a.account_count, 1);
|
||||
ASSERT_LT (telemetry_data_a.uptime, 100);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue