def _get_active_state_root_by_crystallized( db: BaseDB, crystallized_state_root: Hash32) -> Hash32: state_root_to_hash_key = SchemaV1.make_crystallized_to_active_state_root_lookup_key( crystallized_state_root) try: encoded_key = db[state_root_to_hash_key] except KeyError: raise StateRootNotFound( "No canonical active state for crystallized_state_root #{0}". format(state_root_to_hash_key)) else: return rlp.decode(encoded_key, sedes=rlp.sedes.binary)
def _add_crystallized_to_active_state_lookup( cls, db: BaseDB, active_state: ActiveState, crystallized_state_root: Hash32) -> None: """ Set a record in the database to allow looking up this block by its last state recalculation slot. """ slot_to_hash_key = SchemaV1.make_crystallized_to_active_state_root_lookup_key( crystallized_state_root, ) db.set( slot_to_hash_key, rlp.encode(active_state.hash, sedes=rlp.sedes.binary), )