From 15e10e9090338a32d6310a9d22a98a6c3c124e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Tue, 12 Mar 2024 21:37:04 +0100 Subject: [PATCH] TCP CHANNELS LOGGING --- nano/lib/stats_enums.hpp | 4 ++++ nano/node/transport/tcp.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nano/lib/stats_enums.hpp b/nano/lib/stats_enums.hpp index 8dc2eb77a9..f1596e33fe 100644 --- a/nano/lib/stats_enums.hpp +++ b/nano/lib/stats_enums.hpp @@ -159,6 +159,10 @@ enum class detail : uint8_t node_id_handshake_network_error, node_id_handshake_response_invalid, + // tcp_channels + channel_accepted, + channel_rejected, + // bootstrap, callback initiate, initiate_legacy_age, diff --git a/nano/node/transport/tcp.cpp b/nano/node/transport/tcp.cpp index b50523a265..334f605a7f 100644 --- a/nano/node/transport/tcp.cpp +++ b/nano/node/transport/tcp.cpp @@ -203,6 +203,8 @@ std::shared_ptr nano::transport::tcp_channels::cre if (check (endpoint, node_id)) { + node.stats.inc (nano::stat::type::tcp_channels, nano::stat::detail::channel_accepted); + auto channel = std::make_shared (node, socket); channel->set_endpoint (); channel->set_node_id (node_id); @@ -220,7 +222,10 @@ std::shared_ptr nano::transport::tcp_channels::cre } else { - // TODO: Stat & log + node.stats.inc (nano::stat::type::tcp_channels, nano::stat::detail::channel_rejected); + node.logger.debug (nano::log::type::tcp_channels, "Rejected new channel from: {} ({})", + fmt::streamed (socket->remote_endpoint ()), + node_id.to_node_id ()); } } return nullptr;