1
0
Fork 0
mirror of https://github.com/romanz/electrs.git synced 2025-02-24 23:08:39 +01:00

Move fmt::Debug trait to HeaderEntry

This commit is contained in:
Roman Zeyde 2018-05-30 18:34:38 +03:00
parent 313420b0e1
commit a101935f41
No known key found for this signature in database
GPG key ID: 87CAE5FA46917CBB

View file

@ -45,6 +45,21 @@ impl HeaderEntry {
}
}
impl fmt::Debug for HeaderEntry {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let last_block_time = time::at_utc(time::Timespec::new(self.header().time as i64, 0))
.rfc3339()
.to_string();
write!(
f,
"best={} height={} @ {}",
self.hash(),
self.height(),
last_block_time,
)
}
}
pub struct HeaderList {
headers: Vec<HeaderEntry>,
tip: Sha256dHash,
@ -117,21 +132,3 @@ impl HeaderList {
missing
}
}
impl fmt::Debug for HeaderList {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let last_block_time = self.headers.last().map_or("N/A".to_string(), |h| {
time::at_utc(time::Timespec::new(h.header.time as i64, 0))
.rfc3339()
.to_string()
});
write!(
f,
"best={} height={} @ {}",
self.height(),
self.tip(),
last_block_time,
)
}
}