Examples/watch_block: show how to retrieve block metadata (#1058)
* better watch example * put back normal interval
This commit is contained in:
parent
3d4feccabf
commit
c9ef5769e2
|
@ -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(())
|
||||||
|
|
Loading…
Reference in New Issue