pub struct SparseMerkleTreeWithHistoryBounded<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>, const HISTORY_LEVEL: u32> {
pub history_index: Item<'a, u32>,
pub root_history: Map<'a, L, Empty>,
pub root_index: Map<'a, u32, L>,
pub tree: SparseMerkleTree<'a, L, H>,
}Expand description
Like SparseMerkleTree but able to check valid root hash with previous root hashes upto specified history level.
Fields
history_index: Item<'a, u32>root_history: Map<'a, L, Empty>root_index: Map<'a, u32, L>tree: SparseMerkleTree<'a, L, H>Implementations
sourceimpl<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>, const HISTORY_LEVEL: u32> SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>
impl<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>, const HISTORY_LEVEL: u32> SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>
pub const fn new(
hashes_ns: &'a str,
leafs_ns: &'a str,
level_ns: &'a str,
root_ns: &'a str,
root_history_ns: &'a str,
root_index_ns: &'a str,
history_index_ns: &'a str
) -> Self
sourcepub fn update_history_level(
&self,
storage: &mut dyn Storage
) -> Result<(), MerkleTreeError>
pub fn update_history_level(
&self,
storage: &mut dyn Storage
) -> Result<(), MerkleTreeError>
Remove storage unused and out of range stored root. The removed root might not be the earliest.
Trait Implementations
sourceimpl<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>, const HISTORY_LEVEL: u32> MerkleTree<L, H> for SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>
impl<'a, L: Serialize + DeserializeOwned + Clone + Debug + PartialEq + PrimaryKey<'a>, H: Hasher<L>, const HISTORY_LEVEL: u32> MerkleTree<L, H> for SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>
sourcefn 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.
sourcefn 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.sourcefn 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. Read moresourcefn 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, const HISTORY_LEVEL: u32> RefUnwindSafe for SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>where
H: RefUnwindSafe,
L: RefUnwindSafe,
impl<'a, L, H, const HISTORY_LEVEL: u32> Send for SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>where
H: Send,
L: Send,
impl<'a, L, H, const HISTORY_LEVEL: u32> Sync for SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>where
H: Sync,
L: Sync,
impl<'a, L, H, const HISTORY_LEVEL: u32> Unpin for SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>where
H: Unpin,
L: Unpin,
impl<'a, L, H, const HISTORY_LEVEL: u32> UnwindSafe for SparseMerkleTreeWithHistoryBounded<'a, L, H, HISTORY_LEVEL>where
H: UnwindSafe,
L: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more