Skip to content

Commit

Permalink
Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 21, 2024
1 parent 2481834 commit 8f54094
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions nano/core_test/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ TEST (network, purge_dead_channel)
auto channel = channels.front ();
ASSERT_TRUE (channel);

auto sockets = node1.tcp_listener.sockets ();
auto sockets = node1.tcp_listener.all_sockets ();
ASSERT_EQ (sockets.size (), 1);
auto socket = sockets.front ();
ASSERT_TRUE (socket);
Expand Down Expand Up @@ -1217,7 +1217,7 @@ TEST (network, purge_dead_channel_remote)
auto channel = channels.front ();
ASSERT_TRUE (channel);

auto sockets = node1.tcp_listener.sockets ();
auto sockets = node1.tcp_listener.all_sockets ();
ASSERT_EQ (sockets.size (), 1);
auto socket = sockets.front ();
ASSERT_TRUE (socket);
Expand Down
8 changes: 4 additions & 4 deletions nano/core_test/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ TEST (tcp_listener, max_connections)

// create space for one socket and fill the connections table again
{
auto sockets1 = node->tcp_listener.sockets ();
auto sockets1 = node->tcp_listener.all_sockets ();
ASSERT_EQ (sockets1.size (), 2);
sockets1[0]->close ();
}
ASSERT_TIMELY_EQ (10s, node->tcp_listener.sockets ().size (), 1);
ASSERT_TIMELY_EQ (10s, node->tcp_listener.all_sockets ().size (), 1);

auto client4 = std::make_shared<nano::transport::tcp_socket> (*node);
client4->async_connect (node->network.endpoint (), connect_handler);
Expand All @@ -125,12 +125,12 @@ TEST (tcp_listener, max_connections)

// close all existing sockets and fill the connections table again
{
auto sockets2 = node->tcp_listener.sockets ();
auto sockets2 = node->tcp_listener.all_sockets ();
ASSERT_EQ (sockets2.size (), 2);
sockets2[0]->close ();
sockets2[1]->close ();
}
ASSERT_TIMELY_EQ (10s, node->tcp_listener.sockets ().size (), 0);
ASSERT_TIMELY_EQ (10s, node->tcp_listener.all_sockets ().size (), 0);

auto client6 = std::make_shared<nano::transport::tcp_socket> (*node);
client6->async_connect (node->network.endpoint (), connect_handler);
Expand Down
4 changes: 2 additions & 2 deletions nano/node/transport/tcp_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,14 +564,14 @@ asio::ip::tcp::endpoint nano::transport::tcp_listener::endpoint () const
return { asio::ip::address_v6::loopback (), local.port () };
}

auto nano::transport::tcp_listener::sockets () const -> std::vector<std::shared_ptr<tcp_socket>>
auto nano::transport::tcp_listener::all_sockets () const -> std::deque<std::shared_ptr<tcp_socket>>
{
nano::lock_guard<nano::mutex> lock{ mutex };
auto r = connections | std::views::transform ([] (auto const & connection) { return connection.socket; });
return { r.begin (), r.end () };
}

auto nano::transport::tcp_listener::servers () const -> std::vector<std::shared_ptr<tcp_server>>
auto nano::transport::tcp_listener::all_servers () const -> std::deque<std::shared_ptr<tcp_server>>
{
nano::lock_guard<nano::mutex> lock{ mutex };
auto r = connections | std::views::transform ([] (auto const & connection) { return connection.server; });
Expand Down
4 changes: 2 additions & 2 deletions nano/node/transport/tcp_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class tcp_listener final
size_t realtime_count () const;
size_t bootstrap_count () const;

std::vector<std::shared_ptr<tcp_socket>> sockets () const;
std::vector<std::shared_ptr<tcp_server>> servers () const;
std::deque<std::shared_ptr<tcp_socket>> all_sockets () const;
std::deque<std::shared_ptr<tcp_server>> all_servers () const;

nano::container_info container_info () const;

Expand Down

0 comments on commit 8f54094

Please sign in to comment.