pub trait StorageLoader: SmtStorage + Sized {
// Required methods
fn create(
data_dir: &Path,
domain: &'static str,
) -> Result<Self, StateInitializationError>;
fn load_account_tree(
self,
db: &mut Db,
) -> impl Future<Output = Result<AccountTree<LargeSmt<Self>>, StateInitializationError>> + Send;
fn load_nullifier_tree(
self,
db: &mut Db,
) -> impl Future<Output = Result<NullifierTree<LargeSmt<Self>>, StateInitializationError>> + Send;
}Expand description
Trait for loading trees from storage.
For MemoryStorage, the tree is rebuilt from database entries on each startup.
For RocksDbStorage, the tree is loaded directly from disk (much faster for large trees).
Missing or corrupted storage is handled by the verify_tree_consistency check after loading,
which detects divergence between persistent storage and the database. If divergence is detected,
the user should manually delete the tree storage directories and restart the node.
Required Methods§
Sourcefn create(
data_dir: &Path,
domain: &'static str,
) -> Result<Self, StateInitializationError>
fn create( data_dir: &Path, domain: &'static str, ) -> Result<Self, StateInitializationError>
Creates a storage backend for the given domain.
Sourcefn load_account_tree(
self,
db: &mut Db,
) -> impl Future<Output = Result<AccountTree<LargeSmt<Self>>, StateInitializationError>> + Send
fn load_account_tree( self, db: &mut Db, ) -> impl Future<Output = Result<AccountTree<LargeSmt<Self>>, StateInitializationError>> + Send
Loads an account tree, either from persistent storage or by rebuilding from DB.
Sourcefn load_nullifier_tree(
self,
db: &mut Db,
) -> impl Future<Output = Result<NullifierTree<LargeSmt<Self>>, StateInitializationError>> + Send
fn load_nullifier_tree( self, db: &mut Db, ) -> impl Future<Output = Result<NullifierTree<LargeSmt<Self>>, StateInitializationError>> + Send
Loads a nullifier tree, either from persistent storage or by rebuilding from DB.
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.
Implementations on Foreign Types§
Source§impl StorageLoader for RocksDbStorage
Available on crate feature rocksdb only.
impl StorageLoader for RocksDbStorage
rocksdb only.