Skip to content

Commit

Permalink
ACCEPT RESULT RENAME
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 24, 2024
1 parent c899438 commit 815425f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions nano/node/transport/tcp_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ void nano::transport::tcp_listener::run ()
}
}

auto nano::transport::tcp_listener::accept_one () -> check_result
auto nano::transport::tcp_listener::accept_one () -> accept_result
{
auto boost_socket = acceptor.accept ();
auto const remote_endpoint = boost_socket.remote_endpoint ();
auto const local_endpoint = boost_socket.local_endpoint ();

if (auto result = check_limits (remote_endpoint.address ()); result != check_result::accepted)
if (auto result = check_limits (remote_endpoint.address ()); result != accept_result::accepted)
{
stats.inc (nano::stat::type::tcp_listener, nano::stat::detail::accept_limits_exceeded, nano::stat::dir::in);
// Refusal reason should be logged earlier
Expand All @@ -223,7 +223,7 @@ auto nano::transport::tcp_listener::accept_one () -> check_result

connection_accepted.notify (socket, server);

return check_result::accepted;
return accept_result::accepted;
}

void nano::transport::tcp_listener::wait_available_slots ()
Expand All @@ -246,7 +246,7 @@ void nano::transport::tcp_listener::wait_available_slots ()
}
}

auto nano::transport::tcp_listener::check_limits (boost::asio::ip::address const & ip) -> check_result
auto nano::transport::tcp_listener::check_limits (boost::asio::ip::address const & ip) -> accept_result
{
nano::lock_guard<nano::mutex> lock{ mutex };

Expand All @@ -261,7 +261,7 @@ auto nano::transport::tcp_listener::check_limits (boost::asio::ip::address const
stats.inc (nano::stat::type::tcp_listener, nano::stat::detail::max_per_ip, nano::stat::dir::in);
logger.debug (nano::log::type::tcp_listener, "Max connections per IP reached ({}), unable to open new connection", ip.to_string ());

return check_result::too_many_per_ip;
return accept_result::too_many_per_ip;
}
}

Expand All @@ -273,7 +273,7 @@ auto nano::transport::tcp_listener::check_limits (boost::asio::ip::address const
stats.inc (nano::stat::type::tcp_listener, nano::stat::detail::max_per_subnetwork, nano::stat::dir::in);
logger.debug (nano::log::type::tcp_listener, "Max connections per subnetwork reached ({}), unable to open new connection", ip.to_string ());

return check_result::too_many_per_subnetwork;
return accept_result::too_many_per_subnetwork;
}
}

Expand All @@ -282,10 +282,10 @@ auto nano::transport::tcp_listener::check_limits (boost::asio::ip::address const
stats.inc (nano::stat::type::tcp_listener, nano::stat::detail::excluded, nano::stat::dir::in);
logger.debug (nano::log::type::tcp_listener, "Rejected connection from excluded peer: {}", ip.to_string ());

return check_result::excluded;
return accept_result::excluded;
}

return check_result::accepted;
return accept_result::accepted;
}

size_t nano::transport::tcp_listener::connection_count () const
Expand Down
6 changes: 3 additions & 3 deletions nano/node/transport/tcp_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class tcp_listener final
void cleanup ();
void wait_available_slots ();

enum class check_result
enum class accept_result
{
invalid,
accepted,
Expand All @@ -67,8 +67,8 @@ class tcp_listener final
excluded,
};

check_result accept_one ();
check_result check_limits (boost::asio::ip::address const & ip);
accept_result accept_one ();
accept_result check_limits (boost::asio::ip::address const & ip);
size_t count_per_ip (boost::asio::ip::address const & ip) const;
size_t count_per_subnetwork (boost::asio::ip::address const & ip) const;

Expand Down

0 comments on commit 815425f

Please sign in to comment.