Skip to main content

DatabaseSet

Trait DatabaseSet 

Source
pub trait DatabaseSet<E>:
    Clone
    + Send
    + Sync
    + 'static {
    type Unmerkleized: Send;
    type Merkleized: Send + Sync;
    type Config: Send;
    type SyncTargets: Clone + PartialEq + Send + Sync;

    // Required methods
    fn init(
        context: E,
        config: Self::Config,
    ) -> impl Future<Output = Self> + Send;
    fn new_batches(&self) -> impl Future<Output = Self::Unmerkleized> + Send;
    fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized;
    fn matches_sync_targets(
        batches: &Self::Merkleized,
        targets: &Self::SyncTargets,
    ) -> bool;
    fn finalize(
        &self,
        batches: Self::Merkleized,
    ) -> impl Future<Output = ()> + Send;
    fn committed_targets(
        &self,
    ) -> impl Future<Output = Self::SyncTargets> + Send;
    fn rewind_to_targets(
        &self,
        targets: Self::SyncTargets,
    ) -> impl Future<Output = ()> + Send;
    fn max_rewind_depth() -> Option<usize>;
}
Expand description

A collection of individually locked ManagedDb instances.

Each database is wrapped in Arc<AsyncRwLock<...>>, so the set is cheap to clone and each database can be shared without a global lock.

E is a trait generic (not an associated type), so one set type can work across runtimes that satisfy the bounds.

Required Associated Types§

Source

type Unmerkleized: Send

Tuple of ManagedDb::Unmerkleized for every database in the set.

Source

type Merkleized: Send + Sync

Tuple of ManagedDb::Merkleized for every database in the set.

Source

type Config: Send

Configuration needed to construct every database in the set.

  • Single database sets use that database’s ManagedDb::Config.
  • Multi-database tuple sets use a tuple of per-database configs (Db1::Config, Db2::Config, ...).
Source

type SyncTargets: Clone + PartialEq + Send + Sync

Per-database sync targets extracted from a finalized block.

For a single-database set this is one target. For multi-database sets it is a tuple of targets, one per database.

Required Methods§

Source

fn init(context: E, config: Self::Config) -> impl Future<Output = Self> + Send

Construct the database set from its configuration.

Source

fn new_batches(&self) -> impl Future<Output = Self::Unmerkleized> + Send

Create unmerkleized batches from each database’s committed state.

Acquires a read lock on each database.

Source

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Create child unmerkleized batches from a pending merkleized parent.

No lock is needed; reads come from the in-memory merkleized state.

Source

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Return true if merkleized batches match the committed sync targets.

Source

fn finalize(&self, batches: Self::Merkleized) -> impl Future<Output = ()> + Send

Apply each merkleized batch’s changeset to its underlying database.

Acquires a write lock on each database.

Source

fn committed_targets(&self) -> impl Future<Output = Self::SyncTargets> + Send

Return sync targets for the set’s current committed state.

Source

fn rewind_to_targets( &self, targets: Self::SyncTargets, ) -> impl Future<Output = ()> + Send

Rewind the set to the provided per-database targets.

Rewind failures are fatal for startup recovery and therefore panic.

Source

fn max_rewind_depth() -> Option<usize>

Return the most restrictive finite rewind depth across the database set.

None means every database in the set is unbounded.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<E: Send + Sync + Metrics, DB1: ManagedDb<E> + 'static> DatabaseSet<E> for (Arc<AsyncRwLock<DB1>>,)

Source§

type Unmerkleized = (<DB1 as ManagedDb<E>>::Unmerkleized,)

Source§

type Merkleized = (<DB1 as ManagedDb<E>>::Merkleized,)

Source§

type Config = (<DB1 as ManagedDb<E>>::Config,)

Source§

type SyncTargets = (<DB1 as ManagedDb<E>>::SyncTarget,)

Source§

async fn init(context: E, config: Self::Config) -> Self

Source§

async fn new_batches(&self) -> Self::Unmerkleized

Source§

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Source§

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Source§

async fn finalize(&self, batches: Self::Merkleized)

Source§

async fn committed_targets(&self) -> Self::SyncTargets

Source§

async fn rewind_to_targets(&self, targets: Self::SyncTargets)

Source§

fn max_rewind_depth() -> Option<usize>

Source§

