pub struct SparseMerkleTreeWithHistory<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>> {
pub tree: SparseMerkleTree<'a, L, H>,
pub root_history: Map<'a, L, Empty>,
}
Expand description
Like SparseMerkleTree but able to check valid root hash with all previous root hashes.
Fields§
§tree: SparseMerkleTree<'a, L, H>
§root_history: Map<'a, L, Empty>
Implementations§
Trait Implementations§
Source§impl<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>> MerkleTree<L, H> for SparseMerkleTreeWithHistory<'a, L, H>
impl<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>> MerkleTree<L, H> for SparseMerkleTreeWithHistory<'a, L, H>
Source§fn init(
&self,
storage: &mut dyn Storage,
level: u8,
default_leaf: L,
hasher: &H,
) -> Result<(), MerkleTreeError>
fn init( &self, storage: &mut dyn Storage, level: u8, default_leaf: L, hasher: &H, ) -> Result<(), MerkleTreeError>
Initize the tree.
Source§fn is_valid_root(
&self,
storage: &dyn Storage,
root: &L,
) -> Result<bool, MerkleTreeError>
fn is_valid_root( &self, storage: &dyn Storage, root: &L, ) -> Result<bool, MerkleTreeError>
Check if the
root
is valid for the tree.Source§fn insert(
&self,
storage: &mut dyn Storage,
leaf: L,
hasher: &H,
) -> Result<(u64, L), MerkleTreeError>
fn insert( &self, storage: &mut dyn Storage, leaf: L, hasher: &H, ) -> Result<(u64, L), MerkleTreeError>
Insert the
leaf
into the next index slot of the tree.
Return the leaf’s index and the updated root.Source§fn get_latest_root(&self, storage: &dyn Storage) -> Result<L, MerkleTreeError>
fn get_latest_root(&self, storage: &dyn Storage) -> Result<L, MerkleTreeError>
Get the latest root of the tree.
Auto Trait Implementations§
impl<'a, L, H> Freeze for SparseMerkleTreeWithHistory<'a, L, H>
impl<'a, L, H> RefUnwindSafe for SparseMerkleTreeWithHistory<'a, L, H>where
L: RefUnwindSafe,
H: RefUnwindSafe,
impl<'a, L, H> Send for SparseMerkleTreeWithHistory<'a, L, H>
impl<'a, L, H> Sync for SparseMerkleTreeWithHistory<'a, L, H>
impl<'a, L, H> Unpin for SparseMerkleTreeWithHistory<'a, L, H>
impl<'a, L, H> UnwindSafe for SparseMerkleTreeWithHistory<'a, L, H>where
L: UnwindSafe,
H: UnwindSafe,
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