Skip to content

Commit 9ef094f

Browse files
authored
Bump version to 0.9.0-alpha + add parallelism-related docs (#255)
1 parent 3a6db5c commit 9ef094f

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ authors = ["OpenZeppelin"]
1414
edition = "2024"
1515
license = "MIT"
1616
repository = "https://github.com/OpenZeppelin/Event-Scanner"
17-
version = "0.8.0-alpha"
17+
version = "0.9.0-alpha"
1818

1919
[workspace.lints.clippy]
2020
pedantic = "warn"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Add `event-scanner` to your `Cargo.toml`:
5353

5454
```toml
5555
[dependencies]
56-
event-scanner = "0.8.0-alpha"
56+
event-scanner = "0.9.0-alpha"
5757
```
5858

5959
Create an event stream for the given event filters registered with the `EventScanner`:

src/event_scanner/scanner/mod.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,42 @@ mod latest;
2121
mod live;
2222
mod sync;
2323

24-
/// Maximum number of concurrent fetches for block ranges in the current scanner mode.
24+
/// Default number of maximum concurrent fetches for each scanner mode.
2525
pub const DEFAULT_MAX_CONCURRENT_FETCHES: usize = 24;
2626

2727
#[derive(Default)]
2828
pub struct Unspecified;
2929
pub struct Historic {
3030
pub(crate) from_block: BlockId,
3131
pub(crate) to_block: BlockId,
32+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
3233
pub(crate) max_concurrent_fetches: usize,
3334
}
3435
pub struct Live {
3536
pub(crate) block_confirmations: u64,
37+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
3638
pub(crate) max_concurrent_fetches: usize,
3739
}
3840
pub struct LatestEvents {
3941
pub(crate) count: usize,
4042
pub(crate) from_block: BlockId,
4143
pub(crate) to_block: BlockId,
4244
pub(crate) block_confirmations: u64,
45+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
4346
pub(crate) max_concurrent_fetches: usize,
4447
}
4548
#[derive(Default)]
4649
pub struct Synchronize;
4750
pub struct SyncFromLatestEvents {
4851
pub(crate) count: usize,
4952
pub(crate) block_confirmations: u64,
53+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
5054
pub(crate) max_concurrent_fetches: usize,
5155
}
5256
pub struct SyncFromBlock {
5357
pub(crate) from_block: BlockId,
5458
pub(crate) block_confirmations: u64,
59+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
5560
pub(crate) max_concurrent_fetches: usize,
5661
}
5762

@@ -138,18 +143,24 @@ impl EventScannerBuilder<Unspecified> {
138143
///
139144
/// The scanner streams events in chronological order (oldest to newest) within the specified
140145
/// block range. Events are delivered in batches as they are fetched from the provider, with
141-
/// batch sizes controlled by the `max_block_range` configuration.
146+
/// batch sizes controlled by the [`max_block_range`][max_block_range] configuration.
142147
///
143148
/// # Key behaviors
144149
///
145150
/// * **Continuous streaming**: Events are delivered in multiple messages as they are fetched
146151
/// * **Chronological order**: Events are always delivered oldest to newest
152+
/// * **Concurrent log fetching**: Logs are fetched concurrently to reduce the execution time.
153+
/// The maximum number of concurrent RPC calls is controlled by
154+
/// [`max_concurrent_fetches`][max_concurrent_fetches]
147155
/// * **Default range**: By default, scans from `Earliest` to `Latest` block
148-
/// * **Batch control**: Use `.max_block_range(n)` to control how many blocks are queried per
149-
/// RPC call
156+
/// * **Batch control**: Use [`max_block_range`][max_block_range] to control how many blocks are
157+
/// queried per RPC call
150158
/// * **Reorg handling**: Performs reorg checks when streaming events from non-finalized blocks;
151159
/// if a reorg is detected, streams events from the reorged blocks
152160
/// * **Completion**: The scanner completes when the entire range has been processed.
161+
///
162+
/// [max_block_range]: crate::EventScannerBuilder::max_block_range
163+
/// [max_concurrent_fetches]: crate::EventScannerBuilder::max_concurrent_fetches
153164
#[must_use]
154165
pub fn historic() -> EventScannerBuilder<Historic> {
155166
EventScannerBuilder::default()
@@ -308,6 +319,9 @@ impl EventScannerBuilder<Unspecified> {
308319
/// message, chronologically ordered
309320
/// * **One-shot operation**: The scanner completes after delivering messages; it does not
310321
/// continue streaming
322+
/// * **Concurrent log fetching**: Logs are fetched concurrently to reduce the execution time.
323+
/// The maximum number of concurrent RPC calls is controlled by
324+
/// [`max_concurrent_fetches`][max_concurrent_fetches]
311325
/// * **Flexible count**: If fewer than `count` events exist in the range, returns all available
312326
/// events
313327
/// * **Default range**: By default, scans from `Earliest` to `Latest` block
@@ -349,6 +363,7 @@ impl EventScannerBuilder<Unspecified> {
349363
/// [sync_from_latest]: EventScannerBuilder::from_latest
350364
/// [reorg]: crate::Notification::ReorgDetected
351365
/// [no_logs]: crate::Notification::NoPastLogsFound
366+
/// [max_concurrent_fetches]: crate::EventScannerBuilder#method.max_concurrent_fetches-1
352367
#[must_use]
353368
pub fn latest(count: usize) -> EventScannerBuilder<LatestEvents> {
354369
EventScannerBuilder::<LatestEvents>::new(count)

src/event_scanner/scanner/sync/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ impl EventScannerBuilder<Synchronize> {
7373
///
7474
/// * **No duplicates**: Events are not delivered twice across the phase transition
7575
/// * **Flexible count**: If fewer than `count` events exist, returns all available events
76+
/// * **Concurrent log fetching**: Logs are fetched concurrently to reduce the sync phase
77+
/// execution time. The maximum number of concurrent RPC calls is controlled by
78+
/// [`max_concurrent_fetches`][max_concurrent_fetches]
7679
/// * **Reorg handling**: Both phases handle reorgs appropriately:
7780
/// - Latest events phase: resets and rescans on reorg detection
7881
/// - Live phase: resets stream to the first post-reorg block that satisfies the configured
@@ -114,6 +117,7 @@ impl EventScannerBuilder<Synchronize> {
114117
/// [reorg]: crate::types::Notification::ReorgDetected
115118
/// [switch_to_live]: crate::types::Notification::SwitchingToLive
116119
/// [no_logs]: crate::types::Notification::NoPastLogsFound
120+
/// [max_concurrent_fetches]: crate::EventScannerBuilder#method.block_confirmations-4
117121
#[must_use]
118122
pub fn from_latest(self, count: usize) -> EventScannerBuilder<SyncFromLatestEvents> {
119123
EventScannerBuilder::<SyncFromLatestEvents>::new(count)
@@ -199,6 +203,9 @@ impl EventScannerBuilder<Synchronize> {
199203
///
200204
/// * **No duplicates**: Events are not delivered twice across the phase transition
201205
/// * **Chronological order**: Historical events are delivered oldest to newest
206+
/// * **Concurrent log fetching**: Logs are fetched concurrently to reduce the sync phase
207+
/// execution time. The maximum number of concurrent RPC calls is controlled by
208+
/// [`max_concurrent_fetches`][max_concurrent_fetches]
202209
/// * **Seamless transition**: Automatically switches to live mode when caught up
203210
/// * **Continuous operation**: Live phase continues indefinitely until the scanner is dropped
204211
/// * **Reorg detection**: When a reorg is detected, [`Notification::ReorgDetected`][reorg] is
@@ -217,6 +224,7 @@ impl EventScannerBuilder<Synchronize> {
217224
/// [start]: crate::event_scanner::EventScanner::start
218225
/// [reorg]: crate::types::Notification::ReorgDetected
219226
/// [switch_to_live]: crate::types::Notification::SwitchingToLive
227+
/// [max_concurrent_fetches]: crate::EventScannerBuilder#method.block_confirmations-3
220228
#[must_use]
221229
pub fn from_block(self, block_id: impl Into<BlockId>) -> EventScannerBuilder<SyncFromBlock> {
222230
EventScannerBuilder::<SyncFromBlock>::new(block_id.into())

0 commit comments

Comments
 (0)