Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix: close example subscriptions after 2 emitted items (#1892)
Browse files Browse the repository at this point in the history
cargo +nightly fmt

Co-authored-by: Andrea Simeoni <>
  • Loading branch information
0xMelkor authored Nov 26, 2022
1 parent 585280f commit b0ef134
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions examples/subscribe_events_by_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ async fn main() -> Result<(), Box<dyn Error>> {
// refine the event filter
let event = Contract::event_of_type::<AnswerUpdatedFilter>(&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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/subscribe_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down

0 comments on commit b0ef134

Please sign in to comment.