Skip to content

Conversation

@yug49
Copy link
Contributor

@yug49 yug49 commented Dec 7, 2025

Resolves #227

Description

This PR optimizes the historic/sync scanning modes by deferring reorg checks until after all block ranges have been streamed.

Changes

  1. stream_historical_range in common.rs:
  • Phase 1: Stream all finalized blocks without any reorg checks (unchanged)
  • Phase 2: Stream all non-finalized block ranges without intermediate reorg checks
  • After streaming the last range, check if the end block still exists (single reorg check)
  • If a reorg is detected (BlockNotFound), send ReorgDetected notification and re-stream all non-finalized blocks
  • Repeat until stable (end block exists or has become finalized)
  1. handle_historical in block_range_scanner.rs:
  • Removed ReorgHandler instantiation and parameter passing (no longer needed for historic mode)
  1. sync_handler.rs:
  • catchup_historical_blocks no longer requires reorg_handler parameter
  • Reorg handling during sync's historical phase now uses the optimized approach

@yug49 yug49 changed the title perf(historic): optimized reorg handling by deferring checks to end of stream enhancement: optimized reorg handling by deferring checks to end of stream (historic) Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Historic: Perform Reorg Check Only After Streaming Last Block Range

1 participant