2021-04-08 06:52:31 +00:00
|
|
|
use ethers::prelude::*;
|
|
|
|
use std::time::Duration;
|
|
|
|
|
|
|
|
#[tokio::main]
|
2021-08-30 11:00:30 +00:00
|
|
|
#[cfg(feature = "ipc")]
|
2021-04-08 06:52:31 +00:00
|
|
|
async fn main() -> anyhow::Result<()> {
|
2021-10-29 12:29:35 +00:00
|
|
|
let provider =
|
|
|
|
Provider::connect_ipc("~/.ethereum/geth.ipc").await?.interval(Duration::from_millis(2000));
|
2021-04-08 06:52:31 +00:00
|
|
|
let block = provider.get_block_number().await?;
|
|
|
|
println!("Current block: {}", block);
|
|
|
|
let mut stream = provider.watch_blocks().await?.stream();
|
|
|
|
while let Some(block) = stream.next().await {
|
|
|
|
dbg!(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2021-08-30 11:00:30 +00:00
|
|
|
|
|
|
|
#[cfg(not(feature = "ipc"))]
|
|
|
|
fn main() {}
|