Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(base-node): add client connection count to status line #4774

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions applications/tari_base_node/src/commands/command/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use async_trait::async_trait;
use chrono::{DateTime, NaiveDateTime, Utc};
use clap::Parser;
use tari_app_utilities::consts;
use tari_comms::connectivity::ConnectivitySelection;
use tokio::time;

use super::{CommandContext, HandleCommand};
Expand Down Expand Up @@ -103,11 +102,15 @@ impl CommandContext {
status_line.add_field("Mempool", "query timed out");
};

let conns = self
.connectivity
.select_connections(ConnectivitySelection::all_nodes(vec![]))
.await?;
status_line.add_field("Connections", conns.len());
let conns = self.connectivity.get_active_connections().await?;
let (num_nodes, num_clients) = conns.iter().fold((0usize, 0usize), |(nodes, clients), conn| {
if conn.peer_features().is_node() {
(nodes + 1, clients)
} else {
(nodes, clients + 1)
}
});
status_line.add_field("Connections", format!("{}|{}", num_nodes, num_clients));
let banned_peers = self.fetch_banned_peers().await?;
status_line.add_field("Banned", banned_peers.len());

Expand Down