add "User Agent" column to peers in tui (#1949)
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user