Skip to content

Commit

Permalink
don't increment block for block number 0
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Jan 29, 2024
1 parent 707149e commit ee9265b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/snapshot/src/segments/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ impl<DB: Database> Segment<DB> for Headers {
provider.tx_ref().cursor_read::<tables::CanonicalHeaders>()?;
let canonical_headers_walker = canonical_headers_cursor.walk_range(block_range)?;

let mut headers =
headers_walker.zip(header_td_walker).zip(canonical_headers_walker).peekable();
while let Some(((header_entry, header_td_entry), canonical_header_entry)) = headers.next() {
for ((header_entry, header_td_entry), canonical_header_entry) in
headers_walker.zip(header_td_walker).zip(canonical_headers_walker)
{
let (header_block, header) = header_entry?;
let (header_td_block, header_td) = header_td_entry?;
let (canonical_header_block, canonical_header) = canonical_header_entry?;

debug_assert_eq!(header_block, header_td_block);
debug_assert_eq!(header_td_block, canonical_header_block);

snapshot_writer.append_header(header, header_td.0, canonical_header)?;

if headers.peek().is_some() {
if header_block > 0 {
let _snapshot_block = snapshot_writer.increment_block(SnapshotSegment::Headers)?;
debug_assert_eq!(_snapshot_block, header_block);
}

snapshot_writer.append_header(header, header_td.0, canonical_header)?;
}

Ok(())
Expand Down

0 comments on commit ee9265b

Please sign in to comment.