Skip to content

Commit

Permalink
Rename set_endpoint to update_endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 18, 2024
1 parent 55f06c0 commit c4aa597
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion nano/node/bootstrap/bootstrap_connections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ nano::bootstrap_client::bootstrap_client (std::shared_ptr<nano::node> const & no
{
++node_a->bootstrap_initiator.connections->connections_count;
receive_buffer->resize (256);
channel->set_endpoint ();
channel->update_endpoint ();
}

nano::bootstrap_client::~bootstrap_client ()
Expand Down
15 changes: 2 additions & 13 deletions nano/node/transport/tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,6 @@ std::string nano::transport::channel_tcp::to_string () const
return nano::util::to_str (get_tcp_endpoint ());
}

void nano::transport::channel_tcp::set_endpoint ()
{
nano::lock_guard<nano::mutex> lk{ channel_mutex };
debug_assert (endpoint == nano::tcp_endpoint (boost::asio::ip::address_v6::any (), 0)); // Not initialized endpoint value
// Calculate TCP socket endpoint
if (auto socket_l = socket.lock ())
{
endpoint = socket_l->remote_endpoint ();
}
}

void nano::transport::channel_tcp::operator() (nano::object_stream & obs) const
{
nano::transport::channel::operator() (obs); // Write common data
Expand Down Expand Up @@ -350,7 +339,7 @@ void nano::transport::tcp_channels::process_message (nano::message const & messa
{
// Add temporary channel
auto temporary_channel (std::make_shared<nano::transport::channel_tcp> (node, socket_a));
temporary_channel->set_endpoint ();
temporary_channel->update_endpoint ();
debug_assert (endpoint_a == temporary_channel->get_tcp_endpoint ());
temporary_channel->set_node_id (node_id_a);
temporary_channel->set_network_version (message_a.header.version_using);
Expand Down Expand Up @@ -608,7 +597,7 @@ void nano::transport::tcp_channels::start_tcp (nano::endpoint const & endpoint_a
nano::util::to_str (endpoint_a),
(query ? query->cookie.to_string () : "<none>"));

channel->set_endpoint ();
channel->update_endpoint ();
std::shared_ptr<std::vector<uint8_t>> receive_buffer (std::make_shared<std::vector<uint8_t>> ());
receive_buffer->resize (256);
channel->send (message, [node_w, channel, endpoint_a, receive_buffer] (boost::system::error_code const & ec, std::size_t size_a) {
Expand Down
10 changes: 9 additions & 1 deletion nano/node/transport/tcp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ namespace transport

std::string to_string () const override;

void set_endpoint ();
void update_endpoint ()
{
nano::lock_guard<nano::mutex> lk (channel_mutex);
debug_assert (endpoint == nano::tcp_endpoint (boost::asio::ip::address_v6::any (), 0)); // Not initialized endpoint value
if (auto socket_l = socket.lock ())
{
endpoint = socket_l->remote_endpoint ();
}
}

nano::endpoint get_endpoint () const override
{
Expand Down

0 comments on commit c4aa597

Please sign in to comment.