File tree Expand file tree Collapse file tree 4 files changed +37
-8
lines changed
Expand file tree Collapse file tree 4 files changed +37
-8
lines changed Original file line number Diff line number Diff line change @@ -114,11 +114,14 @@ impl<N: Network> HistoricEventScanner<N> {
114114 ReceiverStream :: new ( receiver)
115115 }
116116
117- /// Calls stream historical
117+ /// Starts the scanner in historical mode.
118+ ///
119+ /// Scans from `from_block` to `to_block` (inclusive), emitting block ranges
120+ /// and matching logs to registered listeners.
118121 ///
119122 /// # Errors
120123 ///
121- /// * `EventScannerMessage::ServiceShutdown` - if the service is already shutting down.
124+ /// - `EventScannerMessage::ServiceShutdown` if the service is already shutting down.
122125 pub async fn start ( self ) -> Result < ( ) , EventScannerError > {
123126 let client = self . block_range_scanner . run ( ) ?;
124127 let stream = client. stream_historical ( self . config . from_block , self . config . to_block ) . await ?;
Original file line number Diff line number Diff line change @@ -135,11 +135,21 @@ impl<N: Network> LatestEventScanner<N> {
135135 ReceiverStream :: new ( receiver)
136136 }
137137
138- /// Calls stream latest
138+ /// Scans a block range and collects the latest `count` matching events per registered listener.
139+ ///
140+ /// Emits a single message per listener with up to `count` logs, ordered oldest→newest.
141+ ///
142+ /// # Reorg behavior
143+ ///
144+ /// Performs a reverse-ordered rewind over the range, periodically checking the tip hash. If a
145+ /// reorg is detected, emits [`ScannerStatus::ReorgDetected`], resets the rewind start to the
146+ /// updated tip, and resumes until completion. Final log delivery preserves chronological order.
139147 ///
140148 /// # Errors
141149 ///
142- /// * `EventScannerMessage::ServiceShutdown` - if the service is already shutting down.
150+ /// - Returns `EventScannerError` if the scanner fails to start or fetching logs fails.
151+ ///
152+ /// [`ScannerStatus::ReorgDetected`]: crate::types::ScannerStatus::ReorgDetected
143153 pub async fn start ( self ) -> Result < ( ) , EventScannerError > {
144154 let client = self . block_range_scanner . run ( ) ?;
145155 let stream = client. rewind ( self . config . from_block , self . config . to_block ) . await ?;
Original file line number Diff line number Diff line change @@ -104,11 +104,19 @@ impl<N: Network> LiveEventScanner<N> {
104104 ReceiverStream :: new ( receiver)
105105 }
106106
107- /// Calls stream live
107+ /// Starts the scanner in live mode.
108+ ///
109+ /// Streams new blocks as they are produced, applying the configured
110+ /// `block_confirmations` to mitigate reorgs.
111+ ///
112+ /// # Reorg behavior
113+ ///
114+ /// - Emits [`ScannerStatus::ReorgDetected`] and adjusts the next confirmed
115+ /// range using `block_confirmations` to re-emit the confirmed portion.
108116 ///
109117 /// # Errors
110118 ///
111- /// * `EventScannerMessage::ServiceShutdown` - if the service is already shutting down.
119+ /// - `EventScannerMessage::ServiceShutdown` if the service is already shutting down.
112120 pub async fn start ( self ) -> Result < ( ) , EventScannerError > {
113121 let client = self . block_range_scanner . run ( ) ?;
114122 let stream = client. stream_live ( self . config . block_confirmations ) . await ?;
Original file line number Diff line number Diff line change @@ -114,11 +114,19 @@ impl<N: Network> SyncEventScanner<N> {
114114 ReceiverStream :: new ( receiver)
115115 }
116116
117- /// Calls stream from
117+ /// Starts the scanner in sync (historical → live) mode.
118+ ///
119+ /// Streams from `from_block` up to the current confirmed tip using the configured
120+ /// `block_confirmations`, then continues streaming new confirmed ranges live.
121+ ///
122+ /// # Reorg behavior
123+ ///
124+ /// - In live mode, emits [`ScannerStatus::ReorgDetected`] and adjusts the next confirmed range
125+ /// using `block_confirmations` to re-emit the confirmed portion.
118126 ///
119127 /// # Errors
120128 ///
121- /// * `EventScannerMessage::ServiceShutdown` - if the service is already shutting down.
129+ /// - `EventScannerMessage::ServiceShutdown` if the service is already shutting down.
122130 pub async fn start ( self ) -> Result < ( ) , EventScannerError > {
123131 let client = self . block_range_scanner . run ( ) ?;
124132 let stream =
You can’t perform that action at this time.
0 commit comments