Skip to content

Commit e366272

Browse files
committed
stream to start
1 parent 872a842 commit e366272

File tree

12 files changed

+23
-26
lines changed

12 files changed

+23
-26
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,8 @@ let scanner = EventScanner::latest()
130130
- `block_read_limit(usize)` – Sets the maximum number of blocks to process per read operation. This prevents RPC provider errors from overly large block range queries.
131131
- Connect with `connect_ws::<Ethereum>(url)`, `connect_ipc::<Ethereum>(path)`, or `connect(provider)`.
132132

133-
**Mode-specific APIs:**
134-
- Live: `client.stream()` – Start streaming new blocks
135-
- Historical: `client.stream()` – Process historical range (configured during setup)
136-
- Sync: `client.stream()` – Process historical then transition to live
137-
- Latest: `client.stream()` – Process a set number of events
133+
**Starting the Scanner:**
134+
Invoking `scanner.start()` starts the scanner in the specified mode.
138135

139136
### Defining Event Filters
140137

examples/historical_scanning/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async fn main() -> anyhow::Result<()> {
6060
let mut stream = client.create_event_stream(increase_filter);
6161

6262
sleep(Duration::from_secs(10)).await;
63-
client.stream().await.expect("failed to start scanner");
63+
client.run().await.expect("failed to start scanner");
6464

6565
while let Some(message) = stream.next().await {
6666
match message {

examples/simple_counter/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async fn main() -> anyhow::Result<()> {
5757
let mut stream = client.create_event_stream(increase_filter);
5858

5959
let task_1 = tokio::spawn(async move {
60-
client.stream().await.expect("failed to start scanner");
60+
client.start().await.expect("failed to start scanner");
6161
});
6262

6363
let task_2 = tokio::spawn(async move {

src/event_lib/modes/historic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<N: Network> HistoricEventScanner<N> {
114114
/// # Errors
115115
///
116116
/// * `EventScannerMessage::ServiceShutdown` - if the service is already shutting down.
117-
pub async fn stream(self) -> Result<(), EventScannerError> {
117+
pub async fn run(self) -> Result<(), EventScannerError> {
118118
self.inner.stream_historical(self.config.from_block, self.config.to_block).await
119119
}
120120
}

src/event_lib/modes/latest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl<N: Network> LatestEventScanner<N> {
188188
///
189189
/// * `EventScannerMessage::ServiceShutdown` - if the service is already shutting down.
190190
#[allow(clippy::unused_async)]
191-
pub async fn stream(self) -> Result<(), EventScannerError> {
191+
pub async fn start(self) -> Result<(), EventScannerError> {
192192
unimplemented!()
193193
}
194194
}

src/event_lib/modes/live.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<N: Network> LiveEventScanner<N> {
101101
/// # Errors
102102
///
103103
/// * `EventScannerMessage::ServiceShutdown` - if the service is already shutting down.
104-
pub async fn stream(self) -> Result<(), EventScannerError> {
104+
pub async fn start(self) -> Result<(), EventScannerError> {
105105
self.inner.stream_live(self.config.block_confirmations).await
106106
}
107107
}

src/event_lib/modes/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<N: Network> SyncEventScanner<N> {
114114
/// # Errors
115115
///
116116
/// * `EventScannerMessage::ServiceShutdown` - if the service is already shutting down.
117-
pub async fn stream(self) -> Result<(), EventScannerError> {
117+
pub async fn start(self) -> Result<(), EventScannerError> {
118118
self.inner.stream_from(self.config.from_block, self.config.block_confirmations).await
119119
}
120120
}

tests/historic_mode/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async fn processes_events_within_specified_historical_range() -> anyhow::Result<
4242
.await?;
4343
let mut stream = client.create_event_stream(filter).take(expected_event_count);
4444

45-
tokio::spawn(async move { client.stream().await });
45+
tokio::spawn(async move { client.run().await });
4646

4747
let event_count = Arc::new(AtomicUsize::new(0));
4848
let event_count_clone = Arc::clone(&event_count);

tests/live_mode/basic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async fn basic_single_event_scanning() -> anyhow::Result<()> {
2828
let mut client = EventScanner::live().connect_ws::<Ethereum>(anvil.ws_endpoint_url()).await?;
2929
let mut stream = client.create_event_stream(filter).take(expected_event_count);
3030

31-
tokio::spawn(async move { client.stream().await });
31+
tokio::spawn(async move { client.start().await });
3232

3333
for _ in 0..expected_event_count {
3434
contract.increase().send().await?.watch().await?;
@@ -88,7 +88,7 @@ async fn multiple_contracts_same_event_isolate_callbacks() -> anyhow::Result<()>
8888
let a_stream = client.create_event_stream(a_filter);
8989
let b_stream = client.create_event_stream(b_filter);
9090

91-
tokio::spawn(async move { client.stream().await });
91+
tokio::spawn(async move { client.start().await });
9292

9393
for _ in 0..expected_events_a {
9494
a.increase().send().await?.watch().await?;
@@ -160,7 +160,7 @@ async fn multiple_events_same_contract() -> anyhow::Result<()> {
160160
let mut incr_stream = client.create_event_stream(increase_filter).take(expected_incr_events);
161161
let mut decr_stream = client.create_event_stream(decrease_filter).take(expected_decr_events);
162162

163-
tokio::spawn(async move { client.stream().await });
163+
tokio::spawn(async move { client.start().await });
164164

165165
for _ in 0..expected_incr_events {
166166
contract.increase().send().await?.watch().await?;
@@ -227,7 +227,7 @@ async fn signature_matching_ignores_irrelevant_events() -> anyhow::Result<()> {
227227

228228
let mut stream = client.create_event_stream(filter).take(num_of_events);
229229

230-
tokio::spawn(async move { client.stream().await });
230+
tokio::spawn(async move { client.start().await });
231231

232232
for _ in 0..num_of_events {
233233
contract.increase().send().await?.watch().await?;
@@ -260,7 +260,7 @@ async fn live_filters_malformed_signature_graceful() -> anyhow::Result<()> {
260260

261261
let mut stream = client.create_event_stream(filter).take(num_of_events);
262262

263-
tokio::spawn(async move { client.stream().await });
263+
tokio::spawn(async move { client.start().await });
264264

265265
for _ in 0..num_of_events {
266266
contract.increase().send().await?.watch().await?;

tests/live_mode/optional_fields.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async fn track_all_events_from_contract() -> anyhow::Result<()> {
2727

2828
let mut stream = client.create_event_stream(filter).take(expected_event_count);
2929

30-
tokio::spawn(async move { client.stream().await });
30+
tokio::spawn(async move { client.start().await });
3131

3232
// Generate both increase and decrease events
3333
for _ in 0..expected_event_count {
@@ -67,7 +67,7 @@ async fn track_all_events_in_block_range() -> anyhow::Result<()> {
6767

6868
let mut stream = client.create_event_stream(filter).take(expected_event_count);
6969

70-
tokio::spawn(async move { client.stream().await });
70+
tokio::spawn(async move { client.start().await });
7171

7272
// Generate events from our contract
7373
for _ in 0..expected_event_count {
@@ -112,7 +112,7 @@ async fn mixed_optional_and_required_filters() -> anyhow::Result<()> {
112112
client.create_event_stream(specific_filter).take(expected_specific_count);
113113
let mut all_stream = client.create_event_stream(all_events_filter).take(expected_all_count);
114114

115-
tokio::spawn(async move { client.stream().await });
115+
tokio::spawn(async move { client.start().await });
116116

117117
// First increase the counter to have some balance
118118
for _ in 0..expected_all_count {

0 commit comments

Comments
 (0)