event_reader.multicall_timestamp
Documentation for eth_defi.event_reader.multicall_timestamp Python module.
Read exact sampled block timestamps using cache-aware backends.
Module Attributes
Use exact sampled Hypersync reads when less than one per 100 blocks is needed. |
Functions
|
Fetch exact sampled block timestamps using parallel RPC reads. |
Fetch block timestamps, choose backend. |
- HYPERSYNC_SPARSE_TIMESTAMP_MIN_STEP = 100
Use exact sampled Hypersync reads when less than one per 100 blocks is needed.
- fetch_block_timestamps_multiprocess(chain_id, web3factory, start_block, end_block, step, display_progress=True, max_workers=8, timeout=120, cache_path=PosixPath('/home/runner/.tradingstrategy/block-timestamp'), checkpoint_freq=20000, rpc_request_stats=None)
Fetch exact sampled block timestamps using parallel RPC reads.
The historical function name is retained for callers. Thread-local Web3 connections read only missing sample blocks and preserve the original
start_blocksampling grid. A sparse cache’s latest block is not a completeness boundary, and nearest-block estimates are not cache hits.- Parameters
chain_id (int) – Chain whose block headers are requested.
web3factory (eth_defi.event_reader.web3factory.Web3Factory) – Factory using the operator’s configured RPC providers.
start_block (int) – First sample block, inclusive.
end_block (int) – Last permissible block, inclusive.
step (int) – Positive interval between samples.
display_progress (bool) – Display progress for missing samples.
max_workers (int) – Maximum parallel RPC workers.
timeout (int) – Joblib task timeout in seconds.
cache_path (Optional[pathlib.Path]) – Persistent timestamp-cache directory; required.
checkpoint_freq (int) – Block-number interval between buffered cache writes.
rpc_request_stats (Optional[eth_defi.provider.rpcdb.RPCRequestStats]) – Optional accumulator for actual RPC calls.
- Returns
Caller-owned slicer containing exact requested timestamps; close it after use.
- Return type
- fetch_block_timestamps_multiprocess_auto_backend(chain_id, web3factory, start_block, end_block, step, display_progress=True, max_workers=8, timeout=120, cache_path=PosixPath('/home/runner/.tradingstrategy/block-timestamp'), checkpoint_freq=20000, hypersync_client=None, rpc_request_stats=None)
Fetch block timestamps, choose backend.
If Hypersync is available, use the optimised code path
For arguments see
fetch_block_timestamps_multiprocess().- Parameters
step (int) – Sampling interval. Wide intervals use a sparse, cache-aware Hypersync path instead of downloading every intervening block header.
chain_id (int) –
web3factory (eth_defi.event_reader.web3factory.Web3Factory) –
start_block (int) –
end_block (int) –
cache_path (Optional[pathlib.Path]) –
checkpoint_freq (int) –
hypersync_client (hypersync.HypersyncClient | None) –
rpc_request_stats (Optional[eth_defi.provider.rpcdb.RPCRequestStats]) –
- Returns
Pandas series block number (int) -> block timestamp (datetime)
The mapping is deliberately keyed by block number. Modern chains such as Monad can produce multiple blocks in one second, while block-header timestamps retain one-second precision. Do not reverse this mapping or treat timestamp values as unique; retaining the same timestamp for multiple blocks is correct for the scanner’s intended precision.
- Return type