LazyTimestampContainer

Documentation for eth_defi.event_reader.lazy_timestamp_reader.LazyTimestampContainer Python class.

class LazyTimestampContainer

Bases: object

Dictionary-like object to get block timestamps on-demand.

Lazily load any block timestamp over JSON-RPC API if we have not cached it yet.

See extract_timestamps_json_rpc_lazy().

TODO: This is not using middleware and fails to retry any failed JSON-RPC requests.

Parameters
  • web3 – Connection

  • start_block – Start block range, inclusive

  • end_block – End block range, inclusive

Attributes summary

api_call_counter

How many API requets we have made

Methods summary

__init__(web3, start_block, end_block[, ...])

param web3

update_block_hash(block_identifier)

Internal function to get block timestamp from JSON-RPC and store it in the cache.

__init__(web3, start_block, end_block, callback=None)
Parameters
  • web3 (web3.main.Web3) – Connection

  • start_block (int) – Start block range, inclusive

  • end_block (int) – End block range, inclusive

  • callback (Callable) –

api_call_counter

How many API requets we have made

update_block_hash(block_identifier)

Internal function to get block timestamp from JSON-RPC and store it in the cache.

Parameters

block_identifier (Union[Literal['latest', 'earliest', 'pending', 'safe', 'finalized'], eth_typing.evm.BlockNumber, eth_typing.evm.Hash32, eth_typing.encoding.HexStr, hexbytes.main.HexBytes, int]) –

Return type

int