Skip to main content

Database

Trait Database 

Source
pub trait Database: Sized + Send {
    type Family: Family;
    type Op: Send + Sync;
    type Journal: Journal<Self::Family, Context = Self::Context, Op = Self::Op>;
    type Config: Config<JournalConfig = <Self::Journal as Journal<Self::Family>>::Config>;
    type Digest: Digest;
    type Context: Storage + Clock + Metrics;
    type Hasher: Hasher<Digest = Self::Digest>;

    // Required methods
    fn from_sync_result(
        context: Self::Context,
        config: Self::Config,
        journal: Self::Journal,
        pinned_nodes: Option<Vec<Self::Digest>>,
        range: NonEmptyRange<Location<Self::Family>>,
        apply_batch_size: NonZeroU64,
    ) -> impl Future<Output = Result<Self, Error<Self::Family>>> + Send;
    fn persist_sync_result(
        self,
    ) -> impl Future<Output = Result<Self, Error<Self::Family>>> + Send;
    fn local_pinned_nodes(
        context: Self::Context,
        config: &Self::Config,
        target: &Target<Self::Family, Self::Digest>,
        journal: &Self::Journal,
    ) -> impl Future<Output = Result<Option<Vec<Self::Digest>>, Error<Self::Family>>> + Send;
    fn root(&self) -> Self::Digest;
}

Required Associated Types§

Source

type Family: Family

Source

type Op: Send + Sync

Source

type Journal: Journal<Self::Family, Context = Self::Context, Op = Self::Op>

Source

type Config: Config<JournalConfig = <Self::Journal as Journal<Self::Family>>::Config>

Source

type Digest: Digest

Source

type Context: Storage + Clock + Metrics

Source

type Hasher: Hasher<Digest = Self::Digest>

Required Methods§

Source

fn from_sync_result( context: Self::Context, config: Self::Config, journal: Self::Journal, pinned_nodes: Option<Vec<Self::Digest>>, range: NonEmptyRange<Location<Self::Family>>, apply_batch_size: NonZeroU64, ) -> impl Future<Output = Result<Self, Error<Self::Family>>> + Send

Build a database from the journal and pinned nodes populated by the sync engine.

Source

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

Persist any state that must remain provisional until the engine verifies the rebuilt root.

The engine calls this only after Self::root matches the requested target. Implementations that persist everything in Self::from_sync_result must explicitly return Ok(self).

Source

fn local_pinned_nodes( context: Self::Context, config: &Self::Config, target: &Target<Self::Family, Self::Digest>, journal: &Self::Journal, ) -> impl Future<Output = Result<Option<Vec<Self::Digest>>, Error<Self::Family>>> + Send

Return locally available pinned nodes for the target, if persisted local state can authenticate them.

Returning Some lets a completed sync journal reuse pinned nodes from an on-disk database instead of fetching them from peers. Returning None always falls back to fetching from peers.

Source

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

Get the root digest of the database for verification

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, C, H, T, S> Database for Immutable<F, E, K, V, C, H, T, S>
where F: Family, E: Context, K: Key, V: ValueEncoding, C: Mutable<Item = Operation<F, K, V>> + Journal<F, Context = E, Op = Operation<F, K, V>>, C::Item: EncodeShared, C::Config: Clone + Send, H: Hasher, T: Translator, S: Strategy,

Source§

type Family = F

Source§

type Op = Operation<F, K, V>

Source§

type Journal = C

Source§

type Hasher = H

Source§

type Config = Config<T, <C as Journal<F>>::Config, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

type Context = E

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 Journal = Memory<F, E, 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, K, V, H, T, S> Database for commonware_storage::qmdb::any::unordered::fixed::Db<F, E, K, V, H, T, S>
where F: Family, E: Context + Spawner, K: Array, V: FixedValue + 'static, H: Hasher, T: Translator, S: Strategy,

Source§

type Family = F

Source§

type Context = E

Source§

type Op = Operation<F, Update<K, FixedEncoding<V>>>

Source§

type Journal = Journal<E, <Db<F, E, Journal<E, Operation<F, Update<K, FixedEncoding<V>>>>, Index<T, Location<F>>, H, Update<K, FixedEncoding<V>>, { crate::qmdb::any::BITMAP_CHUNK_BYTES }, S> as Database>::Op>

Source§

type Hasher = H

Source§

type Config = Config<T, Config, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

impl<F, E, K, V, H, T, S> Database for commonware_storage::qmdb::any::ordered::fixed::Db<F, E, K, V, H, T, S>
where F: Family, E: Context + Spawner, K: Array, V: FixedValue + 'static, H: Hasher, T: Translator, S: Strategy,

Source§

type Family = F

Source§

type Context = E

Source§

type Op = Operation<F, Update<K, FixedEncoding<V>>>

Source§

type Journal = Journal<E, <Db<F, E, Journal<E, Operation<F, Update<K, FixedEncoding<V>>>>, Index<T, Location<F>>, H, Update<K, FixedEncoding<V>>, { crate::qmdb::any::BITMAP_CHUNK_BYTES }, S> as Database>::Op>

