pub struct SparseMerkleTree<H, V, S> { /* private fields */ }
Expand description
Sparse merkle tree
Implementations§
Source§impl<H: Hasher + Default, V: Value, S: Store<V>> SparseMerkleTree<H, V, S>
impl<H: Hasher + Default, V: Value, S: Store<V>> SparseMerkleTree<H, V, S>
Sourcepub fn new(root: H256, store: S) -> SparseMerkleTree<H, V, S>
pub fn new(root: H256, store: S) -> SparseMerkleTree<H, V, S>
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: H256, value: V) -> Result<&H256>
pub fn update(&mut self, key: H256, value: V) -> Result<&H256>
Update a leaf, return new merkle root set to zero value to delete a key
Sourcepub fn get(&self, key: &H256) -> Result<V>
pub fn get(&self, key: &H256) -> Result<V>
Get value of a leaf return zero value if leaf not exists
Sourcepub fn merkle_proof(&self, keys: Vec<H256>) -> Result<MerkleProof>
pub fn merkle_proof(&self, keys: Vec<H256>) -> Result<MerkleProof>
Generate merkle proof
Trait Implementations§
Auto Trait Implementations§
impl<H, V, S> Freeze for SparseMerkleTree<H, V, S>where
S: Freeze,
impl<H, V, S> RefUnwindSafe for SparseMerkleTree<H, V, S>
impl<H, V, S> Send for SparseMerkleTree<H, V, S>
impl<H, V, S> Sync for SparseMerkleTree<H, V, S>
impl<H, V, S> Unpin for SparseMerkleTree<H, V, S>
impl<H, V, S> UnwindSafe for SparseMerkleTree<H, V, S>
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