示例#1
0
 def _add_block_hash_tree_root_to_signing_root_lookup(
     db: DatabaseAPI, block: BaseBeaconBlock
 ) -> None:
     key = SchemaV1.make_block_hash_tree_root_to_signing_root_lookup_key(
         block.hash_tree_root
     )
     db.set(key, block.signing_root)
示例#2
0
 def _get_block_signing_root_by_hash_tree_root(
         db: DatabaseAPI, block_root: HashTreeRoot) -> SigningRoot:
     validate_word(block_root, title="block hash tree root")
     key = SchemaV1.make_block_hash_tree_root_to_signing_root_lookup_key(
         block_root)
     try:
         signing_root = db[key]
     except KeyError:
         raise BlockNotFound(
             "No block with hash tree root {0} found".format(
                 encode_hex(block_root)))
     return cast(SigningRoot, signing_root)
示例#3
0
def test_chaindb_persist_block_and_hash_tree_root_to_signing_root(
        chaindb, block, fork_choice_scoring):
    with pytest.raises(BlockNotFound):
        chaindb.get_block_signing_root_by_hash_tree_root(block.hash_tree_root)
    key = SchemaV1.make_block_hash_tree_root_to_signing_root_lookup_key(
        block.hash_tree_root)
    assert not chaindb.exists(key)

    chaindb.persist_block(block, block.__class__, fork_choice_scoring)

    assert (chaindb.get_block_signing_root_by_hash_tree_root(
        block.hash_tree_root) == block.signing_root)
    assert chaindb.exists(key)