Skip to main content

StorageLoader

Trait StorageLoader 

Source
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§

Source

fn create( data_dir: &Path, domain: &'static str, ) -> Result<Self, StateInitializationError>

Creates a storage backend for the given domain.

Source

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.

Source

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.
Source§

fn create( data_dir: &Path, domain: &'static str, ) -> Result<Self, StateInitializationError>

Source§

async fn load_account_tree( self, db: &mut Db, ) -> Result<AccountTree<LargeSmt<Self>>, StateInitializationError>

Source§

async fn load_nullifier_tree( self, db: &mut Db, ) -> Result<NullifierTree<LargeSmt<Self>>, StateInitializationError>

Implementors§