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:
parent
313420b0e1
commit
a101935f41
1 changed files with 15 additions and 18 deletions
33
src/util.rs
33
src/util.rs
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue