Skip to main content

Module scan

Module scan 

Source
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.
ScanPlan
What a scan will cover; see LogScan::plan.
ScanProgress
Passed to the LogScan::on_progress callback 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.