Example #1
0
    def get_from_proof(cls, root_hash, key, proof):
        trie = cls({})

        for node in proof:
            trie._persist_node(node)
        trie.root_hash = root_hash
        try:
            return trie.get(key)
        except KeyError as e:
            raise BadTrieProof("Missing proof node with hash {}".format(e.args))
Example #2
0
    def get_from_proof(cls, root_hash, key, proof):
        trie = cls({})

        for node in proof:
            trie._set_raw_node(node)

        with trie.at_root(root_hash) as proven_snapshot:
            try:
                return proven_snapshot.get(key)
            except KeyError as e:
                raise BadTrieProof("Missing proof node with hash {}".format(
                    e.args))