fn check_merkle_proofs<K, V, T, S, E>(
    correlation_id: CorrelationId,
    txn: &T,
    store: &S,
    root: &Digest,
    leaves: &[Trie<K, V>],
) -> Result<Vec<bool>, E>
where
    K: ToBytes + FromBytes + Eq + std::fmt::Debug + Copy,
    V: ToBytes + FromBytes + Eq + Copy,
    T: Readable<Handle = S::Handle>,
    S: TrieStore<K, V>,
    S::Error: From<T::Error>,
    E: From<S::Error> + From<bytesrepr::Error>,
{
    let mut ret = Vec::new();

    for leaf in leaves {
        if let Trie::Leaf { key, value } = leaf {
            let maybe_proof: ReadResult<TrieMerkleProof<K, V>> =
                read_with_proof::<_, _, _, _, E>(correlation_id, txn, store, root, key)?;
            match maybe_proof {
                ReadResult::Found(proof) => {
                    let hash = proof.compute_state_hash()?;
                    ret.push(hash == *root && proof.value() == value);
                }
                ReadResult::NotFound => {
                    ret.push(false);
                }
                ReadResult::RootNotFound => panic!("Root not found!"),
            };
        } else {
            panic!("leaves should only contain leaves")
        }
    }
    Ok(ret)
}
/// For a given vector of leaves check the merkle proofs exist and are correct
For a given vector of leaves check the merkle proofs exist and are correct
For a given vector of leaves check the merkle proofs exist and are correct
fn check_merkle_proofs<K, V, T, S, E>(
    correlation_id: CorrelationId,
    txn: &T,
    store: &S,
    root: &Digest,
    leaves: &[Trie<K, V>],
) -> Result<Vec<bool>, E>
where
    K: ToBytes + FromBytes + Eq + std::fmt::Debug + Copy,
    V: ToBytes + FromBytes + Eq + Copy,
    T: Readable<Handle = S::Handle>,
    S: TrieStore<K, V>,
    S::Error: From<T::Error>,
    E: From<S::Error> + From<bytesrepr::Error>,
{
    let mut ret = Vec::new();
    for leaf in leaves {
        if let Trie::Leaf { key, value } = leaf {
            let maybe_proof: ReadResult<TrieMerkleProof<K, V>> =
                read_with_proof::<_, _, _, _, E>(correlation_id, txn, store, root, key)?;
            match maybe_proof {
                ReadResult::Found(proof) => {
                    let hash = proof.compute_state_hash()?;
                    ret.push(hash == *root && proof.value() == value);
                }
                ReadResult::NotFound => {
                    ret.push(false);
                }
                ReadResult::RootNotFound => panic!("Root not found!"),
            };
        } else {
            panic!("leaves should only contain leaves")
        }
    }
    Ok(ret)
}
fn check_merkle_proofs < K , V , T , S , E > ( correlation_id : CorrelationId , txn : & T , store : & S , root : & Digest , leaves : & [ Trie < K , V > ] , ) -> Result < Vec < bool > , E > where K : ToBytes + FromBytes + Eq + std :: fmt :: Debug + Copy , V : ToBytes + FromBytes + Eq + Copy , T : Readable < Handle = S :: Handle > , S : TrieStore < K , V > , S :: Error : From < T :: Error > , E : From < S :: Error > + From < bytesrepr :: Error > , { let mut ret = Vec :: new ( ) ; for leaf in leaves { if let Trie :: Leaf { key , value } = leaf { let maybe_proof : ReadResult < TrieMerkleProof < K , V > > = read_with_proof :: < _ , _ , _ , _ , E > ( correlation_id , txn , store , root , key ) ? ; match maybe_proof { ReadResult :: Found ( proof ) => { let hash = proof . compute_state_hash ( ) ? ; ret . push ( hash == * root && proof . value ( ) == value ) ; } ReadResult :: NotFound => { ret . push ( false ) ; } ReadResult :: RootNotFound => panic ! ( " " ) , } ; } else { panic ! ( " " ) } } Ok ( ret ) }
For a given vector of leaves check the merkle proofs exist and are correct
For a given vector of leaves check the merkle proofs exist and are correct
correlation_id
CorrelationId
txn
&T
store
&S
root
&Digest
leaves
&[Trie<K, V>]
correlation_id
CorrelationId
txn
&T
store
&S
root
&Digest
leaves
&[Trie<K, V>]