pub async fn new(
        data: D,
        blocks: B,
        state: S,
        public_key: PublicKey,
        secret_key: Option<SecretKey>
        ) -> Result<Self>
    {
        let data = StoreData::new(data);
        let mut blocks = StoreBlocks::new(blocks);
        let mut state = StoreState::new(state);

        let merkle = state.read().await?;
        let length = merkle.blocks() as u32;
        let byte_length = match length {
            0 => 0,
            n => {
                let block = blocks.read(n - 1).await?;
                block.offset() as u64 + block.length() as u64
            },
        };

        Ok(Self {
            data,
            blocks,
            state,
            merkle,
            public_key,
            secret_key,
            length,
            byte_length,
        })
    }
/// Create a new instance with a custom storage backend.
Create a new instance with a custom storage backend.
Create a new instance with a custom storage backend .
pub async fn new(
        data: D,
        blocks: B,
        state: S,
        public_key: PublicKey,
        secret_key: Option<SecretKey>
        ) -> Result<Self>
    {
        let data = StoreData::new(data);
        let mut blocks = StoreBlocks::new(blocks);
        let mut state = StoreState::new(state);
        let merkle = state.read().await?;
        let length = merkle.blocks() as u32;
        let byte_length = match length {
            0 => 0,
            n => {
                let block = blocks.read(n - 1).await?;
                block.offset() as u64 + block.length() as u64
            },
        };
        Ok(Self {
            data,
            blocks,
            state,
            merkle,
            public_key,
            secret_key,
            length,
            byte_length,
        })
    }
pub async fn new ( data : D , blocks : B , state : S , public_key : PublicKey , secret_key : Option < SecretKey > ) -> Result < Self > { let data = StoreData :: new ( data ) ; let mut blocks = StoreBlocks :: new ( blocks ) ; let mut state = StoreState :: new ( state ) ; let merkle = state . read ( ) . await ? ; let length = merkle . blocks ( ) as u32 ; let byte_length = match length { 0 => 0 , n => { let block = blocks . read ( n - 1 ) . await ? ; block . offset ( ) as u64 + block . length ( ) as u64 } , } ; Ok ( Self { data , blocks , state , merkle , public_key , secret_key , length , byte_length , } ) }
Create a new instance with a custom storage backend.
Create a new instance with a custom storage backend .
data
D
blocks
B
state
S
public_key
PublicKey
secret_key
Option<SecretKey>
data
D
blocks
B
state
S
public_key
PublicKey
secret_key
Option<SecretKey>