Struct cfx_storage::TrieProof
source · pub struct TrieProof { /* private fields */ }
Implementations§
source§impl TrieProof
impl TrieProof
pub const MAX_NODES: usize = 1_000usize
sourcepub fn new(nodes: Vec<TrieProofNode>) -> Result<Self>
pub fn new(nodes: Vec<TrieProofNode>) -> Result<Self>
Makes sure that the proof nodes are valid and connected at the time of creation.
pub fn get_merkle_root(&self) -> &MerkleHash
sourcepub fn is_valid_kv(
&self,
key: &[u8],
value: Option<&[u8]>,
root: &MerkleHash
) -> bool
pub fn is_valid_kv( &self, key: &[u8], value: Option<&[u8]>, root: &MerkleHash ) -> bool
Verify that the trie root
has value
under key
.
Use None
for exclusion proofs (i.e. there is no value under key
).
sourcepub fn if_proves_key(&self, key: &[u8]) -> (bool, Option<&TrieProofNode>)
pub fn if_proves_key(&self, key: &[u8]) -> (bool, Option<&TrieProofNode>)
Check if the key can be proved. The only reason of inability to prove a key is missing nodes.
sourcepub fn get_value(&self, key: &[u8], root: &MerkleHash) -> (bool, Option<&[u8]>)
pub fn get_value(&self, key: &[u8], root: &MerkleHash) -> (bool, Option<&[u8]>)
Get the value under key
starting from root
.
sourcepub fn is_valid_node_merkle(
&self,
key: &[u8],
node_merkle: &MptValue<MerkleHash>,
root: &MerkleHash
) -> bool
pub fn is_valid_node_merkle( &self, key: &[u8], node_merkle: &MptValue<MerkleHash>, root: &MerkleHash ) -> bool
Verify that the trie root
has a node with node_merkle
under key
.
If node_merkle
is None
, then it must prove that the trie does not
contain key
.
If node_merkle
is Tombstone
, then it must prove that the trie
contains a tombstone value under key
.
If node_merkle
is Some(hash)
, then it must prove that the trie
contains a node under key
whose node merkle equals hash
.
pub fn number_nodes(&self) -> usize
pub fn number_leaf_nodes(&self) -> u32
pub fn get_proof_nodes(&self) -> &Vec<TrieProofNode>
pub fn into_proof_nodes(self) -> Vec<TrieProofNode>
sourcepub fn compute_snapshot_mpt_path_for_proof(
&self,
key: &[u8]
) -> Vec<(CompressedPathRaw, u8, &VanillaTrieNode<MerkleHash>)>
pub fn compute_snapshot_mpt_path_for_proof( &self, key: &[u8] ) -> Vec<(CompressedPathRaw, u8, &VanillaTrieNode<MerkleHash>)>
Returns the (snapshot_mpt_key, child_index, trie_node) along the proof path of key.