Rename channel_tcp to tcp_channel
This commit is contained in:
parent
0906a4f33c
commit
2a6c51e7a4
15 changed files with 50 additions and 50 deletions
|
|
@ -614,7 +614,7 @@ TEST (tcp_listener, tcp_listener_timeout_node_id_handshake)
|
||||||
ASSERT_TRUE (cookie);
|
ASSERT_TRUE (cookie);
|
||||||
nano::node_id_handshake::query_payload query{ *cookie };
|
nano::node_id_handshake::query_payload query{ *cookie };
|
||||||
nano::node_id_handshake node_id_handshake{ nano::dev::network_params.network, query };
|
nano::node_id_handshake node_id_handshake{ nano::dev::network_params.network, query };
|
||||||
auto channel = std::make_shared<nano::transport::channel_tcp> (*node0, socket);
|
auto channel = std::make_shared<nano::transport::tcp_channel> (*node0, socket);
|
||||||
socket->async_connect (node0->tcp_listener.endpoint (), [&node_id_handshake, channel] (boost::system::error_code const & ec) {
|
socket->async_connect (node0->tcp_listener.endpoint (), [&node_id_handshake, channel] (boost::system::error_code const & ec) {
|
||||||
ASSERT_FALSE (ec);
|
ASSERT_FALSE (ec);
|
||||||
channel->send (node_id_handshake, [] (boost::system::error_code const & ec, size_t size_a) {
|
channel->send (node_id_handshake, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ TEST (request_aggregator, one)
|
||||||
std::vector<std::pair<nano::block_hash, nano::root>> request;
|
std::vector<std::pair<nano::block_hash, nano::root>> request;
|
||||||
request.emplace_back (send1->hash (), send1->root ());
|
request.emplace_back (send1->hash (), send1->root ());
|
||||||
auto client = std::make_shared<nano::transport::socket> (node);
|
auto client = std::make_shared<nano::transport::socket> (node);
|
||||||
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::channel_tcp> (node, client);
|
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::tcp_channel> (node, client);
|
||||||
node.aggregator.request (request, dummy_channel);
|
node.aggregator.request (request, dummy_channel);
|
||||||
ASSERT_TIMELY (3s, node.aggregator.empty ());
|
ASSERT_TIMELY (3s, node.aggregator.empty ());
|
||||||
// Not yet in the ledger
|
// Not yet in the ledger
|
||||||
|
|
@ -169,7 +169,7 @@ TEST (request_aggregator, two)
|
||||||
request.emplace_back (send2->hash (), send2->root ());
|
request.emplace_back (send2->hash (), send2->root ());
|
||||||
request.emplace_back (receive1->hash (), receive1->root ());
|
request.emplace_back (receive1->hash (), receive1->root ());
|
||||||
auto client = std::make_shared<nano::transport::socket> (node);
|
auto client = std::make_shared<nano::transport::socket> (node);
|
||||||
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::channel_tcp> (node, client);
|
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::tcp_channel> (node, client);
|
||||||
// Process both blocks
|
// Process both blocks
|
||||||
node.aggregator.request (request, dummy_channel);
|
node.aggregator.request (request, dummy_channel);
|
||||||
// One vote should be generated for both blocks
|
// One vote should be generated for both blocks
|
||||||
|
|
@ -288,7 +288,7 @@ TEST (request_aggregator, split)
|
||||||
ASSERT_TIMELY_EQ (5s, max_vbh + 2, node.ledger.cemented_count ());
|
ASSERT_TIMELY_EQ (5s, max_vbh + 2, node.ledger.cemented_count ());
|
||||||
ASSERT_EQ (max_vbh + 1, request.size ());
|
ASSERT_EQ (max_vbh + 1, request.size ());
|
||||||
auto client = std::make_shared<nano::transport::socket> (node);
|
auto client = std::make_shared<nano::transport::socket> (node);
|
||||||
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::channel_tcp> (node, client);
|
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::tcp_channel> (node, client);
|
||||||
node.aggregator.request (request, dummy_channel);
|
node.aggregator.request (request, dummy_channel);
|
||||||
// In the ledger but no vote generated yet
|
// In the ledger but no vote generated yet
|
||||||
ASSERT_TIMELY_EQ (3s, 2, node.stats.count (nano::stat::type::requests, nano::stat::detail::requests_generated_votes));
|
ASSERT_TIMELY_EQ (3s, 2, node.stats.count (nano::stat::type::requests, nano::stat::detail::requests_generated_votes));
|
||||||
|
|
@ -327,7 +327,7 @@ TEST (request_aggregator, channel_max_queue)
|
||||||
std::vector<std::pair<nano::block_hash, nano::root>> request;
|
std::vector<std::pair<nano::block_hash, nano::root>> request;
|
||||||
request.emplace_back (send1->hash (), send1->root ());
|
request.emplace_back (send1->hash (), send1->root ());
|
||||||
auto client = std::make_shared<nano::transport::socket> (node);
|
auto client = std::make_shared<nano::transport::socket> (node);
|
||||||
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::channel_tcp> (node, client);
|
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::tcp_channel> (node, client);
|
||||||
node.aggregator.request (request, dummy_channel);
|
node.aggregator.request (request, dummy_channel);
|
||||||
node.aggregator.request (request, dummy_channel);
|
node.aggregator.request (request, dummy_channel);
|
||||||
ASSERT_LT (0, node.stats.count (nano::stat::type::aggregator, nano::stat::detail::aggregator_dropped));
|
ASSERT_LT (0, node.stats.count (nano::stat::type::aggregator, nano::stat::detail::aggregator_dropped));
|
||||||
|
|
@ -356,7 +356,7 @@ TEST (request_aggregator, DISABLED_unique)
|
||||||
std::vector<std::pair<nano::block_hash, nano::root>> request;
|
std::vector<std::pair<nano::block_hash, nano::root>> request;
|
||||||
request.emplace_back (send1->hash (), send1->root ());
|
request.emplace_back (send1->hash (), send1->root ());
|
||||||
auto client = std::make_shared<nano::transport::socket> (node);
|
auto client = std::make_shared<nano::transport::socket> (node);
|
||||||
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::channel_tcp> (node, client);
|
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::tcp_channel> (node, client);
|
||||||
node.aggregator.request (request, dummy_channel);
|
node.aggregator.request (request, dummy_channel);
|
||||||
node.aggregator.request (request, dummy_channel);
|
node.aggregator.request (request, dummy_channel);
|
||||||
node.aggregator.request (request, dummy_channel);
|
node.aggregator.request (request, dummy_channel);
|
||||||
|
|
@ -401,7 +401,7 @@ TEST (request_aggregator, cannot_vote)
|
||||||
// Incorrect hash, correct root
|
// Incorrect hash, correct root
|
||||||
request.emplace_back (1, send2->root ());
|
request.emplace_back (1, send2->root ());
|
||||||
auto client = std::make_shared<nano::transport::socket> (node);
|
auto client = std::make_shared<nano::transport::socket> (node);
|
||||||
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::channel_tcp> (node, client);
|
std::shared_ptr<nano::transport::channel> dummy_channel = std::make_shared<nano::transport::tcp_channel> (node, client);
|
||||||
node.aggregator.request (request, dummy_channel);
|
node.aggregator.request (request, dummy_channel);
|
||||||
ASSERT_TIMELY (3s, node.aggregator.empty ());
|
ASSERT_TIMELY (3s, node.aggregator.empty ());
|
||||||
ASSERT_EQ (1, node.stats.count (nano::stat::type::aggregator, nano::stat::detail::aggregator_accepted));
|
ASSERT_EQ (1, node.stats.count (nano::stat::type::aggregator, nano::stat::detail::aggregator_accepted));
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ TEST (socket, drop_policy)
|
||||||
});
|
});
|
||||||
|
|
||||||
auto client = std::make_shared<nano::transport::socket> (*node);
|
auto client = std::make_shared<nano::transport::socket> (*node);
|
||||||
auto channel = std::make_shared<nano::transport::channel_tcp> (*node, client);
|
auto channel = std::make_shared<nano::transport::tcp_channel> (*node, client);
|
||||||
|
|
||||||
std::atomic completed_writes{ 0 };
|
std::atomic completed_writes{ 0 };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,8 +157,8 @@ add_library(
|
||||||
telemetry.cpp
|
telemetry.cpp
|
||||||
transport/channel.hpp
|
transport/channel.hpp
|
||||||
transport/channel.cpp
|
transport/channel.cpp
|
||||||
transport/channel_tcp.hpp
|
transport/tcp_channel.hpp
|
||||||
transport/channel_tcp.cpp
|
transport/tcp_channel.cpp
|
||||||
transport/fake.hpp
|
transport/fake.hpp
|
||||||
transport/fake.cpp
|
transport/fake.cpp
|
||||||
transport/inproc.hpp
|
transport/inproc.hpp
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class node;
|
||||||
class bootstrap_connections;
|
class bootstrap_connections;
|
||||||
namespace transport
|
namespace transport
|
||||||
{
|
{
|
||||||
class channel_tcp;
|
class tcp_channel;
|
||||||
}
|
}
|
||||||
enum class bootstrap_mode
|
enum class bootstrap_mode
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,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::bootstrap_max_new_connections;
|
||||||
constexpr unsigned nano::bootstrap_limits::requeued_pulls_processed_blocks_factor;
|
constexpr unsigned nano::bootstrap_limits::requeued_pulls_processed_blocks_factor;
|
||||||
|
|
||||||
nano::bootstrap_client::bootstrap_client (std::shared_ptr<nano::node> const & node_a, std::shared_ptr<nano::transport::channel_tcp> const & channel_a, std::shared_ptr<nano::transport::socket> const & socket_a) :
|
nano::bootstrap_client::bootstrap_client (std::shared_ptr<nano::node> const & node_a, std::shared_ptr<nano::transport::tcp_channel> const & channel_a, std::shared_ptr<nano::transport::socket> const & socket_a) :
|
||||||
node (node_a),
|
node (node_a),
|
||||||
channel (channel_a),
|
channel (channel_a),
|
||||||
socket (socket_a),
|
socket (socket_a),
|
||||||
|
|
@ -159,7 +159,7 @@ void nano::bootstrap_connections::connect_client (nano::tcp_endpoint const & end
|
||||||
{
|
{
|
||||||
this_l->node.logger.debug (nano::log::type::bootstrap, "Connection established to: {}", nano::util::to_str (endpoint_a));
|
this_l->node.logger.debug (nano::log::type::bootstrap, "Connection established to: {}", nano::util::to_str (endpoint_a));
|
||||||
|
|
||||||
auto client (std::make_shared<nano::bootstrap_client> (this_l->node.shared (), std::make_shared<nano::transport::channel_tcp> (*this_l->node.shared (), socket), socket));
|
auto client (std::make_shared<nano::bootstrap_client> (this_l->node.shared (), std::make_shared<nano::transport::tcp_channel> (*this_l->node.shared (), socket), socket));
|
||||||
this_l->pool_connection (client, true, push_front);
|
this_l->pool_connection (client, true, push_front);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace nano
|
||||||
class node;
|
class node;
|
||||||
namespace transport
|
namespace transport
|
||||||
{
|
{
|
||||||
class channel_tcp;
|
class tcp_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
class bootstrap_attempt;
|
class bootstrap_attempt;
|
||||||
|
|
@ -25,14 +25,14 @@ class pull_info;
|
||||||
class bootstrap_client final : public std::enable_shared_from_this<bootstrap_client>
|
class bootstrap_client final : public std::enable_shared_from_this<bootstrap_client>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bootstrap_client (std::shared_ptr<nano::node> const & node_a, std::shared_ptr<nano::transport::channel_tcp> const & channel_a, std::shared_ptr<nano::transport::socket> const & socket_a);
|
bootstrap_client (std::shared_ptr<nano::node> const & node_a, std::shared_ptr<nano::transport::tcp_channel> const & channel_a, std::shared_ptr<nano::transport::socket> const & socket_a);
|
||||||
~bootstrap_client ();
|
~bootstrap_client ();
|
||||||
void stop (bool force);
|
void stop (bool force);
|
||||||
double sample_block_rate ();
|
double sample_block_rate ();
|
||||||
double elapsed_seconds () const;
|
double elapsed_seconds () const;
|
||||||
void set_start_time (std::chrono::steady_clock::time_point start_time_a);
|
void set_start_time (std::chrono::steady_clock::time_point start_time_a);
|
||||||
std::weak_ptr<nano::node> node;
|
std::weak_ptr<nano::node> node;
|
||||||
std::shared_ptr<nano::transport::channel_tcp> channel;
|
std::shared_ptr<nano::transport::tcp_channel> channel;
|
||||||
std::shared_ptr<nano::transport::socket> socket;
|
std::shared_ptr<nano::transport::socket> socket;
|
||||||
std::shared_ptr<std::vector<uint8_t>> receive_buffer;
|
std::shared_ptr<std::vector<uint8_t>> receive_buffer;
|
||||||
std::atomic<uint64_t> block_count{ 0 };
|
std::atomic<uint64_t> block_count{ 0 };
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@
|
||||||
namespace nano::transport
|
namespace nano::transport
|
||||||
{
|
{
|
||||||
class channel;
|
class channel;
|
||||||
class channel_tcp;
|
class tcp_channel;
|
||||||
class tcp_channels;
|
class tcp_channels;
|
||||||
}
|
}
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
#include <nano/lib/stats.hpp>
|
#include <nano/lib/stats.hpp>
|
||||||
#include <nano/lib/utility.hpp>
|
#include <nano/lib/utility.hpp>
|
||||||
#include <nano/node/node.hpp>
|
#include <nano/node/node.hpp>
|
||||||
#include <nano/node/transport/channel_tcp.hpp>
|
|
||||||
#include <nano/node/transport/message_deserializer.hpp>
|
#include <nano/node/transport/message_deserializer.hpp>
|
||||||
|
#include <nano/node/transport/tcp_channel.hpp>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* channel_tcp
|
* tcp_channel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nano::transport::channel_tcp::channel_tcp (nano::node & node_a, std::weak_ptr<nano::transport::socket> socket_a) :
|
nano::transport::tcp_channel::tcp_channel (nano::node & node_a, std::weak_ptr<nano::transport::socket> socket_a) :
|
||||||
channel (node_a),
|
channel (node_a),
|
||||||
socket (std::move (socket_a))
|
socket (std::move (socket_a))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
nano::transport::channel_tcp::~channel_tcp ()
|
nano::transport::tcp_channel::~tcp_channel ()
|
||||||
{
|
{
|
||||||
nano::lock_guard<nano::mutex> lk{ channel_mutex };
|
nano::lock_guard<nano::mutex> lk{ channel_mutex };
|
||||||
// Close socket. Exception: socket is used by tcp_server
|
// Close socket. Exception: socket is used by tcp_server
|
||||||
|
|
@ -24,7 +24,7 @@ nano::transport::channel_tcp::~channel_tcp ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::transport::channel_tcp::update_endpoints ()
|
void nano::transport::tcp_channel::update_endpoints ()
|
||||||
{
|
{
|
||||||
nano::lock_guard<nano::mutex> lk (channel_mutex);
|
nano::lock_guard<nano::mutex> lk (channel_mutex);
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ void nano::transport::channel_tcp::update_endpoints ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::transport::channel_tcp::send_buffer (nano::shared_const_buffer const & buffer_a, std::function<void (boost::system::error_code const &, std::size_t)> const & callback_a, nano::transport::buffer_drop_policy policy_a, nano::transport::traffic_type traffic_type)
|
void nano::transport::tcp_channel::send_buffer (nano::shared_const_buffer const & buffer_a, std::function<void (boost::system::error_code const &, std::size_t)> const & callback_a, nano::transport::buffer_drop_policy policy_a, nano::transport::traffic_type traffic_type)
|
||||||
{
|
{
|
||||||
if (auto socket_l = socket.lock ())
|
if (auto socket_l = socket.lock ())
|
||||||
{
|
{
|
||||||
|
|
@ -88,12 +88,12 @@ void nano::transport::channel_tcp::send_buffer (nano::shared_const_buffer const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string nano::transport::channel_tcp::to_string () const
|
std::string nano::transport::tcp_channel::to_string () const
|
||||||
{
|
{
|
||||||
return nano::util::to_str (get_tcp_endpoint ());
|
return nano::util::to_str (get_tcp_endpoint ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::transport::channel_tcp::operator() (nano::object_stream & obs) const
|
void nano::transport::tcp_channel::operator() (nano::object_stream & obs) const
|
||||||
{
|
{
|
||||||
nano::transport::channel::operator() (obs); // Write common data
|
nano::transport::channel::operator() (obs); // Write common data
|
||||||
|
|
||||||
|
|
@ -7,15 +7,15 @@ namespace nano::transport
|
||||||
{
|
{
|
||||||
class tcp_server;
|
class tcp_server;
|
||||||
class tcp_channels;
|
class tcp_channels;
|
||||||
class channel_tcp;
|
class tcp_channel;
|
||||||
|
|
||||||
class channel_tcp : public nano::transport::channel, public std::enable_shared_from_this<channel_tcp>
|
class tcp_channel : public nano::transport::channel, public std::enable_shared_from_this<tcp_channel>
|
||||||
{
|
{
|
||||||
friend class nano::transport::tcp_channels;
|
friend class nano::transport::tcp_channels;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
channel_tcp (nano::node &, std::weak_ptr<nano::transport::socket>);
|
tcp_channel (nano::node &, std::weak_ptr<nano::transport::socket>);
|
||||||
~channel_tcp () override;
|
~tcp_channel () override;
|
||||||
|
|
||||||
void update_endpoints ();
|
void update_endpoints ();
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ bool nano::transport::tcp_channels::check (const nano::tcp_endpoint & endpoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should be the only place in node where channels are created
|
// This should be the only place in node where channels are created
|
||||||
std::shared_ptr<nano::transport::channel_tcp> nano::transport::tcp_channels::create (const std::shared_ptr<nano::transport::socket> & socket, const std::shared_ptr<nano::transport::tcp_server> & server, const nano::account & node_id)
|
std::shared_ptr<nano::transport::tcp_channel> nano::transport::tcp_channels::create (const std::shared_ptr<nano::transport::socket> & socket, const std::shared_ptr<nano::transport::tcp_server> & server, const nano::account & node_id)
|
||||||
{
|
{
|
||||||
auto const endpoint = socket->remote_endpoint ();
|
auto const endpoint = socket->remote_endpoint ();
|
||||||
debug_assert (endpoint.address ().is_v6 ());
|
debug_assert (endpoint.address ().is_v6 ());
|
||||||
|
|
@ -117,7 +117,7 @@ std::shared_ptr<nano::transport::channel_tcp> nano::transport::tcp_channels::cre
|
||||||
fmt::streamed (socket->remote_endpoint ()),
|
fmt::streamed (socket->remote_endpoint ()),
|
||||||
node_id.to_node_id ());
|
node_id.to_node_id ());
|
||||||
|
|
||||||
auto channel = std::make_shared<nano::transport::channel_tcp> (node, socket);
|
auto channel = std::make_shared<nano::transport::tcp_channel> (node, socket);
|
||||||
channel->update_endpoints ();
|
channel->update_endpoints ();
|
||||||
channel->set_node_id (node_id);
|
channel->set_node_id (node_id);
|
||||||
|
|
||||||
|
|
@ -145,10 +145,10 @@ std::size_t nano::transport::tcp_channels::size () const
|
||||||
return channels.size ();
|
return channels.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<nano::transport::channel_tcp> nano::transport::tcp_channels::find_channel (nano::tcp_endpoint const & endpoint_a) const
|
std::shared_ptr<nano::transport::tcp_channel> nano::transport::tcp_channels::find_channel (nano::tcp_endpoint const & endpoint_a) const
|
||||||
{
|
{
|
||||||
nano::lock_guard<nano::mutex> lock{ mutex };
|
nano::lock_guard<nano::mutex> lock{ mutex };
|
||||||
std::shared_ptr<nano::transport::channel_tcp> result;
|
std::shared_ptr<nano::transport::tcp_channel> result;
|
||||||
auto existing (channels.get<endpoint_tag> ().find (endpoint_a));
|
auto existing (channels.get<endpoint_tag> ().find (endpoint_a));
|
||||||
if (existing != channels.get<endpoint_tag> ().end ())
|
if (existing != channels.get<endpoint_tag> ().end ())
|
||||||
{
|
{
|
||||||
|
|
@ -202,9 +202,9 @@ void nano::transport::tcp_channels::random_fill (std::array<nano::endpoint, 8> &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<nano::transport::channel_tcp> nano::transport::tcp_channels::find_node_id (nano::account const & node_id_a)
|
std::shared_ptr<nano::transport::tcp_channel> nano::transport::tcp_channels::find_node_id (nano::account const & node_id_a)
|
||||||
{
|
{
|
||||||
std::shared_ptr<nano::transport::channel_tcp> result;
|
std::shared_ptr<nano::transport::tcp_channel> result;
|
||||||
nano::lock_guard<nano::mutex> lock{ mutex };
|
nano::lock_guard<nano::mutex> lock{ mutex };
|
||||||
auto existing (channels.get<node_id_tag> ().find (node_id_a));
|
auto existing (channels.get<node_id_tag> ().find (node_id_a));
|
||||||
if (existing != channels.get<node_id_tag> ().end ())
|
if (existing != channels.get<node_id_tag> ().end ())
|
||||||
|
|
@ -387,7 +387,7 @@ void nano::transport::tcp_channels::keepalive ()
|
||||||
auto const cutoff_time = std::chrono::steady_clock::now () - node.network_params.network.keepalive_period;
|
auto const cutoff_time = std::chrono::steady_clock::now () - node.network_params.network.keepalive_period;
|
||||||
|
|
||||||
// Wake up channels
|
// Wake up channels
|
||||||
std::vector<std::shared_ptr<nano::transport::channel_tcp>> to_wakeup;
|
std::vector<std::shared_ptr<nano::transport::tcp_channel>> to_wakeup;
|
||||||
for (auto const & entry : channels)
|
for (auto const & entry : channels)
|
||||||
{
|
{
|
||||||
if (entry.channel->get_last_packet_sent () < cutoff_time)
|
if (entry.channel->get_last_packet_sent () < cutoff_time)
|
||||||
|
|
@ -434,7 +434,7 @@ void nano::transport::tcp_channels::list (std::deque<std::shared_ptr<nano::trans
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::transport::tcp_channels::modify (std::shared_ptr<nano::transport::channel_tcp> const & channel_a, std::function<void (std::shared_ptr<nano::transport::channel_tcp> const &)> modify_callback_a)
|
void nano::transport::tcp_channels::modify (std::shared_ptr<nano::transport::tcp_channel> const & channel_a, std::function<void (std::shared_ptr<nano::transport::tcp_channel> const &)> modify_callback_a)
|
||||||
{
|
{
|
||||||
nano::lock_guard<nano::mutex> lock{ mutex };
|
nano::lock_guard<nano::mutex> lock{ mutex };
|
||||||
auto existing (channels.get<endpoint_tag> ().find (channel_a->get_tcp_endpoint ()));
|
auto existing (channels.get<endpoint_tag> ().find (channel_a->get_tcp_endpoint ()));
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <nano/lib/random.hpp>
|
#include <nano/lib/random.hpp>
|
||||||
#include <nano/node/common.hpp>
|
#include <nano/node/common.hpp>
|
||||||
#include <nano/node/transport/channel.hpp>
|
#include <nano/node/transport/channel.hpp>
|
||||||
#include <nano/node/transport/channel_tcp.hpp>
|
#include <nano/node/transport/tcp_channel.hpp>
|
||||||
#include <nano/node/transport/transport.hpp>
|
#include <nano/node/transport/transport.hpp>
|
||||||
|
|
||||||
#include <boost/multi_index/hashed_index.hpp>
|
#include <boost/multi_index/hashed_index.hpp>
|
||||||
|
|
@ -23,7 +23,7 @@ namespace nano::transport
|
||||||
{
|
{
|
||||||
class tcp_channels final
|
class tcp_channels final
|
||||||
{
|
{
|
||||||
friend class channel_tcp;
|
friend class tcp_channel;
|
||||||
friend class telemetry_simultaneous_requests_Test;
|
friend class telemetry_simultaneous_requests_Test;
|
||||||
friend class network_peer_max_tcp_attempts_subnetwork_Test;
|
friend class network_peer_max_tcp_attempts_subnetwork_Test;
|
||||||
|
|
||||||
|
|
@ -34,13 +34,13 @@ public:
|
||||||
void start ();
|
void start ();
|
||||||
void stop ();
|
void stop ();
|
||||||
|
|
||||||
std::shared_ptr<nano::transport::channel_tcp> create (std::shared_ptr<nano::transport::socket> const &, std::shared_ptr<nano::transport::tcp_server> const &, nano::account const & node_id);
|
std::shared_ptr<nano::transport::tcp_channel> create (std::shared_ptr<nano::transport::socket> const &, std::shared_ptr<nano::transport::tcp_server> const &, nano::account const & node_id);
|
||||||
void erase (nano::tcp_endpoint const &);
|
void erase (nano::tcp_endpoint const &);
|
||||||
std::size_t size () const;
|
std::size_t size () const;
|
||||||
std::shared_ptr<nano::transport::channel_tcp> find_channel (nano::tcp_endpoint const &) const;
|
std::shared_ptr<nano::transport::tcp_channel> find_channel (nano::tcp_endpoint const &) const;
|
||||||
void random_fill (std::array<nano::endpoint, 8> &) const;
|
void random_fill (std::array<nano::endpoint, 8> &) const;
|
||||||
std::unordered_set<std::shared_ptr<nano::transport::channel>> random_set (std::size_t, uint8_t = 0, bool = false) const;
|
std::unordered_set<std::shared_ptr<nano::transport::channel>> random_set (std::size_t, uint8_t = 0, bool = false) const;
|
||||||
std::shared_ptr<nano::transport::channel_tcp> find_node_id (nano::account const &);
|
std::shared_ptr<nano::transport::tcp_channel> find_node_id (nano::account const &);
|
||||||
// Get the next peer for attempting a tcp connection
|
// Get the next peer for attempting a tcp connection
|
||||||
nano::tcp_endpoint bootstrap_peer ();
|
nano::tcp_endpoint bootstrap_peer ();
|
||||||
bool max_ip_connections (nano::tcp_endpoint const & endpoint_a);
|
bool max_ip_connections (nano::tcp_endpoint const & endpoint_a);
|
||||||
|
|
@ -51,7 +51,7 @@ public:
|
||||||
std::unique_ptr<container_info_component> collect_container_info (std::string const &);
|
std::unique_ptr<container_info_component> collect_container_info (std::string const &);
|
||||||
void purge (std::chrono::steady_clock::time_point cutoff_deadline);
|
void purge (std::chrono::steady_clock::time_point cutoff_deadline);
|
||||||
void list (std::deque<std::shared_ptr<nano::transport::channel>> &, uint8_t = 0, bool = true);
|
void list (std::deque<std::shared_ptr<nano::transport::channel>> &, uint8_t = 0, bool = true);
|
||||||
void modify (std::shared_ptr<nano::transport::channel_tcp> const &, std::function<void (std::shared_ptr<nano::transport::channel_tcp> const &)>);
|
void modify (std::shared_ptr<nano::transport::tcp_channel> const &, std::function<void (std::shared_ptr<nano::transport::tcp_channel> const &)>);
|
||||||
void keepalive ();
|
void keepalive ();
|
||||||
std::optional<nano::keepalive> sample_keepalive ();
|
std::optional<nano::keepalive> sample_keepalive ();
|
||||||
|
|
||||||
|
|
@ -69,12 +69,12 @@ private:
|
||||||
class channel_entry final
|
class channel_entry final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<nano::transport::channel_tcp> channel;
|
std::shared_ptr<nano::transport::tcp_channel> channel;
|
||||||
std::shared_ptr<nano::transport::socket> socket;
|
std::shared_ptr<nano::transport::socket> socket;
|
||||||
std::shared_ptr<nano::transport::tcp_server> response_server;
|
std::shared_ptr<nano::transport::tcp_server> response_server;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
channel_entry (std::shared_ptr<nano::transport::channel_tcp> channel_a, std::shared_ptr<nano::transport::socket> socket_a, std::shared_ptr<nano::transport::tcp_server> server_a) :
|
channel_entry (std::shared_ptr<nano::transport::tcp_channel> channel_a, std::shared_ptr<nano::transport::socket> socket_a, std::shared_ptr<nano::transport::tcp_server> server_a) :
|
||||||
channel (std::move (channel_a)), socket (std::move (socket_a)), response_server (std::move (server_a))
|
channel (std::move (channel_a)), socket (std::move (socket_a)), response_server (std::move (server_a))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ private:
|
||||||
std::optional<nano::keepalive> last_keepalive;
|
std::optional<nano::keepalive> last_keepalive;
|
||||||
|
|
||||||
// Every realtime connection must have an associated channel
|
// Every realtime connection must have an associated channel
|
||||||
std::shared_ptr<nano::transport::channel_tcp> channel;
|
std::shared_ptr<nano::transport::tcp_channel> channel;
|
||||||
|
|
||||||
private: // Visitors
|
private: // Visitors
|
||||||
class handshake_message_visitor : public nano::message_visitor
|
class handshake_message_visitor : public nano::message_visitor
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
std::shared_ptr<nano::transport::channel_tcp> nano::test::establish_tcp (nano::test::system & system, nano::node & node, nano::endpoint const & endpoint)
|
std::shared_ptr<nano::transport::tcp_channel> nano::test::establish_tcp (nano::test::system & system, nano::node & node, nano::endpoint const & endpoint)
|
||||||
{
|
{
|
||||||
debug_assert (node.network.endpoint () != endpoint && "Establishing TCP to self is not allowed");
|
debug_assert (node.network.endpoint () != endpoint && "Establishing TCP to self is not allowed");
|
||||||
|
|
||||||
std::shared_ptr<nano::transport::channel_tcp> result;
|
std::shared_ptr<nano::transport::tcp_channel> result;
|
||||||
debug_assert (!node.flags.disable_tcp_realtime);
|
debug_assert (!node.flags.disable_tcp_realtime);
|
||||||
node.network.tcp_channels.start_tcp (endpoint);
|
node.network.tcp_channels.start_tcp (endpoint);
|
||||||
auto error = system.poll_until_true (2s, [&result, &node, &endpoint] {
|
auto error = system.poll_until_true (2s, [&result, &node, &endpoint] {
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@ class node;
|
||||||
namespace transport
|
namespace transport
|
||||||
{
|
{
|
||||||
class channel;
|
class channel;
|
||||||
class channel_tcp;
|
class tcp_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
{
|
{
|
||||||
class system;
|
class system;
|
||||||
/** Waits until a TCP connection is established and returns the TCP channel on success*/
|
/** Waits until a TCP connection is established and returns the TCP channel on success*/
|
||||||
std::shared_ptr<nano::transport::channel_tcp> establish_tcp (nano::test::system &, nano::node &, nano::endpoint const &);
|
std::shared_ptr<nano::transport::tcp_channel> establish_tcp (nano::test::system &, nano::node &, nano::endpoint const &);
|
||||||
|
|
||||||
/** Adds a node to the system without establishing connections */
|
/** Adds a node to the system without establishing connections */
|
||||||
std::shared_ptr<nano::node> add_outer_node (nano::test::system & system, nano::node_config const & config_a, nano::node_flags = nano::node_flags ());
|
std::shared_ptr<nano::node> add_outer_node (nano::test::system & system, nano::node_config const & config_a, nano::node_flags = nano::node_flags ());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue