pub trait NullifierTreeBackend: Sized {
type Error: Error + Send + 'static;
// Required methods
fn num_entries(&self) -> usize;
fn entries(&self) -> Box<dyn Iterator<Item = (Word, Word)> + '_>;
fn open(&self, key: &Word) -> SmtProof;
fn apply_mutations(
&mut self,
set: MutationSet<SMT_DEPTH, Word, Word>,
) -> Result<(), Self::Error>;
fn compute_mutations(
&self,
updates: impl IntoIterator<Item = (Word, Word)>,
) -> Result<MutationSet<SMT_DEPTH, Word, Word>, Self::Error>;
fn insert(
&mut self,
key: Word,
value: NullifierBlock,
) -> Result<NullifierBlock, Self::Error>;
fn get_value(&self, key: &Word) -> NullifierBlock;
fn root(&self) -> Word;
}Expand description
This trait abstracts over different SMT backends (e.g., Smt and LargeSmt) to allow
the NullifierTree to work with either implementation transparently.
Users should instantiate the backend directly (potentially with entries) and then
pass it to NullifierTree::new_unchecked.
§Invariants
Assumes the provided SMT upholds the guarantees of the NullifierTree. Specifically:
- Nullifiers are only spent once and their block numbers do not change.
- Nullifier leaf values must be valid according to
NullifierBlock.
Required Associated Types§
Required Methods§
Sourcefn num_entries(&self) -> usize
fn num_entries(&self) -> usize
Returns the number of entries in the SMT.
Sourcefn entries(&self) -> Box<dyn Iterator<Item = (Word, Word)> + '_>
fn entries(&self) -> Box<dyn Iterator<Item = (Word, Word)> + '_>
Returns all entries in the SMT as an iterator over key-value pairs.
Sourcefn open(&self, key: &Word) -> SmtProof
fn open(&self, key: &Word) -> SmtProof
Opens the leaf at the given key, returning a Merkle proof.
Sourcefn apply_mutations(
&mut self,
set: MutationSet<SMT_DEPTH, Word, Word>,
) -> Result<(), Self::Error>
fn apply_mutations( &mut self, set: MutationSet<SMT_DEPTH, Word, Word>, ) -> Result<(), Self::Error>
Applies the given mutation set to the SMT.
Sourcefn compute_mutations(
&self,
updates: impl IntoIterator<Item = (Word, Word)>,
) -> Result<MutationSet<SMT_DEPTH, Word, Word>, Self::Error>
fn compute_mutations( &self, updates: impl IntoIterator<Item = (Word, Word)>, ) -> Result<MutationSet<SMT_DEPTH, Word, Word>, Self::Error>
Computes the mutation set required to apply the given updates to the SMT.
Sourcefn insert(
&mut self,
key: Word,
value: NullifierBlock,
) -> Result<NullifierBlock, Self::Error>
fn insert( &mut self, key: Word, value: NullifierBlock, ) -> Result<NullifierBlock, Self::Error>
Inserts a key-value pair into the SMT, returning the previous value at that key.
Sourcefn get_value(&self, key: &Word) -> NullifierBlock
fn get_value(&self, key: &Word) -> NullifierBlock
Returns the value associated with the given key.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl NullifierTreeBackend for Smt
impl NullifierTreeBackend for Smt
type Error = MerkleError
Source§impl<Backend> NullifierTreeBackend for LargeSmt<Backend>where
Backend: SmtStorage,
Available on crate feature std only.
impl<Backend> NullifierTreeBackend for LargeSmt<Backend>where
Backend: SmtStorage,
std only.