mirror of
https://github.com/romanz/electrs.git
synced 2025-02-24 15:02:21 +01:00
Merge pull request #141 from dagurval/index-height
[stats] Update index height when chain shortens
This commit is contained in:
commit
5282497a2d
1 changed files with 5 additions and 0 deletions
|
@ -305,6 +305,10 @@ impl Stats {
|
|||
for tx in &block.txdata {
|
||||
self.vsize.inc_by(tx.get_weight() as i64 / 4);
|
||||
}
|
||||
self.update_height(height);
|
||||
}
|
||||
|
||||
fn update_height(&self, height: usize) {
|
||||
self.height.set(height as i64);
|
||||
}
|
||||
|
||||
|
@ -422,6 +426,7 @@ impl Index {
|
|||
fetcher.join().expect("block fetcher failed");
|
||||
self.headers.write().unwrap().apply(new_headers, tip);
|
||||
assert_eq!(tip, self.headers.read().unwrap().tip());
|
||||
self.stats.update_height(self.headers.read().unwrap().len() - 1);
|
||||
Ok(tip)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue