use crate::{mmr::Location, qmdb::sync::Journal, translator::Translator}; use commonware_cryptography::Digest; use std::{future::Future, ops::Range}; pub trait Config { type JournalConfig; fn journal_config(&self) -> Self::JournalConfig; } impl Config for crate::qmdb::any::Config { type JournalConfig = J; fn journal_config(&self) -> Self::JournalConfig { self.journal_config.clone() } } impl Config for crate::qmdb::immutable::Config { type JournalConfig = C; fn journal_config(&self) -> Self::JournalConfig { self.log.clone() } } pub trait Database: Sized + Send { type Op: Send; type Journal: Journal; type Config: Config::Config>; type Digest: Digest; type Context: commonware_runtime::Storage + commonware_runtime::Clock + commonware_runtime::Metrics; type Hasher: commonware_cryptography::Hasher; /// Build a database from the journal and pinned nodes populated by the sync engine. fn from_sync_result( context: Self::Context, config: Self::Config, journal: Self::Journal, pinned_nodes: Option>, range: Range, apply_batch_size: usize, ) -> impl Future>> + Send; /// Get the root digest of the database for verification fn root(&self) -> Self::Digest; }