pub trait SmtBackendReader: Sized {
type Error: Error + Send + 'static;
// Required methods
fn num_leaves(&self) -> usize;
fn num_entries(&self) -> usize;
fn leaves(
&self,
) -> Box<dyn Iterator<Item = (LeafIndex<SMT_DEPTH>, SmtLeaf)> + '_>;
fn entries(&self) -> Box<dyn Iterator<Item = (Word, Word)> + '_>;
fn open(&self, key: &Word) -> SmtProof;
fn get_value(&self, key: &Word) -> Word;
fn get_leaf(&self, key: &Word) -> SmtLeaf;
fn root(&self) -> Word;
}Expand description
Abstracts over the read-only operations of the different SMT backends (e.g. Smt and
LargeSmt), so that the block trees can work with either implementation transparently.
This trait is value-agnostic: leaves are stored as raw Words. Trees that wrap a more
specific value type (such as the nullifier tree) are responsible for converting to and from
Word in their own accessors.
The method set is intentionally the superset required by both the account and nullifier trees,
so a given tree only uses the subset relevant to it (e.g. the account tree iterates
leaves, the nullifier tree iterates entries).
This trait contains only read-only methods. For write methods, see SmtBackend.
Required Associated Types§
Required Methods§
Sourcefn num_leaves(&self) -> usize
fn num_leaves(&self) -> usize
Returns the number of leaves in the SMT.
Sourcefn num_entries(&self) -> usize
fn num_entries(&self) -> usize
Returns the number of key-value entries in the SMT.
This can exceed Self::num_leaves when keys collide into the same leaf.
Sourcefn leaves(
&self,
) -> Box<dyn Iterator<Item = (LeafIndex<SMT_DEPTH>, SmtLeaf)> + '_>
fn leaves( &self, ) -> Box<dyn Iterator<Item = (LeafIndex<SMT_DEPTH>, SmtLeaf)> + '_>
Returns all leaves in the SMT as an iterator over leaf index and leaf pairs.
Sourcefn entries(&self) -> Box<dyn Iterator<Item = (Word, Word)> + '_>
fn entries(&self) -> Box<dyn Iterator<Item = (Word, Word)> + '_>
Returns all key-value entries in the SMT.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl SmtBackendReader for Smt
impl SmtBackendReader for Smt
type Error = MerkleError
Source§impl<Backend> SmtBackendReader for LargeSmt<Backend>where
Backend: SmtStorageReader,
Available on crate feature std only.
impl<Backend> SmtBackendReader for LargeSmt<Backend>where
Backend: SmtStorageReader,
std only.