Skip to content

Commit

Permalink
Log detailed peer and connections info
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev authored and clemahieu committed Jul 9, 2024
1 parent 36df62b commit f5590e9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
12 changes: 9 additions & 3 deletions nano/node/monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ void nano::monitor::run_one ()
blocks_confirmed_rate,
blocks_checked_rate);

logger.info (nano::log::type::monitor, "Peers: {} (stake peered: {} | stake online: {} | quorum: {})",
logger.info (nano::log::type::monitor, "Peers: {} (realtime: {} | bootstrap: {} | inbound connections: {} | outbound connections: {})",
node.network.size (),
node.tcp_listener.realtime_count (),
node.tcp_listener.bootstrap_count (),
node.tcp_listener.connection_count (nano::transport::tcp_listener::connection_type::inbound),
node.tcp_listener.connection_count (nano::transport::tcp_listener::connection_type::outbound));

logger.info (nano::log::type::monitor, "Quorum: {} (stake peered: {} | stake online: {})",
nano::uint128_union{ node.online_reps.delta () }.format_balance (Mxrb_ratio, 1, true),
nano::uint128_union{ node.rep_crawler.total_weight () }.format_balance (Mxrb_ratio, 1, true),
nano::uint128_union{ node.online_reps.online () }.format_balance (Mxrb_ratio, 1, true),
nano::uint128_union{ node.online_reps.delta () }.format_balance (Mxrb_ratio, 1, true));
nano::uint128_union{ node.online_reps.online () }.format_balance (Mxrb_ratio, 1, true));

logger.info (nano::log::type::monitor, "Elections active: {} (priority: {} | hinted: {} | optimistic: {})",
node.active.size (),
Expand Down
6 changes: 6 additions & 0 deletions nano/node/transport/tcp_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@ size_t nano::transport::tcp_listener::connection_count () const
return connections.size ();
}

size_t nano::transport::tcp_listener::connection_count (connection_type type) const
{
nano::lock_guard<nano::mutex> lock{ mutex };
return count_per_type (type);
}

size_t nano::transport::tcp_listener::attempt_count () const
{
nano::lock_guard<nano::mutex> lock{ mutex };
Expand Down
14 changes: 8 additions & 6 deletions nano/node/transport/tcp_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class tcp_config
*/
class tcp_listener final
{
public:
enum class connection_type
{
inbound,
outbound,
};

public:
tcp_listener (uint16_t port, tcp_config const &, nano::node &);
~tcp_listener ();
Expand All @@ -69,6 +76,7 @@ class tcp_listener final
nano::tcp_endpoint endpoint () const;

size_t connection_count () const;
size_t connection_count (connection_type) const;
size_t attempt_count () const;
size_t realtime_count () const;
size_t bootstrap_count () const;
Expand Down Expand Up @@ -104,12 +112,6 @@ class tcp_listener final
error,
};

enum class connection_type
{
inbound,
outbound,
};

asio::awaitable<void> connect_impl (asio::ip::tcp::endpoint);
asio::awaitable<asio::ip::tcp::socket> connect_socket (asio::ip::tcp::endpoint);

Expand Down

0 comments on commit f5590e9

Please sign in to comment.