Skip to content

Commit 8b79a56

Browse files
committed
ref: handle to token
1 parent 95bfb72 commit 8b79a56

File tree

24 files changed

+140
-142
lines changed

24 files changed

+140
-142
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ async fn run_scanner(
8787

8888
let subscription = scanner.subscribe(filter);
8989

90-
// Start the scanner and get the handle
91-
let handle = scanner.start().await?;
90+
// Start the scanner and get the token
91+
let token = scanner.start().await?;
9292

93-
// Access the stream using the handle
94-
let mut stream = subscription.stream(&handle);
93+
// Access the stream using the token
94+
let mut stream = subscription.stream(&token);
9595

9696
// Process messages from the stream
9797
while let Some(message) = stream.next().await {

examples/historical_scanning/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ async fn main() -> anyhow::Result<()> {
6565

6666
let subscription = scanner.subscribe(increase_filter);
6767

68-
let handle = scanner.start().await.expect("failed to start scanner");
68+
let token = scanner.start().await.expect("failed to start scanner");
6969

70-
// Access the stream using the handle (proves scanner is started)
71-
let mut stream = subscription.stream(&handle);
70+
// Access the stream using the token (proves scanner is started)
71+
let mut stream = subscription.stream(&token);
7272

7373
while let Some(message) = stream.next().await {
7474
match message {

examples/latest_events_scanning/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ async fn main() -> anyhow::Result<()> {
6666
_ = counter_contract.increase().send().await?;
6767
}
6868

69-
let handle = scanner.start().await?;
69+
let token = scanner.start().await?;
7070

71-
// Access the stream using the handle (proves scanner is started)
72-
let mut stream = subscription.stream(&handle);
71+
// Access the stream using the token (proves scanner is started)
72+
let mut stream = subscription.stream(&token);
7373

7474
while let Some(message) = stream.next().await {
7575
match message {

examples/live_scanning/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ async fn main() -> anyhow::Result<()> {
6363

6464
let subscription = scanner.subscribe(increase_filter);
6565

66-
let handle = scanner.start().await.expect("failed to start scanner");
66+
let token = scanner.start().await.expect("failed to start scanner");
6767

68-
// Access the stream using the handle (proves scanner is started)
69-
let mut stream = subscription.stream(&handle);
68+
// Access the stream using the token (proves scanner is started)
69+
let mut stream = subscription.stream(&token);
7070

7171
_ = counter_contract.increase().send().await?;
7272

examples/sync_from_block_scanning/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ async fn main() -> anyhow::Result<()> {
7272
let subscription = scanner.subscribe(increase_filter);
7373

7474
info!("Starting sync scanner...");
75-
let handle = scanner.start().await.expect("failed to start scanner");
75+
let token = scanner.start().await.expect("failed to start scanner");
7676

77-
// Access the stream using the handle (proves scanner is started)
78-
let mut stream = subscription.stream(&handle);
77+
// Access the stream using the token (proves scanner is started)
78+
let mut stream = subscription.stream(&token);
7979

8080
info!("Creating live events...");
8181
for i in 0..2 {

examples/sync_from_latest_scanning/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ async fn main() -> anyhow::Result<()> {
6767
_ = counter_contract.increase().send().await?;
6868
}
6969

70-
let handle = client.start().await.expect("failed to start scanner");
70+
let token = client.start().await.expect("failed to start scanner");
7171

72-
// Access the stream using the handle (proves scanner is started)
73-
let mut stream = subscription.stream(&handle);
72+
// Access the stream using the token (proves scanner is started)
73+
let mut stream = subscription.stream(&token);
7474

7575
// emit some events for live mode to pick up
7676
_ = counter_contract.increase().send().await?;

src/event_scanner/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ pub use scanner::{
1010
EventScanner, EventScannerBuilder, Historic, LatestEvents, Live, SyncFromBlock,
1111
SyncFromLatestEvents,
1212
};
13-
pub use stream::{EventSubscription, ScannerHandle};
13+
pub use stream::{EventSubscription, ScannerToken};

src/event_scanner/scanner/historic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::common::{ConsumerMode, handle_stream};
88
use crate::{
99
EventScannerBuilder, ScannerError,
1010
event_scanner::{
11-
ScannerHandle,
11+
ScannerToken,
1212
scanner::{EventScanner, Historic},
1313
},
1414
robust_provider::IntoRobustProvider,
@@ -87,7 +87,7 @@ impl<N: Network> EventScanner<Historic, N> {
8787
/// Can error out if the service fails to start.
8888
///
8989
/// [subscribe]: EventScanner::subscribe
90-
pub async fn start(self) -> Result<ScannerHandle, ScannerError> {
90+
pub async fn start(self) -> Result<ScannerToken, ScannerError> {
9191
let client = self.block_range_scanner.run()?;
9292
let stream = client.stream_historical(self.config.from_block, self.config.to_block).await?;
9393

@@ -98,7 +98,7 @@ impl<N: Network> EventScanner<Historic, N> {
9898
handle_stream(stream, &provider, &listeners, ConsumerMode::Stream).await;
9999
});
100100

101-
Ok(ScannerHandle::new())
101+
Ok(ScannerToken::new())
102102
}
103103
}
104104

src/event_scanner/scanner/latest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use alloy::{
77
use super::common::{ConsumerMode, handle_stream};
88
use crate::{
99
EventScannerBuilder, ScannerError,
10-
event_scanner::{EventScanner, LatestEvents, ScannerHandle},
10+
event_scanner::{EventScanner, LatestEvents, ScannerToken},
1111
robust_provider::IntoRobustProvider,
1212
};
1313

@@ -91,7 +91,7 @@ impl<N: Network> EventScanner<LatestEvents, N> {
9191
/// Can error out if the service fails to start.
9292
///
9393
/// [subscribe]: EventScanner::subscribe
94-
pub async fn start(self) -> Result<ScannerHandle, ScannerError> {
94+
pub async fn start(self) -> Result<ScannerToken, ScannerError> {
9595
let client = self.block_range_scanner.run()?;
9696
let stream = client.rewind(self.config.from_block, self.config.to_block).await?;
9797

@@ -108,7 +108,7 @@ impl<N: Network> EventScanner<LatestEvents, N> {
108108
.await;
109109
});
110110

111-
Ok(ScannerHandle::new())
111+
Ok(ScannerToken::new())
112112
}
113113
}
114114

src/event_scanner/scanner/live.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use alloy::network::Network;
33
use super::common::{ConsumerMode, handle_stream};
44
use crate::{
55
EventScannerBuilder, ScannerError,
6-
event_scanner::{EventScanner, ScannerHandle, scanner::Live},
6+
event_scanner::{EventScanner, ScannerToken, scanner::Live},
77
robust_provider::IntoRobustProvider,
88
};
99

@@ -43,7 +43,7 @@ impl<N: Network> EventScanner<Live, N> {
4343
/// Can error out if the service fails to start.
4444
///
4545
/// [subscribe]: EventScanner::subscribe
46-
pub async fn start(self) -> Result<ScannerHandle, ScannerError> {
46+
pub async fn start(self) -> Result<ScannerToken, ScannerError> {
4747
let client = self.block_range_scanner.run()?;
4848
let stream = client.stream_live(self.config.block_confirmations).await?;
4949

@@ -54,7 +54,7 @@ impl<N: Network> EventScanner<Live, N> {
5454
handle_stream(stream, &provider, &listeners, ConsumerMode::Stream).await;
5555
});
5656

57-
Ok(ScannerHandle::new())
57+
Ok(ScannerToken::new())
5858
}
5959
}
6060

0 commit comments

Comments
 (0)