Skip to main content

Database

Trait Database 

Source
pub trait Database: Sized + Send {
    type Family: Family;
    type Op: Encode + Send;
    type Config: Clone;
    type Digest: Digest;
    type Context: Storage + Clock + Metrics;
    type Hasher: Hasher<Digest = Self::Digest>;

    // Required methods
    fn from_validated_state(
        context: Self::Context,
        config: Self::Config,
        state: ValidatedState<Self::Family, Self::Op, Self::Digest>,
    ) -> impl Future<Output = Result<Self, Error<Self::Family>>> + Send;
    fn inactivity_floor(op: &Self::Op) -> Option<Location<Self::Family>>;
    fn root(&self) -> Self::Digest;
    fn persist_compact_state(
        &self,
    ) -> impl Future<Output = Result<(), Error<Self::Family>>> + Send;
}
Expand description

Database types that can be initialized directly from compact state.

Required Associated Types§

Required Methods§

Source

fn from_validated_state( context: Self::Context, config: Self::Config, state: ValidatedState<Self::Family, Self::Op, Self::Digest>, ) -> impl Future<Output = Result<Self, Error<Self::Family>>> + Send

Build a database from authenticated state in memory.

The caller has already validated last_commit_proof and the compact frontier against the requested target root and passes the derived validation artifacts with the state. This constructor must not durably persist anything; persistence happens only after the caller re-checks that Self::root() matches the target root.

Source

fn inactivity_floor(op: &Self::Op) -> Option<Location<Self::Family>>

Return the inactivity floor if the operation is a commit.

Source

fn root(&self) -> Self::Digest

Get the root digest for final verification.

Source

fn persist_compact_state( &self, ) -> impl Future<Output = Result<(), Error<Self::Family>>> + Send

Persist the compact-initialized state once the caller has verified its root.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F, E, K, V, H, Cfg, S> Database for commonware_storage::qmdb::immutable::CompactDb<F, E, K, V, H, Cfg, S>
where F: Family, E: Context, K: Key, V: ValueEncoding, H: Hasher, S: Strategy, Operation<F, K, V>: EncodeShared + Read<Cfg = Cfg>, Cfg: Clone + Send + Sync + 'static,

Source§

type Family = F

Source§

type Op = Operation<F, K, V>

Source§

type Config = Config<Cfg, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

type Context = E

Source§

type Hasher = H

Source§

impl<F, E, V, H, Cfg, S> Database for commonware_storage::qmdb::keyless::CompactDb<F, E, V, H, Cfg, S>
where F: Family, E: Context, V: ValueEncoding + Codec, H: Hasher, S: Strategy, Operation<F, V>: EncodeShared + Read<Cfg = Cfg>, Cfg: Clone + Send + Sync + 'static,

Source§

type Family = F

Source§

type Op = Operation<F, V>

Source§

type Config = Config<Cfg, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

type Context = E

Source§

type Hasher = H