start using ethers-rs
This commit is contained in:
parent
7705991b4c
commit
969bb32495
2157
Cargo.lock
generated
2157
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@ argh = "0.1.7"
|
|||||||
anyhow = "1.0.57"
|
anyhow = "1.0.57"
|
||||||
atomic-counter = "1.0.1"
|
atomic-counter = "1.0.1"
|
||||||
dashmap = "5.2.0"
|
dashmap = "5.2.0"
|
||||||
|
ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["rustls", "ws"] }
|
||||||
futures = { version = "0.3.21", features = ["thread-pool"] }
|
futures = { version = "0.3.21", features = ["thread-pool"] }
|
||||||
governor = { version = "0.4.2", features = ["dashmap", "std"] }
|
governor = { version = "0.4.2", features = ["dashmap", "std"] }
|
||||||
tokio = { version = "1.17.0", features = ["full"] }
|
tokio = { version = "1.17.0", features = ["full"] }
|
||||||
|
21
examples/watch_blocks.rs
Normal file
21
examples/watch_blocks.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
use ethers::prelude::*;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> anyhow::Result<()> {
|
||||||
|
// let ws = Ws::connect("ws://10.11.12.16:8545").await?;
|
||||||
|
let ws = Ws::connect("ws://10.11.12.16:8946").await?;
|
||||||
|
let provider = Provider::new(ws).interval(Duration::from_secs(1));
|
||||||
|
let mut stream = provider.watch_blocks().await?.take(5);
|
||||||
|
while let Some(block_number) = stream.next().await {
|
||||||
|
let block = provider.get_block(block_number).await?.unwrap();
|
||||||
|
println!(
|
||||||
|
"Ts: {:?}, block number: {} -> {:?}",
|
||||||
|
block.timestamp,
|
||||||
|
block.number.unwrap(),
|
||||||
|
block.hash.unwrap()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
@ -45,7 +45,7 @@ async fn handle_new_head_message(message: tungstenite::Message) -> anyhow::Resul
|
|||||||
// TODO: parse the message as json and get out the block data. then update a map for this rpc
|
// TODO: parse the message as json and get out the block data. then update a map for this rpc
|
||||||
println!("now what? {:?}", data);
|
println!("now what? {:?}", data);
|
||||||
|
|
||||||
unimplemented!();
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BalancedRpcs {
|
impl BalancedRpcs {
|
||||||
|
Loading…
Reference in New Issue
Block a user