Examples/watch_block: show how to retrieve block metadata (#1058)

* better watch example

* put back normal interval
This commit is contained in:
Nicolas Gailly 2022-03-18 05:08:15 +00:00 committed by GitHub
parent 3d4feccabf
commit c9ef5769e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -8,7 +8,8 @@ async fn main() -> eyre::Result<()> {
let provider = Provider::new(ws).interval(Duration::from_millis(2000)); let provider = Provider::new(ws).interval(Duration::from_millis(2000));
let mut stream = provider.watch_blocks().await?.take(5); let mut stream = provider.watch_blocks().await?.take(5);
while let Some(block) = stream.next().await { while let Some(block) = stream.next().await {
dbg!(block); let block = provider.get_block(block).await?.unwrap();
println!("Ts: {:?}, block number: {} -> {:?}",block.timestamp,block.number.unwrap(),block.hash.unwrap());
} }
Ok(()) Ok(())