Header
HeaderDB
- class eth.db.header.HeaderDB(db: AtomicDatabaseAPI)
- get_block_header_by_hash(block_hash: Hash32) BlockHeaderAPI
Return the block header for the given
block_hash. RaiseHeaderNotFoundif no header with the givenblock_hashexists in the database.
- get_canonical_block_hash(block_number: BlockNumber) Hash32
Return the block hash for the canonical block at the given number.
Raise
BlockNotFoundif there’s no block header with the given number in the canonical chain.
- get_canonical_block_header_by_number(block_number: BlockNumber) BlockHeaderAPI
Return the block header with the given number in the canonical chain.
Raise
HeaderNotFoundif there’s no block header with the given number in the canonical chain.
- get_canonical_head() BlockHeaderAPI
Return the current block header at the head of the chain.
- get_header_chain_gaps() Tuple[Tuple[Tuple[BlockNumber, BlockNumber], ...], BlockNumber]
Return information about gaps in the chain of headers. This consists of an ordered sequence of block ranges describing the integrity of the chain. Each block range describes a missing segment in the chain and each range is defined with inclusive boundaries, meaning the first value describes the first missing block of that segment and the second value describes the last missing block of the segment.
In addition to the sequences of block ranges a block number is included that indicates the number of the first header that is known to be missing at the very tip of the chain.
- header_exists(block_hash: Hash32) bool
Return
Trueif theblock_hashexists in the database, otherwiseFalse.
- persist_checkpoint_header(header: BlockHeaderAPI, score: int) None
Persist a checkpoint header with a trusted score. Persisting the checkpoint header automatically sets it as the new canonical head.
- persist_header(header: BlockHeaderAPI) Tuple[Tuple[BlockHeaderAPI, ...], Tuple[BlockHeaderAPI, ...]]
Persist the
headerin the database. Return two iterable of headers, the first containing the new canonical header, the second containing the old canonical headers
- persist_header_chain(headers: Iterable[BlockHeaderAPI], genesis_parent_hash: Hash32 = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') Tuple[Tuple[BlockHeaderAPI, ...], Tuple[BlockHeaderAPI, ...]]
Persist a chain of headers in the database. Return two iterable of headers, the first containing the new canonical headers, the second containing the old canonical headers
- Parameters:
genesis_parent_hash – optional parent hash of the block that is treated as genesis. Providing a
genesis_parent_hashallows storage of headers that aren’t (yet) connected back to the true genesis header.