Skip to content

Commit 304e54c

Browse files
committed
revert StartingLiveStream->SwitchingToLive
1 parent ecd7327 commit 304e54c

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

src/block_range_scanner/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(crate) async fn stream_live_blocks<N: Network>(
3333
return;
3434
};
3535

36-
if notify_after_first_block && !sender.try_stream(Notification::StartingLiveStream).await {
36+
if notify_after_first_block && !sender.try_stream(Notification::SwitchingToLive).await {
3737
return;
3838
}
3939

src/block_range_scanner/sync_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<N: Network> SyncHandler<N> {
197197
}
198198
};
199199

200-
if !sender.try_stream(Notification::StartingLiveStream).await {
200+
if !sender.try_stream(Notification::SwitchingToLive).await {
201201
return;
202202
}
203203

src/event_scanner/scanner/sync/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl EventScannerBuilder<Synchronize> {
1616
///
1717
/// 1. **Latest events phase**: Collects up to `count` most recent events by scanning backwards
1818
/// from the current chain tip. Events are delivered in chronological order.
19-
/// 2. **Automatic transition**: Emits [`Notification::StartingLiveStream`][switch_to_live] to
19+
/// 2. **Automatic transition**: Emits [`Notification::SwitchingToLive`][switch_to_live] to
2020
/// signal the mode change
2121
/// 3. **Live streaming phase**: Continuously monitors and streams new events as they arrive
2222
/// on-chain
@@ -50,7 +50,7 @@ impl EventScannerBuilder<Synchronize> {
5050
/// }
5151
/// Ok(Message::Notification(notification)) => {
5252
/// println!("Notification received: {:?}", notification);
53-
/// // You'll see Notification::StartingLiveStream when transitioning
53+
/// // You'll see Notification::SwitchingToLive when transitioning
5454
/// }
5555
/// Err(e) => {
5656
/// eprintln!("Error: {}", e);
@@ -101,7 +101,7 @@ impl EventScannerBuilder<Synchronize> {
101101
/// [subscribe]: crate::EventScanner::subscribe
102102
/// [start]: crate::event_scanner::EventScanner::start
103103
/// [reorg]: crate::types::Notification::ReorgDetected
104-
/// [switch_to_live]: crate::types::Notification::StartingLiveStream
104+
/// [switch_to_live]: crate::types::Notification::SwitchingToLive
105105
#[must_use]
106106
pub fn from_latest(self, count: usize) -> EventScannerBuilder<SyncFromLatestEvents> {
107107
EventScannerBuilder::<SyncFromLatestEvents>::new(count)
@@ -114,7 +114,7 @@ impl EventScannerBuilder<Synchronize> {
114114
///
115115
/// 1. **Historical sync phase**: Streams events from `from_block` up to the current confirmed
116116
/// tip
117-
/// 2. **Automatic transition**: Emits [`Notification::StartingLiveStream`][switch_to_live] to
117+
/// 2. **Automatic transition**: Emits [`Notification::SwitchingToLive`][switch_to_live] to
118118
/// signal the mode change
119119
/// 3. **Live streaming phase**: Continuously monitors and streams new events as they arrive
120120
/// on-chain
@@ -148,7 +148,7 @@ impl EventScannerBuilder<Synchronize> {
148148
/// }
149149
/// Ok(Message::Notification(notification)) => {
150150
/// println!("Notification received: {:?}", notification);
151-
/// // You'll see Notification::StartingLiveStream when transitioning
151+
/// // You'll see Notification::SwitchingToLive when transitioning
152152
/// }
153153
/// Err(e) => {
154154
/// eprintln!("Error: {}", e);
@@ -208,7 +208,7 @@ impl EventScannerBuilder<Synchronize> {
208208
/// [subscribe]: crate::EventScanner::subscribe
209209
/// [start]: crate::event_scanner::EventScanner::start
210210
/// [reorg]: crate::types::Notification::ReorgDetected
211-
/// [switch_to_live]: crate::types::Notification::StartingLiveStream
211+
/// [switch_to_live]: crate::types::Notification::SwitchingToLive
212212
#[must_use]
213213
pub fn from_block(self, block_id: impl Into<BlockId>) -> EventScannerBuilder<SyncFromBlock> {
214214
EventScannerBuilder::<SyncFromBlock>::new(block_id.into())

src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum ScannerMessage<T: Clone> {
1515

1616
#[derive(Copy, Debug, Clone, PartialEq)]
1717
pub enum Notification {
18-
StartingLiveStream,
18+
SwitchingToLive,
1919
ReorgDetected,
2020
}
2121

tests/block_range_scanner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async fn stream_from_starts_at_latest_once_it_has_enough_confirmations() -> anyh
9090
let mut stream = assert_empty!(stream);
9191

9292
provider.anvil_mine(Some(1), None).await?;
93-
assert_next!(stream, Notification::StartingLiveStream);
93+
assert_next!(stream, Notification::SwitchingToLive);
9494
assert_next!(stream, 20..=20);
9595
let mut stream = assert_empty!(stream);
9696

tests/sync/from_block.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async fn replays_historical_then_switches_to_live() -> anyhow::Result<()> {
3333
);
3434

3535
// chain tip reached
36-
assert_next!(stream, Notification::StartingLiveStream);
36+
assert_next!(stream, Notification::SwitchingToLive);
3737

3838
// now emit live events
3939
contract.increase().send().await?.watch().await?;
@@ -72,9 +72,9 @@ async fn sync_from_future_block_waits_until_minted() -> anyhow::Result<()> {
7272
// Act: emit an event that will be mined in block == future_start
7373
contract.increase().send().await?.watch().await?;
7474

75-
// only after the live event at `future_start_block` is emitted, will `StartingLiveStream` be
75+
// only after the live event at `future_start_block` is emitted, will `SwitchingToLive` be
7676
// streamed
77-
assert_next!(stream, Notification::StartingLiveStream);
77+
assert_next!(stream, Notification::SwitchingToLive);
7878
// Assert: the first streamed message arrives and contains the expected event
7979
assert_next!(stream, &[TestCounter::CountIncreased { newCount: U256::from(3) }]);
8080
assert_empty!(stream);
@@ -103,7 +103,7 @@ async fn block_confirmations_mitigate_reorgs() -> anyhow::Result<()> {
103103
TestCounter::CountIncreased { newCount: U256::from(2) }
104104
]
105105
);
106-
assert_next!(stream, Notification::StartingLiveStream);
106+
assert_next!(stream, Notification::SwitchingToLive);
107107

108108
// emit "live" events
109109
for _ in 0..2 {

tests/sync/from_latest.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ async fn happy_path_no_duplicates() -> anyhow::Result<()> {
3939
contract.increase().send().await?.watch().await?;
4040
contract.increase().send().await?.watch().await?;
4141

42-
// Assert `StartingLiveStream` after emitting live events, because the test finishes the "latest
42+
// Assert `SwitchingToLive` after emitting live events, because the test finishes the "latest
4343
// events" phase before new events are emitted, thus the "live" phase actually starts from a
4444
// future block.
45-
assert_next!(stream, Notification::StartingLiveStream);
45+
assert_next!(stream, Notification::SwitchingToLive);
4646
assert_event_sequence_final!(
4747
stream,
4848
&[
@@ -81,10 +81,10 @@ async fn fewer_historical_then_continues_live() -> anyhow::Result<()> {
8181
contract.increase().send().await?.watch().await?;
8282
contract.increase().send().await?.watch().await?;
8383

84-
// Assert `StartingLiveStream` after emitting live events, because the test finishes the "latest
84+
// Assert `SwitchingToLive` after emitting live events, because the test finishes the "latest
8585
// events" phase before new events are emitted, thus the "live" phase actually starts from a
8686
// future block.
87-
assert_next!(stream, Notification::StartingLiveStream);
87+
assert_next!(stream, Notification::SwitchingToLive);
8888
assert_event_sequence_final!(
8989
stream,
9090
&[
@@ -128,10 +128,10 @@ async fn exact_historical_count_then_live() -> anyhow::Result<()> {
128128
// Live continues
129129
contract.increase().send().await?.watch().await?;
130130

131-
// Assert `StartingLiveStream` after emitting live events, because the test finishes the "latest
131+
// Assert `SwitchingToLive` after emitting live events, because the test finishes the "latest
132132
// events" phase before new events are emitted, thus the "live" phase actually starts from a
133133
// future block.
134-
assert_next!(stream, Notification::StartingLiveStream);
134+
assert_next!(stream, Notification::SwitchingToLive);
135135
assert_next!(stream, &[TestCounter::CountIncreased { newCount: U256::from(5) }]);
136136
assert_empty!(stream);
137137

@@ -156,10 +156,10 @@ async fn no_historical_only_live_streams() -> anyhow::Result<()> {
156156

157157
// Latest events are empty
158158

159-
// Assert `StartingLiveStream` after emitting live events, because the test finishes the "latest
159+
// Assert `SwitchingToLive` after emitting live events, because the test finishes the "latest
160160
// events" phase before new events are emitted, thus the "live" phase actually starts from a
161161
// future block.
162-
assert_next!(stream, Notification::StartingLiveStream);
162+
assert_next!(stream, Notification::SwitchingToLive);
163163
assert_event_sequence_final!(
164164
stream,
165165
&[
@@ -207,10 +207,10 @@ async fn block_gaps_do_not_affect_number_of_events_streamed() -> anyhow::Result<
207207
// Immediately produce a new live event in a new block
208208
contract.increase().send().await?.watch().await?;
209209

210-
// Assert `StartingLiveStream` after emitting live events, because the test finishes the "latest
210+
// Assert `SwitchingToLive` after emitting live events, because the test finishes the "latest
211211
// events" phase before new events are emitted, thus the "live" phase actually starts from a
212212
// future block.
213-
assert_next!(stream, Notification::StartingLiveStream);
213+
assert_next!(stream, Notification::SwitchingToLive);
214214
assert_next!(stream, &[TestCounter::CountIncreased { newCount: U256::from(4) }]);
215215
assert_empty!(stream);
216216

@@ -242,7 +242,7 @@ async fn waiting_on_live_logs_arriving() -> anyhow::Result<()> {
242242
);
243243
assert_empty!(stream);
244244

245-
// `Notification::StartingLiveStream` arrives only on first live block received
245+
// `Notification::SwitchingToLive` arrives only on first live block received
246246

247247
Ok(())
248248
}

0 commit comments

Comments
 (0)