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
get(block_number)

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

Parameters

block_number (int) –

Return type

datetime.datetime | None

get_last_block()

Get the maximum block number in the database.

Return type

int

close()

Release the associated cache db.