2020-06-17 18:01:20 +00:00
|
|
|
use ethers::prelude::*;
|
2020-06-22 08:44:08 +00:00
|
|
|
use std::time::Duration;
|
2020-06-17 18:01:20 +00:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> anyhow::Result<()> {
|
2020-06-21 07:17:11 +00:00
|
|
|
let ws = Ws::connect("ws://localhost:8546").await?;
|
2020-06-22 08:44:08 +00:00
|
|
|
let provider = Provider::new(ws).interval(Duration::from_millis(2000));
|
|
|
|
let mut stream = provider.watch_blocks().await?.stream();
|
2020-06-17 18:01:20 +00:00
|
|
|
while let Some(block) = stream.next().await {
|
|
|
|
dbg!(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|