//! Test trait implementations for the unordered Current QMDB. use super::{fixed, variable}; use crate::{ qmdb::{ any::{ traits::DbAny, unordered::variable::Operation as VariableOperation, FixedValue, VariableValue, }, current::BitmapPrunedBits, store::LogStore as _, }, translator::Translator, }; use commonware_codec::Read; use commonware_cryptography::Hasher; use commonware_runtime::{Clock, Metrics, Storage}; use commonware_utils::Array; // ============================================================================= // Fixed variant test trait implementations // ============================================================================= impl< E: Storage + Clock + Metrics, K: Array, V: FixedValue + 'static, H: Hasher, T: Translator, const N: usize, > DbAny for fixed::Db { type Digest = H::Digest; } // ============================================================================= // Variable variant test trait implementations // ============================================================================= impl< E: Storage + Clock + Metrics, K: Array, V: VariableValue + 'static, H: Hasher, T: Translator, const N: usize, > DbAny for variable::Db where VariableOperation: Read, { type Digest = H::Digest; } // ============================================================================= // BitmapPrunedBits trait implementations // ============================================================================= impl< E: Storage + Clock + Metrics, K: Array, V: FixedValue, H: Hasher, T: Translator, const N: usize, > BitmapPrunedBits for fixed::Db { fn pruned_bits(&self) -> u64 { self.status.pruned_bits() } fn get_bit(&self, index: u64) -> bool { self.status.get_bit(index) } async fn oldest_retained(&self) -> u64 { *self.any.bounds().await.start } } impl< E: Storage + Clock + Metrics, K: Array, V: VariableValue, H: Hasher, T: Translator, const N: usize, > BitmapPrunedBits for variable::Db where VariableOperation: Read, { fn pruned_bits(&self) -> u64 { self.status.pruned_bits() } fn get_bit(&self, index: u64) -> bool { self.status.get_bit(index) } async fn oldest_retained(&self) -> u64 { *self.any.bounds().await.start } } // ============================================================================= // Partitioned Fixed variant test trait implementations // ============================================================================= impl< E: Storage + Clock + Metrics, K: Array, V: FixedValue + 'static, H: Hasher, T: Translator, const P: usize, const N: usize, > DbAny for fixed::partitioned::Db { type Digest = H::Digest; } impl< E: Storage + Clock + Metrics, K: Array, V: FixedValue, H: Hasher, T: Translator, const P: usize, const N: usize, > BitmapPrunedBits for fixed::partitioned::Db { fn pruned_bits(&self) -> u64 { self.status.pruned_bits() } fn get_bit(&self, index: u64) -> bool { self.status.get_bit(index) } async fn oldest_retained(&self) -> u64 { *self.any.bounds().await.start } } // ============================================================================= // Partitioned Variable variant test trait implementations // ============================================================================= impl< E: Storage + Clock + Metrics, K: Array, V: VariableValue + 'static, H: Hasher, T: Translator, const P: usize, const N: usize, > DbAny for variable::partitioned::Db where VariableOperation: Read, { type Digest = H::Digest; } impl< E: Storage + Clock + Metrics, K: Array, V: VariableValue, H: Hasher, T: Translator, const P: usize, const N: usize, > BitmapPrunedBits for variable::partitioned::Db where VariableOperation: Read, { fn pruned_bits(&self) -> u64 { self.status.pruned_bits() } fn get_bit(&self, index: u64) -> bool { self.status.get_bit(index) } async fn oldest_retained(&self) -> u64 { *self.any.bounds().await.start } }