extract_timestamps_json_rpc_lazy
Documentation for eth_defi.event_reader.lazy_timestamp_reader.extract_timestamps_json_rpc_lazy function.
- extract_timestamps_json_rpc_lazy(web3, start_block, end_block, fetch_boundaries=True)
Create a cache container that instead of reading block timestamps upfront for the given range, only calls JSON-RPC API when requested
Works on the cases where sparse event data is read over long block range Use slow JSON-RPC block headers call to get this information.
The reader is hash based. It is mainly meant to resolve eth_getLogs resulting block hashes to corresponding event timestamps.
This is a drop-in replacement for the dict returned by eager
eth_defi.reader.extract_timestamps_json_rpc()
Example:
# Allocate timestamp reader for blocks 1...100 timestamps = extract_timestamps_json_rpc_lazy(web3, 1, 100) # Get a hash of some block block_hash = web3.eth.get_block(5)["hash"] # Read timestamp for block 5 unix_time = timestamps[block_hash]
For more information see
eth_defi.reader.extract_timestamps_json_rpc()eth_defi.reorganisation_monitor.ReorganisationMonitor
- Returns
Wrapper object for block hash based timestamp access.
- Parameters
- Return type
eth_defi.event_reader.lazy_timestamp_reader.LazyTimestampContainer