Source§

type Hasher = H

Source§

type Config = Config<T, Config, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

impl<F, E, K, V, H, T, S> Database for commonware_storage::qmdb::any::unordered::variable::Db<F, E, K, V, H, T, S>
where F: Family, E: Context + Spawner, K: Key, V: VariableValue + 'static, H: Hasher, T: Translator, S: Strategy, Operation<F, K, V>: CodecShared,

Source§

type Family = F

Source§

type Context = E

Source§

type Op = Operation<F, Update<K, VariableEncoding<V>>>

Source§

type Journal = Journal<E, <Db<F, E, Journal<E, Operation<F, Update<K, VariableEncoding<V>>>>, Index<T, Location<F>>, H, Update<K, VariableEncoding<V>>, { crate::qmdb::any::BITMAP_CHUNK_BYTES }, S> as Database>::Op>

Source§

type Hasher = H

Source§

type Config = Config<T, Config<<Operation<F, Update<K, VariableEncoding<V>>> as Read>::Cfg>, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

impl<F, E, K, V, H, T, S> Database for commonware_storage::qmdb::any::ordered::variable::Db<F, E, K, V, H, T, S>
where F: Family, E: Context + Spawner, K: Key, V: VariableValue + 'static, H: Hasher, T: Translator, S: Strategy, Operation<F, K, V>: CodecShared,

Source§

type Family = F

Source§

type Context = E

Source§

type Op = Operation<F, Update<K, VariableEncoding<V>>>

Source§

type Journal = Journal<E, <Db<F, E, Journal<E, Operation<F, Update<K, VariableEncoding<V>>>>, Index<T, Location<F>>, H, Update<K, VariableEncoding<V>>, { crate::qmdb::any::BITMAP_CHUNK_BYTES }, S> as Database>::Op>

Source§

type Hasher = H

Source§

type Config = Config<T, Config<<Operation<F, Update<K, VariableEncoding<V>>> as Read>::Cfg>, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

impl<F, E, K, V, H, T, const N: usize, S> Database for commonware_storage::qmdb::current::unordered::fixed::Db<F, E, K, V, H, T, N, S>
where F: Graftable, E: Context + Spawner, K: Array, V: FixedValue + 'static, H: Hasher, T: Translator, S: Strategy,

Source§

type Family = F

Source§

type Context = E

Source§

type Op = Operation<F, Update<K, FixedEncoding<V>>>

Source§

type Journal = Journal<E, <Db<F, E, Journal<E, Operation<F, Update<K, FixedEncoding<V>>>>, Index<T, Location<F>>, H, Update<K, FixedEncoding<V>>, N, S> as Database>::Op>

Source§

type Hasher = H

Source§

type Config = Config<T, Config, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

impl<F, E, K, V, H, T, const N: usize, S> Database for commonware_storage::qmdb::current::ordered::fixed::Db<F, E, K, V, H, T, N, S>
where F: Graftable, E: Context + Spawner, K: Array, V: FixedValue + 'static, H: Hasher, T: Translator, S: Strategy,

Source§

type Family = F

Source§

type Context = E

Source§

type Op = Operation<F, Update<K, FixedEncoding<V>>>

Source§

type Journal = Journal<E, <Db<F, E, Journal<E, Operation<F, Update<K, FixedEncoding<V>>>>, Index<T, Location<F>>, H, Update<K, FixedEncoding<V>>, N, S> as Database>::Op>

Source§

type Hasher = H

Source§

type Config = Config<T, Config, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

impl<F, E, K, V, H, T, const N: usize, S> Database for commonware_storage::qmdb::current::unordered::variable::Db<F, E, K, V, H, T, N, S>
where F: Graftable, E: Context + Spawner, K: Key, V: VariableValue + 'static, H: Hasher, T: Translator, S: Strategy, Operation<F, K, V>: CodecShared,

Source§

impl<F, E, K, V, H, T, const N: usize, S> Database for commonware_storage::qmdb::current::ordered::variable::Db<F, E, K, V, H, T, N, S>
where F: Graftable, E: Context + Spawner, K: Key, V: VariableValue + 'static, H: Hasher, T: Translator, S: Strategy, Operation<F, K, V>: CodecShared,

Source§

impl<F, E, V, C, H, S> Database for Keyless<F, E, V, C, H, S>
where F: Family, E: Context, V: ValueEncoding + Codec, C: Mutable<Item = Operation<F, V>> + Journal<F, Context = E, Op = Operation<F, V>>, C::Config: Clone + Send, H: Hasher, S: Strategy, Operation<F, V>: EncodeShared,

Source§

type Family = F

Source§

type Op = Operation<F, V>

Source§

type Journal = C

Source§

type Hasher = H

Source§

type Config = Config<<C as Journal<F>>::Config, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

type Context = E

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 Journal = Memory<F, E, Operation<F, V>>

Source§

type Config = Config<Cfg, S>

Source§

type Digest = <H as Hasher>::Digest

Source§

type Context = E

Source§

type Hasher = H