2021-04-08 06:52:31 +00:00
|
|
|
#[tokio::main]
|
2021-08-30 11:00:30 +00:00
|
|
|
#[cfg(feature = "ipc")]
|
2022-02-03 20:36:05 +00:00
|
|
|
async fn main() -> eyre::Result<()> {
|
2021-11-05 17:58:03 +00:00
|
|
|
use ethers::prelude::*;
|
|
|
|
|
|
|
|
let provider = Provider::connect_ipc("~/.ethereum/geth.ipc")
|
|
|
|
.await?
|
|
|
|
.interval(std::time::Duration::from_millis(2000));
|
2021-04-08 06:52:31 +00:00
|
|
|
let block = provider.get_block_number().await?;
|
2022-11-07 23:43:11 +00:00
|
|
|
println!("Current block: {block}");
|
2021-04-08 06:52:31 +00:00
|
|
|
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() {}
|