impl<E: Send + Sync + Metrics, DB1: ManagedDb<E> + 'static, DB2: ManagedDb<E> + 'static> DatabaseSet<E> for (Arc<AsyncRwLock<DB1>>, Arc<AsyncRwLock<DB2>>)

Source§

type Unmerkleized = (<DB1 as ManagedDb<E>>::Unmerkleized, <DB2 as ManagedDb<E>>::Unmerkleized)

Source§

type Merkleized = (<DB1 as ManagedDb<E>>::Merkleized, <DB2 as ManagedDb<E>>::Merkleized)

Source§

type Config = (<DB1 as ManagedDb<E>>::Config, <DB2 as ManagedDb<E>>::Config)

Source§

type SyncTargets = (<DB1 as ManagedDb<E>>::SyncTarget, <DB2 as ManagedDb<E>>::SyncTarget)

Source§

async fn init(context: E, config: Self::Config) -> Self

Source§

async fn new_batches(&self) -> Self::Unmerkleized

Source§

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Source§

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Source§

async fn finalize(&self, batches: Self::Merkleized)

Source§

async fn committed_targets(&self) -> Self::SyncTargets

Source§

async fn rewind_to_targets(&self, targets: Self::SyncTargets)

Source§

fn max_rewind_depth() -> Option<usize>

Source§

impl<E: Send + Sync + Metrics, DB1: ManagedDb<E> + 'static, DB2: ManagedDb<E> + 'static, DB3: ManagedDb<E> + 'static> DatabaseSet<E> for (Arc<AsyncRwLock<DB1>>, Arc<AsyncRwLock<DB2>>, Arc<AsyncRwLock<DB3>>)

Source§

type Unmerkleized = (<DB1 as ManagedDb<E>>::Unmerkleized, <DB2 as ManagedDb<E>>::Unmerkleized, <DB3 as ManagedDb<E>>::Unmerkleized)

Source§

type Merkleized = (<DB1 as ManagedDb<E>>::Merkleized, <DB2 as ManagedDb<E>>::Merkleized, <DB3 as ManagedDb<E>>::Merkleized)

Source§

type Config = (<DB1 as ManagedDb<E>>::Config, <DB2 as ManagedDb<E>>::Config, <DB3 as ManagedDb<E>>::Config)

Source§

type SyncTargets = (<DB1 as ManagedDb<E>>::SyncTarget, <DB2 as ManagedDb<E>>::SyncTarget, <DB3 as ManagedDb<E>>::SyncTarget)

Source§

async fn init(context: E, config: Self::Config) -> Self

Source§

async fn new_batches(&self) -> Self::Unmerkleized

Source§

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Source§

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Source§

async fn finalize(&self, batches: Self::Merkleized)

Source§

async fn committed_targets(&self) -> Self::SyncTargets

Source§

async fn rewind_to_targets(&self, targets: Self::SyncTargets)

Source§

fn max_rewind_depth() -> Option<usize>

Source§

impl<E: Send + Sync + Metrics, DB1: ManagedDb<E> + 'static, DB2: ManagedDb<E> + 'static, DB3: ManagedDb<E> + 'static, DB4: ManagedDb<E> + 'static> DatabaseSet<E> for (Arc<AsyncRwLock<DB1>>, Arc<AsyncRwLock<DB2>>, Arc<AsyncRwLock<DB3>>, Arc<AsyncRwLock<DB4>>)

Source§

type Unmerkleized = (<DB1 as ManagedDb<E>>::Unmerkleized, <DB2 as ManagedDb<E>>::Unmerkleized, <DB3 as ManagedDb<E>>::Unmerkleized, <DB4 as ManagedDb<E>>::Unmerkleized)

Source§

type Merkleized = (<DB1 as ManagedDb<E>>::Merkleized, <DB2 as ManagedDb<E>>::Merkleized, <DB3 as ManagedDb<E>>::Merkleized, <DB4 as ManagedDb<E>>::Merkleized)

Source§

type Config = (<DB1 as ManagedDb<E>>::Config, <DB2 as ManagedDb<E>>::Config, <DB3 as ManagedDb<E>>::Config, <DB4 as ManagedDb<E>>::Config)

Source§

