Created
May 30, 2020 09:25
-
-
Save pawanjay176/d2000f30136cf7d74cb70359f205b62b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use eth1::http::get_deposit_logs_in_range; | |
use std::ops::Range; | |
use std::time::Duration; | |
const START_BLOCK: u64 = 2758066; | |
const END_BLOCK: u64 = 2783329; | |
const DEPOSIT_CONTRACT: &'static str = "0x42cc0FcEB02015F145105Cf6f19F90e9BEa76558"; | |
const ENDPOINT: &'static str = "http://localhost:8545/"; | |
#[tokio::main] | |
async fn main() { | |
let range_chunks = (START_BLOCK..END_BLOCK) | |
.collect::<Vec<u64>>() | |
.chunks(1000) | |
.map(|vec| { | |
let first = vec.first().cloned().unwrap_or_else(|| 0); | |
let last = vec.last().map(|n| n + 1).unwrap_or_else(|| 0); | |
first..last | |
}) | |
.collect::<Vec<Range<u64>>>(); | |
println!( | |
"Searching for deposit logs in range {}..{}", | |
START_BLOCK, END_BLOCK, | |
); | |
for range in range_chunks { | |
let logs = get_deposit_logs_in_range( | |
ENDPOINT, | |
DEPOSIT_CONTRACT, | |
range.clone(), | |
Duration::from_secs(5), | |
) | |
.await | |
.unwrap(); | |
println!( | |
"Found {} logs in range {} to {}", | |
logs.len(), | |
range.start, | |
range.end | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment