BlockTimestampSlicer

Documentation for eth_defi.event_reader.timestamp_cache.BlockTimestampSlicer Python class.

class BlockTimestampSlicer

Bases: object

Read timestamps from DuckDB in slices iteratively.

  • Maintain a memory buffer of block numbers

  • Avoid reading all Arbitrum 20 GB of timestamp data to memory at once

Methods summary

__init__(timestamp_db[, slice_size])

close()

Release the associated cache db.

get(block_number)

Get timestamp for a given block number, or None if not found.

get_last_block()

Get the maximum block number in the database.

__init__(timestamp_db, slice_size=1000000)
Parameters
close()

Release the associated cache db.

get(block_number)

Get timestamp for a given block number, or None if not found.

If the exact block is missing (gap in HyperSync data), returns the timestamp of the nearest available block in the current slice.

Parameters

block_number (int) –

Return type

Optional[datetime.datetime]

get_last_block()

Get the maximum block number in the database.

Return type

int