Add last_seen to peer info (#1688)
* add last_seen to peer and update on ping/pong expose last_seen in tui * rustfmt * chrono serde features
This commit is contained in:
@@ -18,6 +18,8 @@ use std::cmp::Ordering;
|
||||
|
||||
use servers::{PeerStats, ServerStats};
|
||||
|
||||
use chrono::prelude::*;
|
||||
|
||||
use cursive::direction::Orientation;
|
||||
use cursive::traits::{Boxable, Identifiable};
|
||||
use cursive::view::View;
|
||||
@@ -54,9 +56,12 @@ impl TableViewItem<PeerColumn> for PeerStats {
|
||||
match column {
|
||||
PeerColumn::Address => self.addr.clone(),
|
||||
PeerColumn::State => self.state.clone(),
|
||||
PeerColumn::TotalDifficulty => {
|
||||
format!("{} D @ {} H", self.total_difficulty, self.height).to_string()
|
||||
}
|
||||
PeerColumn::TotalDifficulty => format!(
|
||||
"{} D @ {} H ({}s)",
|
||||
self.total_difficulty,
|
||||
self.height,
|
||||
(Utc::now() - self.last_seen).num_seconds(),
|
||||
).to_string(),
|
||||
PeerColumn::Direction => self.direction.clone(),
|
||||
PeerColumn::Version => self.version.to_string(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user