Skip to content

Commit 5fc4121

Browse files
LeoPatOZ0xNeshi
andauthored
Update readme example (#213)
Co-authored-by: Nenad <[email protected]>
1 parent 21cba9f commit 5fc4121

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Create an event stream for the given event filters registered with the `EventSca
6262
use alloy::{network::Ethereum, providers::{Provider, ProviderBuilder}, sol_types::SolEvent};
6363
use event_scanner::{EventFilter, EventScannerBuilder, Message, robust_provider::RobustProviderBuilder};
6464
use tokio_stream::StreamExt;
65+
use tracing::{error, info};
6566

6667
use crate::MyContract;
6768

@@ -76,7 +77,8 @@ async fn run_scanner(
7677
// Configure scanner with custom batch size (optional)
7778
let mut scanner = EventScannerBuilder::live()
7879
.max_block_range(500) // Process up to 500 blocks per batch
79-
.connect(robust_provider);
80+
.connect(robust_provider)
81+
.await?;
8082

8183
// Register an event listener
8284
let filter = EventFilter::new()
@@ -91,14 +93,16 @@ async fn run_scanner(
9193
// Process messages from the stream
9294
while let Some(message) = stream.next().await {
9395
match message {
94-
Message::Data(logs) => {
95-
println!("Received {} logs: {logs:?}", logs.len());
96+
Ok(Message::Data(logs)) => {
97+
for log in logs {
98+
info!("Callback successfully executed with event {:?}", log.inner.data);
99+
}
96100
}
97-
Message::Notification(notification) => {
98-
println!("Notification received: {notification:?}");
101+
Ok(Message::Notification(notification)) => {
102+
info!("Received notification: {:?}", notification);
99103
}
100-
Message::Error(err) => {
101-
eprintln!("Error: {err}");
104+
Err(e) => {
105+
error!("Received error: {}", e);
102106
}
103107
}
104108
}

0 commit comments

Comments
 (0)