1
0
Fork 0
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:
Roman Zeyde 2019-05-14 21:25:43 +03:00 committed by GitHub
commit 5282497a2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
}
}