Expand description
Scanning eth_getLogs over long block ranges, politely.
Providers cap how many blocks one eth_getLogs call may cover (Ronin: 200) and how
many calls you may make per second. LogScan splits a range into windows, can walk
newest first and stop as soon as it has found enough, halves a window when the
node rejects it as too large, and can throttle itself to a request rate.
The scan holds no state between runs: caching or storing results is up to the caller.
use evmify::{EvmClient, Filter};
let client = EvmClient::connect("ronin").await?;
let transfers = Filter::new().event("Transfer(address,address,uint256)");
let latest = client
.scan_logs(transfers)
.newest_first()
.limit(20)
.max_blocks(10_000)
.rate_limit(5.0) // requests per second
.on_progress(|p| eprint!("\r{}/{} blocks", p.scanned, p.total))
.run()
.await?;Structs§
- LogScan
- Builder returned by
EvmClient::scan_logs. - Scan
Plan - What a scan will cover; see
LogScan::plan. - Scan
Progress - Passed to the
LogScan::on_progresscallback after every window.
Constants§
- DEFAULT_
CHUNK - Default window size: Ronin’s limit, and safe for most public RPCs.
- DEFAULT_
MAX_ BLOCKS - Default number of blocks a scan looks back when no start block is given.