type SyncTargets = (<DB1 as ManagedDb<E>>::SyncTarget, <DB2 as ManagedDb<E>>::SyncTarget, <DB3 as ManagedDb<E>>::SyncTarget, <DB4 as ManagedDb<E>>::SyncTarget)

Source§

async fn init(context: E, config: Self::Config) -> Self

Source§

async fn new_batches(&self) -> Self::Unmerkleized

Source§

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Source§

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Source§

async fn finalize(&self, batches: Self::Merkleized)

Source§

async fn committed_targets(&self) -> Self::SyncTargets

Source§

async fn rewind_to_targets(&self, targets: Self::SyncTargets)

Source§

fn max_rewind_depth() -> Option<usize>

Source§

impl<E: Send + Sync + Metrics, DB1: ManagedDb<E> + 'static, DB2: ManagedDb<E> + 'static, DB3: ManagedDb<E> + 'static, DB4: ManagedDb<E> + 'static, DB5: ManagedDb<E> + 'static> DatabaseSet<E> for (Arc<AsyncRwLock<DB1>>, Arc<AsyncRwLock<DB2>>, Arc<AsyncRwLock<DB3>>, Arc<AsyncRwLock<DB4>>, Arc<AsyncRwLock<DB5>>)

Source§

type Unmerkleized = (<DB1 as ManagedDb<E>>::Unmerkleized, <DB2 as ManagedDb<E>>::Unmerkleized, <DB3 as ManagedDb<E>>::Unmerkleized, <DB4 as ManagedDb<E>>::Unmerkleized, <DB5 as ManagedDb<E>>::Unmerkleized)

Source§

type Merkleized = (<DB1 as ManagedDb<E>>::Merkleized, <DB2 as ManagedDb<E>>::Merkleized, <DB3 as ManagedDb<E>>::Merkleized, <DB4 as ManagedDb<E>>::Merkleized, <DB5 as ManagedDb<E>>::Merkleized)

Source§

type Config = (<DB1 as ManagedDb<E>>::Config, <DB2 as ManagedDb<E>>::Config, <DB3 as ManagedDb<E>>::Config, <DB4 as ManagedDb<E>>::Config, <DB5 as ManagedDb<E>>::Config)

Source§

type SyncTargets = (<DB1 as ManagedDb<E>>::SyncTarget, <DB2 as ManagedDb<E>>::SyncTarget, <DB3 as ManagedDb<E>>::SyncTarget, <DB4 as ManagedDb<E>>::SyncTarget, <DB5 as ManagedDb<E>>::SyncTarget)

Source§

async fn init(context: E, config: Self::Config) -> Self

Source§

async fn new_batches(&self) -> Self::Unmerkleized

Source§

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Source§

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Source§

async fn finalize(&self, batches: Self::Merkleized)

Source§

async fn committed_targets(&self) -> Self::SyncTargets

Source§

async fn rewind_to_targets(&self, targets: Self::SyncTargets)

Source§

fn max_rewind_depth() -> Option<usize>

Source§

impl<E: Send + Sync + Metrics, DB1: ManagedDb<E> + 'static, DB2: ManagedDb<E> + 'static, DB3: ManagedDb<E> + 'static, DB4: ManagedDb<E> + 'static, DB5: ManagedDb<E> + 'static, DB6: ManagedDb<E> + 'static> DatabaseSet<E> for (Arc<AsyncRwLock<DB1>>, Arc<AsyncRwLock<DB2>>, Arc<AsyncRwLock<DB3>>, Arc<AsyncRwLock<DB4>>, Arc<AsyncRwLock<DB5>>, Arc<AsyncRwLock<DB6>>)

Source§

type Unmerkleized = (<DB1 as ManagedDb<E>>::Unmerkleized, <DB2 as ManagedDb<E>>::Unmerkleized, <DB3 as ManagedDb<E>>::Unmerkleized, <DB4 as ManagedDb<E>>::Unmerkleized, <DB5 as ManagedDb<E>>::Unmerkleized, <DB6 as ManagedDb<E>>::Unmerkleized)

Source§

type Merkleized = (<DB1 as ManagedDb<E>>::Merkleized, <DB2 as ManagedDb<E>>::Merkleized, <DB3 as ManagedDb<E>>::Merkleized, <DB4 as ManagedDb<E>>::Merkleized, <DB5 as ManagedDb<E>>::Merkleized, <DB6 as ManagedDb<E>>::Merkleized)

