[][src]Struct merkle_trees::merkle_patricia_trie::MerklePatriciaTrie

pub struct MerklePatriciaTrie<V, H, S: Clone + KnownLength, NS, NH> where
    NS: PatriciaTrieNodeSerializer<H, V, S>,
    NH: NodeHasher<S, H>, 
{ pub root_node: NodeType<H, V>, pub phantom_1: PhantomData<V>, pub phantom_2: PhantomData<S>, // some fields omitted }

Fields

root_node: NodeType<H, V>phantom_1: PhantomData<V>phantom_2: PhantomData<S>

Methods

impl<V: Clone + Default + Eq, H: Clone, S: Clone + KnownLength, NS, NH> MerklePatriciaTrie<V, H, S, NS, NH> where
    NS: PatriciaTrieNodeSerializer<H, V, S>,
    NH: NodeHasher<S, H>, 
[src]

pub fn new(hasher: NH, node_serializer: NS) -> Result<Self, MerkleTreeError>[src]

Create a new empty trie

pub fn initialize_with_root_hash(
    hasher: NH,
    node_serializer: NS,
    root_hash: &H,
    hash_db: &mut dyn HashValueDb<H, S>
) -> Result<Self, MerkleTreeError>
[src]

Initialize a trie with a given root hash and database. The root hash must be present in the database.

pub fn get_root_hash(&self) -> Result<H, MerkleTreeError>[src]

pub fn get(
    &self,
    key: &dyn Key,
    proof: &mut Option<Vec<NodeType<H, V>>>,
    hash_db: &dyn HashValueDb<H, S>
) -> Result<V, MerkleTreeError>
[src]

Get value of the given key. If proof is not None, it is populated with a proof.

pub fn get_from_tree_with_root(
    &self,
    tree_root: &NodeType<H, V>,
    key: &dyn Key,
    proof: &mut Option<Vec<NodeType<H, V>>>,
    hash_db: &dyn HashValueDb<H, S>
) -> Result<V, MerkleTreeError>
[src]

Get value of the given key in a tree with root tree_root. If proof is not None, it is populated with a proof.

pub fn insert(
    &mut self,
    key: &dyn Key,
    value: V,
    hash_db: &mut dyn HashValueDb<H, S>
) -> Result<H, MerkleTreeError>
[src]

Insert a key-value into the trie.

pub fn verify_proof(
    key: &dyn Key,
    value: &V,
    proof: Vec<NodeType<H, V>>,
    hasher: NH,
    node_serializer: NS,
    root_hash: &H,
    hash_db: &mut dyn HashValueDb<H, S>
) -> Result<bool, MerkleTreeError>
[src]

Verify that a tree with root hash root_hash has a key key with value value

pub fn get_key_values<K>(
    &self,
    root_node: &NodeType<H, V>,
    proof: &mut Option<Vec<NodeType<H, V>>>,
    hash_db: &dyn HashValueDb<H, S>,
    nibbles_to_key: &dyn Fn(&[u8]) -> K
) -> Result<Vec<(K, V)>, MerkleTreeError>
[src]

Get all key-value pairs in a tree with root root_node. If proof is not None, it is populated with a proof. The argument nibbles_to_key is a function to convert nibbles to keys. Don't want to require Key trait to have a nibble_to_key function as this function might not be needed by all implementations.

pub fn get_keys_values_with_prefix<K>(
    &self,
    prefix_key: &dyn Key,
    node: &NodeType<H, V>,
    proof: &mut Option<Vec<NodeType<H, V>>>,
    hash_db: &dyn HashValueDb<H, S>,
    nibbles_to_key: &dyn Fn(&[u8]) -> K
) -> Result<Vec<(K, V)>, MerkleTreeError>
[src]

Get all key-value pairs in a tree with root root_node and prefix prefix_key. If proof is not None, it is populated with a proof.

pub fn verify_proof_multiple_keys(
    keys: Vec<&dyn Key>,
    values: &[V],
    proof: Vec<NodeType<H, V>>,
    hasher: NH,
    node_serializer: NS,
    root_hash: &H,
    hash_db: &mut dyn HashValueDb<H, S>
) -> Result<bool, MerkleTreeError>
[src]

Trait Implementations

impl<V: Clone, H: Clone, S: Clone + KnownLength, NS: Clone, NH: Clone> Clone for MerklePatriciaTrie<V, H, S, NS, NH> where
    NS: PatriciaTrieNodeSerializer<H, V, S>,
    NH: NodeHasher<S, H>, 
[src]

impl<V: Debug, H: Debug, S: Debug + Clone + KnownLength, NS: Debug, NH: Debug> Debug for MerklePatriciaTrie<V, H, S, NS, NH> where
    NS: PatriciaTrieNodeSerializer<H, V, S>,
    NH: NodeHasher<S, H>, 
[src]

impl<'de, V, H, S: Clone + KnownLength, NS, NH> Deserialize<'de> for MerklePatriciaTrie<V, H, S, NS, NH> where
    NS: PatriciaTrieNodeSerializer<H, V, S>,
    NH: NodeHasher<S, H>,
    V: Deserialize<'de>,
    H: Deserialize<'de>,
    NS: Deserialize<'de>,
    NH: Deserialize<'de>, 
[src]

impl<V, H, S: Clone + KnownLength, NS, NH> Serialize for MerklePatriciaTrie<V, H, S, NS, NH> where
    NS: PatriciaTrieNodeSerializer<H, V, S>,
    NH: NodeHasher<S, H>,
    V: Serialize,
    H: Serialize,
    NS: Serialize,
    NH: Serialize
[src]

Auto Trait Implementations

impl<V, H, S, NS, NH> RefUnwindSafe for MerklePatriciaTrie<V, H, S, NS, NH> where
    H: RefUnwindSafe,
    NH: RefUnwindSafe,
    NS: RefUnwindSafe,
    S: RefUnwindSafe,
    V: RefUnwindSafe

impl<V, H, S, NS, NH> Send for MerklePatriciaTrie<V, H, S, NS, NH> where
    H: Send,
    NH: Send,
    NS: Send,
    S: Send,
    V: Send

impl<V, H, S, NS, NH> Sync for MerklePatriciaTrie<V, H, S, NS, NH> where
    H: Sync,
    NH: Sync,
    NS: Sync,
    S: Sync,
    V: Sync

impl<V, H, S, NS, NH> Unpin for MerklePatriciaTrie<V, H, S, NS, NH> where
    H: Unpin,
    NH: Unpin,
    NS: Unpin,
    S: Unpin,
    V: Unpin

impl<V, H, S, NS, NH> UnwindSafe for MerklePatriciaTrie<V, H, S, NS, NH> where
    H: UnwindSafe,
    NH: UnwindSafe,
    NS: UnwindSafe,
    S: UnwindSafe,
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.