Converting node_id_handshake from unnecessarily using channel::send_buffer to using channel::send

This commit is contained in:
clemahieu 2021-08-03 12:38:42 +01:00
commit 4a737c4bee
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
2 changed files with 3 additions and 4 deletions

View file

@ -572,8 +572,8 @@ TEST (telemetry, remove_peer_different_genesis)
ASSERT_TIMELY (1s, 0 == node0->network.size ());
ASSERT_TIMELY (1s, 0 == node1->network.size ());
ASSERT_EQ (node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::out), 1);
ASSERT_EQ (node1->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::out), 1);
ASSERT_GE (node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::out), 1);
ASSERT_GE (node1->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::out), 1);
nano::lock_guard<nano::mutex> guard (node0->network.excluded_peers.mutex);
ASSERT_EQ (1, node0->network.excluded_peers.peers.get<nano::peer_exclusion::tag_endpoint> ().count (node1->network.endpoint ().address ()));

View file

@ -572,7 +572,6 @@ void nano::transport::tcp_channels::start_tcp (nano::endpoint const & endpoint_a
// TCP node ID handshake
auto cookie (node_l->network.syn_cookies.assign (endpoint_a));
nano::node_id_handshake message (cookie, boost::none);
auto bytes = message.to_shared_const_buffer ();
if (node_l->config.logging.network_node_id_handshake_logging ())
{
node_l->logger.try_log (boost::str (boost::format ("Node ID handshake request sent with node ID %1% to %2%: query %3%") % node_l->node_id.pub.to_node_id () % endpoint_a % (*cookie).to_string ()));
@ -581,7 +580,7 @@ void nano::transport::tcp_channels::start_tcp (nano::endpoint const & endpoint_a
std::shared_ptr<std::vector<uint8_t>> receive_buffer (std::make_shared<std::vector<uint8_t>> ());
receive_buffer->resize (256);
node_l->network.tcp_channels.push_node_id_handshake_socket (socket);
channel->send_buffer (bytes, [node_w, channel, endpoint_a, receive_buffer, callback_a] (boost::system::error_code const & ec, size_t size_a) {
channel->send (message, [node_w, channel, endpoint_a, receive_buffer, callback_a] (boost::system::error_code const & ec, size_t size_a) {
if (auto node_l = node_w.lock ())
{
if (!ec)