Source§

type Config = (<DB1 as ManagedDb<E>>::Config, <DB2 as ManagedDb<E>>::Config, <DB3 as ManagedDb<E>>::Config, <DB4 as ManagedDb<E>>::Config, <DB5 as ManagedDb<E>>::Config, <DB6 as ManagedDb<E>>::Config)

Source§

type SyncTargets = (<DB1 as ManagedDb<E>>::SyncTarget, <DB2 as ManagedDb<E>>::SyncTarget, <DB3 as ManagedDb<E>>::SyncTarget, <DB4 as ManagedDb<E>>::SyncTarget, <DB5 as ManagedDb<E>>::SyncTarget, <DB6 as ManagedDb<E>>::SyncTarget)

Source§

async fn init(context: E, config: Self::Config) -> Self

Source§

async fn new_batches(&self) -> Self::Unmerkleized

Source§

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Source§

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Source§

async fn finalize(&self, batches: Self::Merkleized)

Source§

async fn committed_targets(&self) -> Self::SyncTargets

Source§

async fn rewind_to_targets(&self, targets: Self::SyncTargets)

Source§

fn max_rewind_depth() -> Option<usize>

Source§

impl<E: Send + Sync + Metrics, DB1: ManagedDb<E> + 'static, DB2: ManagedDb<E> + 'static, DB3: ManagedDb<E> + 'static, DB4: ManagedDb<E> + 'static, DB5: ManagedDb<E> + 'static, DB6: ManagedDb<E> + 'static, DB7: ManagedDb<E> + 'static> DatabaseSet<E> for (Arc<AsyncRwLock<DB1>>, Arc<AsyncRwLock<DB2>>, Arc<AsyncRwLock<DB3>>, Arc<AsyncRwLock<DB4>>, Arc<AsyncRwLock<DB5>>, Arc<AsyncRwLock<DB6>>, Arc<AsyncRwLock<DB7>>)

Source§

type Unmerkleized = (<DB1 as ManagedDb<E>>::Unmerkleized, <DB2 as ManagedDb<E>>::Unmerkleized, <DB3 as ManagedDb<E>>::Unmerkleized, <DB4 as ManagedDb<E>>::Unmerkleized, <DB5 as ManagedDb<E>>::Unmerkleized, <DB6 as ManagedDb<E>>::Unmerkleized, <DB7 as ManagedDb<E>>::Unmerkleized)

Source§

type Merkleized = (<DB1 as ManagedDb<E>>::Merkleized, <DB2 as ManagedDb<E>>::Merkleized, <DB3 as ManagedDb<E>>::Merkleized, <DB4 as ManagedDb<E>>::Merkleized, <DB5 as ManagedDb<E>>::Merkleized, <DB6 as ManagedDb<E>>::Merkleized, <DB7 as ManagedDb<E>>::Merkleized)

Source§

type Config = (<DB1 as ManagedDb<E>>::Config, <DB2 as ManagedDb<E>>::Config, <DB3 as ManagedDb<E>>::Config, <DB4 as ManagedDb<E>>::Config, <DB5 as ManagedDb<E>>::Config, <DB6 as ManagedDb<E>>::Config, <DB7 as ManagedDb<E>>::Config)

Source§

type SyncTargets = (<DB1 as ManagedDb<E>>::SyncTarget, <DB2 as ManagedDb<E>>::SyncTarget, <DB3 as ManagedDb<E>>::SyncTarget, <DB4 as ManagedDb<E>>::SyncTarget, <DB5 as ManagedDb<E>>::SyncTarget, <DB6 as ManagedDb<E>>::SyncTarget, <DB7 as ManagedDb<E>>::SyncTarget)

Source§

async fn init(context: E, config: Self::Config) -> Self

Source§

async fn new_batches(&self) -> Self::Unmerkleized

Source§

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Source§

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Source§

async fn finalize(&self, batches: Self::Merkleized)

Source§

async fn committed_targets(&self) -> Self::SyncTargets

Source§

async fn rewind_to_targets(&self, targets: Self::SyncTargets)

Source§

fn max_rewind_depth() -> Option<usize>

Source§

