From b16fbf090e5510a15f5dc02ccbf7d8e187ff9426 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 25 Apr 2022 19:46:17 +0000 Subject: [PATCH] subscribe instead of watch --- examples/{watch_blocks.rs => subscribe_blocks.rs} | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) rename examples/{watch_blocks.rs => subscribe_blocks.rs} (54%) diff --git a/examples/watch_blocks.rs b/examples/subscribe_blocks.rs similarity index 54% rename from examples/watch_blocks.rs rename to examples/subscribe_blocks.rs index 8602824e..78a1106d 100644 --- a/examples/watch_blocks.rs +++ b/examples/subscribe_blocks.rs @@ -3,12 +3,11 @@ use std::time::Duration; #[tokio::main] async fn main() -> anyhow::Result<()> { - // let ws = Ws::connect("ws://10.11.12.16:8545").await?; - let ws = Ws::connect("ws://10.11.12.16:8946").await?; + let ws = Ws::connect("ws://10.11.12.16:8545").await?; + // let ws = Ws::connect("ws://10.11.12.16:8946").await?; let provider = Provider::new(ws).interval(Duration::from_secs(1)); - let mut stream = provider.watch_blocks().await?.take(5); - while let Some(block_number) = stream.next().await { - let block = provider.get_block(block_number).await?.unwrap(); + let mut stream = provider.subscribe_blocks().await?.take(5); + while let Some(block) = stream.next().await { println!( "Ts: {:?}, block number: {} -> {:?}", block.timestamp,