From b0ef1343dd71c28bdce74212aa136e827b9c54a8 Mon Sep 17 00:00:00 2001 From: Andrea Simeoni Date: Sat, 26 Nov 2022 17:42:41 +0100 Subject: [PATCH] fix: close example subscriptions after 2 emitted items (#1892) cargo +nightly fmt Co-authored-by: Andrea Simeoni <> --- examples/subscribe_events_by_type.rs | 3 +-- examples/subscribe_logs.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/subscribe_events_by_type.rs b/examples/subscribe_events_by_type.rs index 9a3aa56f..bc917ccb 100644 --- a/examples/subscribe_events_by_type.rs +++ b/examples/subscribe_events_by_type.rs @@ -27,14 +27,13 @@ async fn main() -> Result<(), Box> { // refine the event filter let event = Contract::event_of_type::(&client) .from_block(16022082) - .to_block(16022282) .address(ValueOrArray::Array(vec![ PRICE_FEED_1.parse()?, PRICE_FEED_2.parse()?, PRICE_FEED_3.parse()?, ])); - let mut stream = event.subscribe_with_meta().await?; + let mut stream = event.subscribe_with_meta().await?.take(2); // Note that `log` has type AnswerUpdatedFilter while let Some(Ok((log, meta))) = stream.next().await { diff --git a/examples/subscribe_logs.rs b/examples/subscribe_logs.rs index 9cd57e98..c85e3728 100644 --- a/examples/subscribe_logs.rs +++ b/examples/subscribe_logs.rs @@ -17,7 +17,7 @@ async fn main() -> Result<()> { let erc20_transfer_filter = Filter::new().from_block(last_block - 25).event("Transfer(address,address,uint256)"); - let mut stream = client.subscribe_logs(&erc20_transfer_filter).await?; + let mut stream = client.subscribe_logs(&erc20_transfer_filter).await?.take(2); while let Some(log) = stream.next().await { println!(