event_reader.multicall_timestamp
Documentation for eth_defi.event_reader.multicall_timestamp Python module.
Read timestamps of blocks using multiprocess.
Module Attributes
Use exact sampled Hypersync reads when less than one per 100 blocks is needed. |
Functions
|
Extract timestamps using fast multiprocessing. |
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)
Extract timestamps using fast multiprocessing.
Subprocess entrypoint
This is called by a joblib.Parallel
The subprocess is recycled between different batch jobs
We cache reader Web3 connections between batch jobs
joblib never shuts down this process
Note
Because this method aggressively uses step to skip blocks, it results to non-reuseable timestamp cache (only valid for one scan and subsequent scans of the same task).
- :param cache_path
Cache timestamps across runs and commands.
Set to
Noneto disable, or remove the file. .
- Parameters
checkpoint_freq (int) – Block number frequency how often to save.
rpc_request_stats (Optional[eth_defi.provider.rpcdb.RPCRequestStats]) – Optional parent accumulator receiving successful subprocess task calls.
chain_id (int) –
web3factory (eth_defi.event_reader.web3factory.Web3Factory) –
start_block (int) –
end_block (int) –
step (int) –
cache_path (Optional[pathlib.Path]) –
- 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)
- Return type