impl<E: Send + Sync + Metrics, DB1: ManagedDb<E> + 'static, DB2: ManagedDb<E> + 'static, DB3: ManagedDb<E> + 'static, DB4: ManagedDb<E> + 'static, DB5: ManagedDb<E> + 'static, DB6: ManagedDb<E> + 'static, DB7: ManagedDb<E> + 'static, DB8: ManagedDb<E> + 'static> DatabaseSet<E> for (Arc<AsyncRwLock<DB1>>, Arc<AsyncRwLock<DB2>>, Arc<AsyncRwLock<DB3>>, Arc<AsyncRwLock<DB4>>, Arc<AsyncRwLock<DB5>>, Arc<AsyncRwLock<DB6>>, Arc<AsyncRwLock<DB7>>, Arc<AsyncRwLock<DB8>>)

Source§

type Unmerkleized = (<DB1 as ManagedDb<E>>::Unmerkleized, <DB2 as ManagedDb<E>>::Unmerkleized, <DB3 as ManagedDb<E>>::Unmerkleized, <DB4 as ManagedDb<E>>::Unmerkleized, <DB5 as ManagedDb<E>>::Unmerkleized, <DB6 as ManagedDb<E>>::Unmerkleized, <DB7 as ManagedDb<E>>::Unmerkleized, <DB8 as ManagedDb<E>>::Unmerkleized)

Source§

type Merkleized = (<DB1 as ManagedDb<E>>::Merkleized, <DB2 as ManagedDb<E>>::Merkleized, <DB3 as ManagedDb<E>>::Merkleized, <DB4 as ManagedDb<E>>::Merkleized, <DB5 as ManagedDb<E>>::Merkleized, <DB6 as ManagedDb<E>>::Merkleized, <DB7 as ManagedDb<E>>::Merkleized, <DB8 as ManagedDb<E>>::Merkleized)

Source§

type Config = (<DB1 as ManagedDb<E>>::Config, <DB2 as ManagedDb<E>>::Config, <DB3 as ManagedDb<E>>::Config, <DB4 as ManagedDb<E>>::Config, <DB5 as ManagedDb<E>>::Config, <DB6 as ManagedDb<E>>::Config, <DB7 as ManagedDb<E>>::Config, <DB8 as ManagedDb<E>>::Config)

Source§

type SyncTargets = (<DB1 as ManagedDb<E>>::SyncTarget, <DB2 as ManagedDb<E>>::SyncTarget, <DB3 as ManagedDb<E>>::SyncTarget, <DB4 as ManagedDb<E>>::SyncTarget, <DB5 as ManagedDb<E>>::SyncTarget, <DB6 as ManagedDb<E>>::SyncTarget, <DB7 as ManagedDb<E>>::SyncTarget, <DB8 as ManagedDb<E>>::SyncTarget)

Source§

async fn init(context: E, config: Self::Config) -> Self

Source§

async fn new_batches(&self) -> Self::Unmerkleized

Source§

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Source§

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Source§

async fn finalize(&self, batches: Self::Merkleized)

Source§

async fn committed_targets(&self) -> Self::SyncTargets

Source§

async fn rewind_to_targets(&self, targets: Self::SyncTargets)

Source§

fn max_rewind_depth() -> Option<usize>

Source§

impl<E: Send + Sync, T: ManagedDb<E> + 'static> DatabaseSet<E> for Arc<AsyncRwLock<T>>

Implement DatabaseSet for a single ManagedDb behind a lock.

Source§

type Unmerkleized = <T as ManagedDb<E>>::Unmerkleized

Source§

type Merkleized = <T as ManagedDb<E>>::Merkleized

Source§

type Config = <T as ManagedDb<E>>::Config

Source§

type SyncTargets = <T as ManagedDb<E>>::SyncTarget

Source§

async fn init(context: E, config: Self::Config) -> Self

Source§

async fn new_batches(&self) -> Self::Unmerkleized

Source§

fn fork_batches(parent: &Self::Merkleized) -> Self::Unmerkleized

Source§

fn matches_sync_targets( batches: &Self::Merkleized, targets: &Self::SyncTargets, ) -> bool

Source§

async fn finalize(&self, batches: Self::Merkleized)

Source§

async fn committed_targets(&self) -> Self::SyncTargets

Source§

async fn rewind_to_targets(&self, target: Self::SyncTargets)

Source§

fn max_rewind_depth() -> Option<usize>

Implementors§