Struct merkletree::merkle::MerkleTree
source · pub struct MerkleTree<E, A, S, BaseTreeArity = U2, SubTreeArity = U0, TopTreeArity = U0>where
E: Element,
A: Algorithm<E>,
S: Store<E>,
BaseTreeArity: Unsigned,
SubTreeArity: Unsigned,
TopTreeArity: Unsigned,{ /* private fields */ }
Implementations§
source§impl<E: Element, A: Algorithm<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> MerkleTree<E, A, LevelCacheStore<E, File>, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E: Element, A: Algorithm<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> MerkleTree<E, A, LevelCacheStore<E, File>, BaseTreeArity, SubTreeArity, TopTreeArity>
sourcepub fn set_external_reader_path(&mut self, path: &Path) -> Result<()>
pub fn set_external_reader_path(&mut self, path: &Path) -> Result<()>
Given a pathbuf, instantiate an ExternalReader and set it for the LevelCacheStore.
sourcepub fn from_store_configs_and_replica(
leafs: usize,
configs: &[StoreConfig],
replica_config: &ReplicaConfig,
) -> Result<MerkleTree<E, A, LevelCacheStore<E, File>, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_store_configs_and_replica( leafs: usize, configs: &[StoreConfig], replica_config: &ReplicaConfig, ) -> Result<MerkleTree<E, A, LevelCacheStore<E, File>, BaseTreeArity, SubTreeArity, TopTreeArity>>
Given a set of StoreConfig’s (i.e on-disk references to levelcache stores) and replica config info, instantiate each tree and return a compound merkle tree with them. The ordering of the trees is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
sourcepub fn from_sub_tree_store_configs_and_replica(
leafs: usize,
configs: &[StoreConfig],
replica_config: &ReplicaConfig,
) -> Result<MerkleTree<E, A, LevelCacheStore<E, File>, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_sub_tree_store_configs_and_replica( leafs: usize, configs: &[StoreConfig], replica_config: &ReplicaConfig, ) -> Result<MerkleTree<E, A, LevelCacheStore<E, File>, BaseTreeArity, SubTreeArity, TopTreeArity>>
Given a set of StoreConfig’s (i.e on-disk references to levelcache stores) and replica config info, instantiate each sub tree and return a compound merkle tree with them. The ordering of the trees is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
source§impl<E: Element, A: Algorithm<E>, S: Store<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E: Element, A: Algorithm<E>, S: Store<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
sourcepub fn new<I: IntoIterator<Item = E>>(
data: I,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn new<I: IntoIterator<Item = E>>( data: I, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Creates new merkle from a sequence of hashes.
sourcepub fn new_with_config<I: IntoIterator<Item = E>>(
data: I,
config: StoreConfig,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn new_with_config<I: IntoIterator<Item = E>>( data: I, config: StoreConfig, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Creates new merkle from a sequence of hashes.
sourcepub fn from_data<O: Hashable<A>, I: IntoIterator<Item = O>>(
data: I,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_data<O: Hashable<A>, I: IntoIterator<Item = O>>( data: I, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Creates new merkle tree from a list of hashable objects.
sourcepub fn from_data_with_config<O: Hashable<A>, I: IntoIterator<Item = O>>(
data: I,
config: StoreConfig,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_data_with_config<O: Hashable<A>, I: IntoIterator<Item = O>>( data: I, config: StoreConfig, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Creates new merkle tree from a list of hashable objects.
sourcepub fn from_data_store(
data: S,
leafs: usize,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_data_store( data: S, leafs: usize, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Creates new merkle tree from an already allocated ‘Store’ (used with ‘Store::new_from_disk’). The specified ‘size’ is the number of base data leafs in the MT.
sourcepub fn from_tree_slice(
data: &[u8],
leafs: usize,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_tree_slice( data: &[u8], leafs: usize, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Represent a fully constructed merkle tree from a provided slice.
sourcepub fn from_tree_slice_with_config(
data: &[u8],
leafs: usize,
config: StoreConfig,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_tree_slice_with_config( data: &[u8], leafs: usize, config: StoreConfig, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Represent a fully constructed merkle tree from a provided slice.
sourcepub fn from_trees(
trees: Vec<MerkleTree<E, A, S, BaseTreeArity>>,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_trees( trees: Vec<MerkleTree<E, A, S, BaseTreeArity>>, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Creates new compound merkle tree from a vector of merkle trees. The ordering of the trees is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
sourcepub fn from_sub_trees(
trees: Vec<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity>>,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_sub_trees( trees: Vec<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity>>, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Creates new top layer merkle tree from a vector of merkle trees with sub-trees. The ordering of the trees is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
sourcepub fn from_sub_trees_as_trees(
trees: Vec<MerkleTree<E, A, S, BaseTreeArity>>,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_sub_trees_as_trees( trees: Vec<MerkleTree<E, A, S, BaseTreeArity>>, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Creates new top layer merkle tree from a vector of merkle trees by first constructing the appropriate sub-trees. The ordering of the trees is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
sourcepub fn from_slices(
tree_data: &[&[u8]],
leafs: usize,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity>>
pub fn from_slices( tree_data: &[&[u8]], leafs: usize, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity>>
Create a compound merkle tree given already constructed merkle trees contained as a slices. The ordering of the trees is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
sourcepub fn from_slices_with_configs(
tree_data: &[&[u8]],
leafs: usize,
configs: &[StoreConfig],
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_slices_with_configs( tree_data: &[&[u8]], leafs: usize, configs: &[StoreConfig], ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Create a compound merkle tree given already constructed merkle trees contained as a slices, along with configs for persistence. The ordering of the trees is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
sourcepub fn from_stores(
leafs: usize,
stores: Vec<S>,
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_stores( leafs: usize, stores: Vec<S>, ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Given a set of Stores (i.e. backing to MTs), instantiate each tree and return a compound merkle tree with them. The ordering of the stores is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
sourcepub fn from_store_configs(
leafs: usize,
configs: &[StoreConfig],
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_store_configs( leafs: usize, configs: &[StoreConfig], ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Given a set of StoreConfig’s (i.e on-disk references to disk stores), instantiate each tree and return a compound merkle tree with them. The ordering of the trees is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
sourcepub fn from_sub_tree_store_configs(
leafs: usize,
configs: &[StoreConfig],
) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
pub fn from_sub_tree_store_configs( leafs: usize, configs: &[StoreConfig], ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>>
Given a set of StoreConfig’s (i.e on-disk references to dis stores), instantiate each sub tree and return a compound merkle tree with them. The ordering of the trees is significant, as trees are leaf indexed / addressable in the same sequence that they are provided here.
sourcepub fn gen_proof(&self, i: usize) -> Result<Proof<E, BaseTreeArity>>
pub fn gen_proof(&self, i: usize) -> Result<Proof<E, BaseTreeArity>>
Generate merkle tree inclusion proof for leaf i
sourcepub fn gen_cached_proof(
&self,
i: usize,
rows_to_discard: Option<usize>,
) -> Result<Proof<E, BaseTreeArity>>
pub fn gen_cached_proof( &self, i: usize, rows_to_discard: Option<usize>, ) -> Result<Proof<E, BaseTreeArity>>
Generate merkle tree inclusion proof for leaf i
by first
building a partial tree (returned) along with the proof.
‘rows_to_discard’ is an option that will be used if set (even
if it may cause an error), otherwise a reasonable default is
chosen.
Return value is a Result tuple of the proof and the partial tree that was constructed.
sourcepub fn compact(
&mut self,
config: StoreConfig,
store_version: u32,
) -> Result<bool>
pub fn compact( &mut self, config: StoreConfig, store_version: u32, ) -> Result<bool>
Truncates the data for later access via LevelCacheStore interface.
pub fn reinit(&mut self) -> Result<()>
sourcepub fn delete(&self, config: StoreConfig) -> Result<()>
pub fn delete(&self, config: StoreConfig) -> Result<()>
Removes the backing store for this merkle tree.
pub fn read_range(&self, start: usize, end: usize) -> Result<Vec<E>>
pub fn read_range_into( &self, start: usize, end: usize, buf: &mut [u8], ) -> Result<()>
sourcepub fn read_into(&self, pos: usize, buf: &mut [u8]) -> Result<()>
pub fn read_into(&self, pos: usize, buf: &mut [u8]) -> Result<()>
Reads into a pre-allocated slice (for optimization purposes).
sourcepub fn from_byte_slice_with_config(
leafs: &[u8],
config: StoreConfig,
) -> Result<Self>
pub fn from_byte_slice_with_config( leafs: &[u8], config: StoreConfig, ) -> Result<Self>
Build the tree given a slice of all leafs, in bytes form.
sourcepub fn from_byte_slice(leafs: &[u8]) -> Result<Self>
pub fn from_byte_slice(leafs: &[u8]) -> Result<Self>
Build the tree given a slice of all leafs, in bytes form.
source§impl<E: Element, A: Algorithm<E>, S: Store<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E: Element, A: Algorithm<E>, S: Store<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
sourcepub fn try_from_iter<I: IntoIterator<Item = Result<E>>>(into: I) -> Result<Self>
pub fn try_from_iter<I: IntoIterator<Item = Result<E>>>(into: I) -> Result<Self>
Attempts to create a new merkle tree using hashable objects yielded by the provided iterator. This method returns the first error yielded by the iterator, if the iterator yielded an error.
sourcepub fn try_from_iter_with_config<I: IntoIterator<Item = Result<E>>>(
into: I,
config: StoreConfig,
) -> Result<Self>
pub fn try_from_iter_with_config<I: IntoIterator<Item = Result<E>>>( into: I, config: StoreConfig, ) -> Result<Self>
Attempts to create a new merkle tree using hashable objects yielded by the provided iterator and store config. This method returns the first error yielded by the iterator, if the iterator yielded an error.
Trait Implementations§
source§impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> Clone for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> Clone for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
source§fn clone(
&self,
) -> MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
fn clone( &self, ) -> MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<E: Element, A: Algorithm<E>, S: Store<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> Debug for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E: Element, A: Algorithm<E>, S: Store<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> Debug for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
source§impl<E: Element, A: Algorithm<E>, S: Store<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> FromIndexedParallelIterator<E, BaseTreeArity> for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E: Element, A: Algorithm<E>, S: Store<E>, BaseTreeArity: Unsigned, SubTreeArity: Unsigned, TopTreeArity: Unsigned> FromIndexedParallelIterator<E, BaseTreeArity> for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
source§fn from_par_iter<I>(into: I) -> Result<Self>
fn from_par_iter<I>(into: I) -> Result<Self>
Creates new merkle tree from an iterator over hashable objects.
source§fn from_par_iter_with_config<I>(into: I, config: StoreConfig) -> Result<Self>
fn from_par_iter_with_config<I>(into: I, config: StoreConfig) -> Result<Self>
Creates new merkle tree from an iterator over hashable objects.
source§impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> PartialEq for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> PartialEq for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
source§fn eq(
&self,
other: &MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>,
) -> bool
fn eq( &self, other: &MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>, ) -> bool
self
and other
values to be equal, and is used
by ==
.impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> Eq for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> StructuralPartialEq for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
Auto Trait Implementations§
impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> Freeze for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> RefUnwindSafe for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>where
E: RefUnwindSafe,
S: RefUnwindSafe,
A: RefUnwindSafe,
BaseTreeArity: RefUnwindSafe,
SubTreeArity: RefUnwindSafe,
TopTreeArity: RefUnwindSafe,
impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> Send for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> Sync for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> Unpin for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>
impl<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity> UnwindSafe for MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>where
E: UnwindSafe,
S: UnwindSafe,
A: UnwindSafe,
BaseTreeArity: UnwindSafe,
SubTreeArity: UnwindSafe,
TopTreeArity: 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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>
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>
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