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:
Antioch Peverell
2018-10-08 13:39:52 +01:00
committed by GitHub
parent fd2eda2308
commit de5b6868fb
6 changed files with 25 additions and 27 deletions
+8 -3
View File
@@ -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(),
}