Skip to content

Commit 50517ff

Browse files
committed
feat: add back comments to scanner start functions
1 parent 2109b1b commit 50517ff

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

src/event_scanner/modes/historic.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff 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?;

src/event_scanner/modes/latest.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff 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?;

src/event_scanner/modes/live.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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?;

src/event_scanner/modes/sync.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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 =

0 commit comments

Comments
 (0)