add "User Agent" column to peers in tui (#1949)

This commit is contained in:
Antioch Peverell
2018-11-09 14:47:28 +00:00
committed by GitHub
parent ee5fd489bb
commit 10c6f8d1ad
2 changed files with 11 additions and 3 deletions
+4 -1
View File
@@ -141,6 +141,8 @@ pub struct PeerStats {
pub addr: String,
/// version running
pub version: u32,
/// Peer user agent string.
pub user_agent: String,
/// difficulty reported by peer
pub total_difficulty: u64,
/// height reported by peer on ping
@@ -181,7 +183,8 @@ impl PeerStats {
PeerStats {
state: state.to_string(),
addr: addr,
version: peer.info.version,
version: peer.info.version.clone(),
user_agent: peer.info.user_agent.clone(),
total_difficulty: peer.info.total_difficulty().to_num(),
height: peer.info.height(),
direction: direction.to_string(),
+7 -2
View File
@@ -39,6 +39,7 @@ enum PeerColumn {
TotalDifficulty,
Direction,
Version,
UserAgent,
}
impl PeerColumn {
@@ -50,6 +51,7 @@ impl PeerColumn {
PeerColumn::Version => "Version",
PeerColumn::TotalDifficulty => "Total Difficulty",
PeerColumn::Direction => "Direction",
PeerColumn::UserAgent => "User Agent",
}
}
}
@@ -77,6 +79,7 @@ impl TableViewItem<PeerColumn> for PeerStats {
).to_string(),
PeerColumn::Direction => self.direction.clone(),
PeerColumn::Version => self.version.to_string(),
PeerColumn::UserAgent => self.user_agent.clone(),
}
}
@@ -104,6 +107,7 @@ impl TableViewItem<PeerColumn> for PeerStats {
PeerColumn::TotalDifficulty => self.total_difficulty.cmp(&other.total_difficulty),
PeerColumn::Direction => self.direction.cmp(&other.direction),
PeerColumn::Version => self.version.cmp(&other.version),
PeerColumn::UserAgent => self.user_agent.cmp(&other.user_agent),
}
}
}
@@ -116,11 +120,12 @@ impl TUIStatusListener for TUIPeerView {
.column(PeerColumn::Address, "Address", |c| c.width_percent(16))
.column(PeerColumn::State, "State", |c| c.width_percent(8))
.column(PeerColumn::UsedBandwidth, "Used bandwidth", |c| {
c.width_percent(24)
c.width_percent(16)
}).column(PeerColumn::Direction, "Direction", |c| c.width_percent(8))
.column(PeerColumn::TotalDifficulty, "Total Difficulty", |c| {
c.width_percent(24)
}).column(PeerColumn::Version, "Version", |c| c.width_percent(16));
}).column(PeerColumn::Version, "Version", |c| c.width_percent(8))
.column(PeerColumn::UserAgent, "User Agent", |c| c.width_percent(16));
let peer_status_view = BoxView::with_full_screen(
LinearLayout::new(Orientation::Vertical)
.child(