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:
parent
9a5f746cc0
commit
4a56884da2
14
src/parse.rs
14
src/parse.rs
@ -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();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user