def get_block_by_root( self, block_root: Root, block_class: Type[BaseBeaconBlock]) -> BaseBeaconBlock: key = SchemaV1.block_root_to_block(block_root) try: block_data = self.db[key] except KeyError: raise BlockNotFound() return ssz.decode(block_data, block_class)
def persist_block(self, signed_block: BaseSignedBeaconBlock) -> None: block = signed_block.message block_root = block.hash_tree_root block_root_to_block = SchemaV1.block_root_to_block(block_root) self.db[block_root_to_block] = ssz.encode(block) signature = signed_block.signature block_root_to_signature = SchemaV1.block_root_to_signature(block_root) self.db[block_root_to_signature] = signature