pub struct SparseMerkleTree<H, K, V, S, const N: usize>{ /* private fields */ }Expand description
Sparse merkle tree
Implementations§
Source§impl<H, K, V, S, const N: usize> SparseMerkleTree<H, K, V, S, N>
impl<H, K, V, S, const N: usize> SparseMerkleTree<H, K, V, S, N>
Sourcepub fn new(root: H256, store: S) -> SparseMerkleTree<H, K, V, S, N>
pub fn new(root: H256, store: S) -> SparseMerkleTree<H, K, V, S, N>
Build a merkle tree from root and store
Sourcepub fn take_store(self) -> S
pub fn take_store(self) -> S
Destroy current tree and retake store
Sourcepub fn update(&mut self, key: K, value: V) -> Result<&H256>
pub fn update(&mut self, key: K, value: V) -> Result<&H256>
Update a leaf, return new merkle root set to zero value to delete a key
Sourcepub fn get(&self, key: &K) -> Result<V>
pub fn get(&self, key: &K) -> Result<V>
Get value of a leaf return zero value if leaf not exists
Sourcepub fn merkle_proof(&self, keys: Vec<K>) -> Result<MerkleProof>
pub fn merkle_proof(&self, keys: Vec<K>) -> Result<MerkleProof>
Generate merkle proof
Sourcepub fn membership_proof(&self, key: &K) -> Result<CommitmentProof>
pub fn membership_proof(&self, key: &K) -> Result<CommitmentProof>
Generate ICS 23 commitment proof for the existing key
Sourcepub fn non_membership_proof(&self, key: &K) -> Result<CommitmentProof>
pub fn non_membership_proof(&self, key: &K) -> Result<CommitmentProof>
Generate ICS 23 commitment proof for the non-existing key
Trait Implementations§
Source§impl<H, K, V, S, const N: usize> Debug for SparseMerkleTree<H, K, V, S, N>
impl<H, K, V, S, const N: usize> Debug for SparseMerkleTree<H, K, V, S, N>
Auto Trait Implementations§
impl<H, K, V, S, const N: usize> Freeze for SparseMerkleTree<H, K, V, S, N>where
S: Freeze,
impl<H, K, V, S, const N: usize> RefUnwindSafe for SparseMerkleTree<H, K, V, S, N>
impl<H, K, V, S, const N: usize> Send for SparseMerkleTree<H, K, V, S, N>
impl<H, K, V, S, const N: usize> Sync for SparseMerkleTree<H, K, V, S, N>
impl<H, K, V, S, const N: usize> Unpin for SparseMerkleTree<H, K, V, S, N>
impl<H, K, V, S, const N: usize> UnwindSafe for SparseMerkleTree<H, K, V, S, N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more