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: add substream count to list-connections #3387

Merged
Merged
Changes from 1 commit
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
16 changes: 8 additions & 8 deletions applications/tari_base_node/src/command_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,22 +701,18 @@ impl CommandHandler {
"Age",
"Role",
"User Agent",
"Chain Height",
"Info",
]);
for conn in conns {
let peer = peer_manager
.find_by_node_id(conn.peer_node_id())
.await
.expect("Unexpected peer database error or peer not found");

let chain_height = if let Some(metadata) = peer
let chain_height = peer
.get_metadata(1)
.and_then(|v| bincode::deserialize::<PeerMetadata>(v).ok())
{
Some(format!("Height = #{}", metadata.metadata.height_of_longest_chain()))
} else {
None
};
.map(|metadata| format!("height: {}", metadata.metadata.height_of_longest_chain()));

table.add_row(row![
peer.node_id,
Expand All @@ -734,7 +730,11 @@ impl CommandHandler {
Some(peer.user_agent)
.map(|ua| if ua.is_empty() { "<unknown>".to_string() } else { ua })
.unwrap(),
chain_height.unwrap_or_default(),
format!(
"substreams: {}{}",
conn.substream_count(),
chain_height.map(|s| format!(", {}", s)).unwrap_or_default()
),
]);
}

Expand Down