1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Use iterator adapter to find last indexed blockhash

This commit is contained in:
Roman Zeyde 2018-06-25 14:14:05 +03:00
parent 9a5f746cc0
commit 4a56884da2
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -85,14 +85,12 @@ impl Parser {
tx.send(rows).unwrap();
}
info!("indexed {} blocks", self.indexed_blockhashes.len());
let mut last_indexed_blockhash = None;
for header in self.current_headers.iter() {
if self.indexed_blockhashes.contains(header.hash()) {
last_indexed_blockhash = Some(header.hash());
}
}
if let Some(blockhash) = last_indexed_blockhash {
let rows = vec![last_indexed_block(blockhash)];
if let Some(last_header) = self.current_headers
.iter()
.take_while(|h| self.indexed_blockhashes.contains(h.hash()))
.last()
{
let rows = vec![last_indexed_block(last_header.hash())];
tx.send(Ok(vec![rows])).unwrap();
}
});