コード例 #1
0
 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)
コード例 #2
0
    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