From a09a3a32bceb9952cc1f496e182b2ed4c93eec02 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Thu, 2 Sep 2021 10:25:16 +0100 Subject: [PATCH] nano::bootstrap_connections is composed of nano::bootstrap_connection. Convert nano::bootstrap_connection::connections to a reference since it doesn't manage lifetime. (#3435) --- nano/node/bootstrap/bootstrap_bulk_pull.cpp | 6 +++--- nano/node/bootstrap/bootstrap_connections.cpp | 8 ++++---- nano/node/bootstrap/bootstrap_connections.hpp | 4 ++-- nano/node/bootstrap/bootstrap_frontier.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/nano/node/bootstrap/bootstrap_bulk_pull.cpp b/nano/node/bootstrap/bootstrap_bulk_pull.cpp index 53301c148..9f6178d3f 100644 --- a/nano/node/bootstrap/bootstrap_bulk_pull.cpp +++ b/nano/node/bootstrap/bootstrap_bulk_pull.cpp @@ -187,7 +187,7 @@ void nano::bulk_pull_client::received_type () // Avoid re-using slow peers, or peers that sent the wrong blocks. if (!connection->pending_stop && (expected == pull.end || (pull.count != 0 && pull.count == pull_blocks))) { - connection->connections->pool_connection (connection); + connection->connections.pool_connection (connection); } break; } @@ -253,7 +253,7 @@ void nano::bulk_pull_client::received_block (boost::system::error_code const & e } else if (stop_pull && block_expected) { - connection->connections->pool_connection (connection); + connection->connections.pool_connection (connection); } } else if (block == nullptr) @@ -376,7 +376,7 @@ void nano::bulk_pull_account_client::receive_pending () } else { - this_l->connection->connections->pool_connection (this_l->connection); + this_l->connection->connections.pool_connection (this_l->connection); } } else diff --git a/nano/node/bootstrap/bootstrap_connections.cpp b/nano/node/bootstrap/bootstrap_connections.cpp index 09a4e761d..cfba8e7ca 100644 --- a/nano/node/bootstrap/bootstrap_connections.cpp +++ b/nano/node/bootstrap/bootstrap_connections.cpp @@ -13,7 +13,7 @@ constexpr double nano::bootstrap_limits::bootstrap_minimum_termination_time_sec; constexpr unsigned nano::bootstrap_limits::bootstrap_max_new_connections; constexpr unsigned nano::bootstrap_limits::requeued_pulls_processed_blocks_factor; -nano::bootstrap_client::bootstrap_client (std::shared_ptr const & node_a, std::shared_ptr const & connections_a, std::shared_ptr const & channel_a, std::shared_ptr const & socket_a) : +nano::bootstrap_client::bootstrap_client (std::shared_ptr const & node_a, nano::bootstrap_connections & connections_a, std::shared_ptr const & channel_a, std::shared_ptr const & socket_a) : node (node_a), connections (connections_a), channel (channel_a), @@ -21,14 +21,14 @@ nano::bootstrap_client::bootstrap_client (std::shared_ptr const & no receive_buffer (std::make_shared> ()), start_time_m (std::chrono::steady_clock::now ()) { - ++connections->connections_count; + ++connections.connections_count; receive_buffer->resize (256); channel->set_endpoint (); } nano::bootstrap_client::~bootstrap_client () { - --connections->connections_count; + --connections.connections_count; } double nano::bootstrap_client::sample_block_rate () @@ -154,7 +154,7 @@ void nano::bootstrap_connections::connect_client (nano::tcp_endpoint const & end { this_l->node.logger.try_log (boost::str (boost::format ("Connection established to %1%") % endpoint_a)); } - auto client (std::make_shared (this_l->node.shared (), this_l, std::make_shared (*this_l->node.shared (), socket), socket)); + auto client (std::make_shared (this_l->node.shared (), *this_l, std::make_shared (*this_l->node.shared (), socket), socket)); this_l->pool_connection (client, true, push_front); } else diff --git a/nano/node/bootstrap/bootstrap_connections.hpp b/nano/node/bootstrap/bootstrap_connections.hpp index dbc63940c..4b47bb68f 100644 --- a/nano/node/bootstrap/bootstrap_connections.hpp +++ b/nano/node/bootstrap/bootstrap_connections.hpp @@ -21,7 +21,7 @@ class pull_info; class bootstrap_client final : public std::enable_shared_from_this { public: - bootstrap_client (std::shared_ptr const & node_a, std::shared_ptr const & connections_a, std::shared_ptr const & channel_a, std::shared_ptr const & socket_a); + bootstrap_client (std::shared_ptr const & node_a, nano::bootstrap_connections & connections_a, std::shared_ptr const & channel_a, std::shared_ptr const & socket_a); ~bootstrap_client (); std::shared_ptr shared (); void stop (bool force); @@ -29,7 +29,7 @@ public: double elapsed_seconds () const; void set_start_time (std::chrono::steady_clock::time_point start_time_a); std::shared_ptr node; - std::shared_ptr connections; + nano::bootstrap_connections & connections; std::shared_ptr channel; std::shared_ptr socket; std::shared_ptr> receive_buffer; diff --git a/nano/node/bootstrap/bootstrap_frontier.cpp b/nano/node/bootstrap/bootstrap_frontier.cpp index 6f6daf45b..c15d79134 100644 --- a/nano/node/bootstrap/bootstrap_frontier.cpp +++ b/nano/node/bootstrap/bootstrap_frontier.cpp @@ -199,7 +199,7 @@ void nano::frontier_req_client::received_frontier (boost::system::error_code con catch (std::future_error &) { } - connection->connections->pool_connection (connection); + connection->connections.pool_connection (connection); } } else