Trait ProvingTrie

Source
pub trait ProvingTrie<Hashing, Key, Value>
where Self: Sized, Hashing: Hasher,
{ // Required methods fn generate_for<I>(items: I) -> Result<Self, DispatchError> where I: IntoIterator<Item = (Key, Value)>; fn root(&self) -> &Hashing::Out; fn query(&self, key: &Key) -> Option<Value>; fn create_proof(&self, key: &Key) -> Result<Vec<u8>, DispatchError>; fn verify_proof( root: &Hashing::Out, proof: &[u8], key: &Key, value: &Value, ) -> Result<(), DispatchError>; }
Expand description

An interface for creating, interacting with, and creating proofs in a merkle trie.

Required Methods§

Source

fn generate_for<I>(items: I) -> Result<Self, DispatchError>
where I: IntoIterator<Item = (Key, Value)>,

Create a new instance of a ProvingTrie using an iterator of key/value pairs.

Source

fn root(&self) -> &Hashing::Out

Access the underlying trie root.

Source

fn query(&self, key: &Key) -> Option<Value>

Query a value contained within the current trie. Returns None if the the value does not exist in the trie.

Source

fn create_proof(&self, key: &Key) -> Result<Vec<u8>, DispatchError>

Create a proof that can be used to verify a key and its value are in the trie.

Source

fn verify_proof( root: &Hashing::Out, proof: &[u8], key: &Key, value: &Value, ) -> Result<(), DispatchError>

Verify the existence of key and value in a given trie root and proof.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Hashing, Key, Value> ProvingTrie<Hashing, Key, Value> for sp_runtime::proving_trie::base2::BasicProvingTrie<Hashing, Key, Value>
where Hashing: Hasher, Hashing::Out: Encode + Decode, Key: Encode + Decode + Ord, Value: Encode + Decode + Clone,

Source§

impl<Hashing, Key, Value> ProvingTrie<Hashing, Key, Value> for sp_runtime::proving_trie::base16::BasicProvingTrie<Hashing, Key, Value>
where Hashing: Hasher, Key: Encode, Value: Encode + Decode,