add chain height to list-connections output
@@ -898,6 +898,7 @@ impl CommandHandler {
"Age",
"Role",
"User Agent",
+ "Chain Height",
]);
for conn in conns {
let peer = peer_manager
@@ -905,6 +906,15 @@ impl CommandHandler {
.await
.expect("Unexpected peer database error or peer not found");
+ let chain_height = if let Some(metadata) = peer
+ .get_metadata(1)
+ .and_then(|v| bincode::deserialize::<PeerMetadata>(v).ok())
+ {
+ Some(format!("Height = #{}", metadata.metadata.height_of_longest_chain()))
+ } else {
+ None
+ };
+
table.add_row(row![
peer.node_id,
peer.public_key,
@@ -920,7 +930,8 @@ impl CommandHandler {
},
Some(peer.user_agent)
.map(|ua| if ua.is_empty() { "<unknown>".to_string() } else { ua })
- .unwrap()
+ .unwrap(),
+ chain_height.unwrap_or_default(),
]);
}
