Skip to content

Commit

Permalink
TCP CHANNELS LOGGING
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 12, 2024
1 parent 5a3a1b1 commit 15e10e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion nano/node/transport/tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ std::shared_ptr<nano::transport::channel_tcp> 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<nano::transport::channel_tcp> (node, socket);
channel->set_endpoint ();
channel->set_node_id (node_id);
Expand All @@ -220,7 +222,10 @@ std::shared_ptr<nano::transport::channel_tcp> 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;
Expand Down

0 comments on commit 15e10e9

Please sign in to comment.