def _get_slot_by_root(db: DatabaseAPI, block_root: Hash32) -> Slot: validate_word(block_root, title="block root") try: encoded_slot = db[SchemaV1.make_block_root_to_slot_lookup_key( block_root)] except KeyError: raise BlockNotFound("No block with root {0} found".format( encode_hex(block_root))) return Slot(ssz.decode(encoded_slot, sedes=ssz.sedes.uint64))
def _add_block_root_to_slot_lookup(db: DatabaseAPI, block: BaseBeaconBlock) -> None: """ Set a record in the database to allow looking up the slot number by its block root. """ block_root_to_slot_key = SchemaV1.make_block_root_to_slot_lookup_key( block.message.hash_tree_root ) db.set(block_root_to_slot_key, ssz.encode(block.slot, sedes=ssz.sedes.uint64))
def _get_slot_by_root(db: BaseDB, block_root: Hash32) -> SlotNumber: validate_word(block_root, title="block root") try: encoded_slot = db[SchemaV1.make_block_root_to_slot_lookup_key(block_root)] except KeyError: raise BlockNotFound("No block with root {0} found".format( encode_hex(block_root))) return SlotNumber(rlp.decode(encoded_slot, sedes=rlp.sedes.big_endian_int))
def _add_block_root_to_slot_lookup(db: BaseDB, block: BaseBeaconBlock) -> None: """ Set a record in the database to allow looking up the slot number by its block root. """ block_root_to_slot_key = SchemaV1.make_block_root_to_slot_lookup_key( block.root ) db.set( block_root_to_slot_key, rlp.encode(block.slot, sedes=rlp.sedes.big_endian_int), )