Summary
Reduce RPC calls by performing the reorg check only once after the last block range is streamed, rather than checking on every ReorgDetected notification during collection.
Background
Currently, in rewind mode, the scanner handles ReorgDetected notifications as they arrive, invalidating collected logs immediately. This is correct but potentially wasteful since:
- Reorgs are rare, especially during the collection phase
- Each reorg check may trigger additional processing
Proposed Optimisation
Defer the reorg check until the collection phase completes. Based on the assumption that reorgs are rare, this reduces unnecessary work in the common case.
Implementation Challenges
Because the event scanner stops BRS (Block Range Scanner) as soon as it collects enough events, BRS can't simply perform a reorg check at the end of the specified rewind block range.
Potential solutions:
- Add a callback/hook mechanism for the scanner to request a reorg check on-demand
Summary
Reduce RPC calls by performing the reorg check only once after the last block range is streamed, rather than checking on every ReorgDetected notification during collection.
Background
Currently, in rewind mode, the scanner handles ReorgDetected notifications as they arrive, invalidating collected logs immediately. This is correct but potentially wasteful since:
Proposed Optimisation
Defer the reorg check until the collection phase completes. Based on the assumption that reorgs are rare, this reduces unnecessary work in the common case.
Implementation Challenges
Because the event scanner stops BRS (Block Range Scanner) as soon as it collects enough events, BRS can't simply perform a reorg check at the end of the specified rewind block range.
Potential solutions: