Use startup_time from system.connected (#300)

* Handle startup time

* Remove dead code

* Bump protocol version + FE changes
This commit is contained in:
Maciej Hirsz
2020-11-30 12:05:49 +01:00
committed by GitHub
parent ebb01c1a7d
commit 262dbd6f14
11 changed files with 27 additions and 27 deletions
+10 -7
View File
@@ -33,16 +33,19 @@ pub struct Node {
location: Option<Arc<NodeLocation>>,
/// Flag marking if the node is stale (not syncing or producing blocks)
stale: bool,
/// Connected at timestamp
connected_at: Timestamp,
/// Unix timestamp for when node started up (falls back to connection time)
startup_time: Option<Timestamp>,
/// Network state
network_state: Option<Bytes>,
}
impl Node {
pub fn new(details: NodeDetails) -> Self {
Node {
pub fn new(mut details: NodeDetails) -> Self {
let startup_time = details.startup_time
.take()
.and_then(|time| time.parse().ok());
Node {
details,
stats: NodeStats::default(),
io: NodeIO::default(),
@@ -52,7 +55,7 @@ impl Node {
hardware: NodeHardware::default(),
location: None,
stale: false,
connected_at: now(),
startup_time,
network_state: None,
}
}
@@ -230,7 +233,7 @@ impl Node {
}
}
pub fn connected_at(&self) -> Timestamp {
self.connected_at
pub fn startup_time(&self) -> Option<Timestamp> {
self.startup_time
}
}