pub use super::db::KeyValueProof;
use crate::{
index::unordered::Index,
journal::contiguous::fixed::Journal,
merkle::{Graftable, Location},
qmdb::{
any::{unordered::fixed::Operation, value::FixedEncoding, FixedValue},
current::FixedConfig as Config,
Error,
},
translator::Translator,
Context,
};
use commonware_cryptography::Hasher;
use commonware_utils::Array;
pub type Db<F, E, K, V, H, T, const N: usize> = super::db::Db<
F,
E,
Journal<E, Operation<F, K, V>>,
K,
FixedEncoding<V>,
Index<T, Location<F>>,
H,
N,
>;
impl<
F: Graftable,
E: Context,
K: Array,
V: FixedValue,
H: Hasher,
T: Translator,
const N: usize,
> Db<F, E, K, V, H, T, N>
{
pub async fn init(context: E, config: Config<T>) -> Result<Self, Error<F>> {
crate::qmdb::current::init(context, config).await
}
}
pub mod partitioned {
use super::*;
use crate::index::partitioned::unordered::Index;
pub type Db<F, E, K, V, H, T, const P: usize, const N: usize> =
crate::qmdb::current::unordered::db::Db<
F,
E,
Journal<E, Operation<F, K, V>>,
K,
FixedEncoding<V>,
Index<T, Location<F>, P>,
H,
N,
>;
impl<
F: Graftable,
E: Context,
K: Array,
V: FixedValue,
H: Hasher,
T: Translator,
const P: usize,
const N: usize,
> Db<F, E, K, V, H, T, P, N>
{
pub async fn init(context: E, config: Config<T>) -> Result<Self, Error<F>> {
crate::qmdb::current::init(context, config).await
}
}
}
#[cfg(test)]
pub mod test {
use super::*;
use crate::{
mmr,
qmdb::current::{tests::fixed_config, unordered::tests as shared},
translator::TwoCap,
};
use commonware_cryptography::{sha256::Digest, Sha256};
use commonware_macros::test_traced;
use commonware_runtime::deterministic;
type CurrentTest = Db<mmr::Family, deterministic::Context, Digest, Digest, Sha256, TwoCap, 32>;
async fn open_db(context: deterministic::Context, partition_prefix: String) -> CurrentTest {
let cfg = fixed_config::<TwoCap>(&partition_prefix, &context);
CurrentTest::init(context, cfg).await.unwrap()
}
#[test_traced("DEBUG")]
pub fn test_current_db_verify_proof_over_bits_in_uncommitted_chunk() {
shared::test_verify_proof_over_bits_in_uncommitted_chunk(open_db);
}
#[test_traced("DEBUG")]
pub fn test_current_db_range_proofs() {
shared::test_range_proofs(open_db);
}
#[test_traced("DEBUG")]
pub fn test_current_db_key_value_proof() {
shared::test_key_value_proof(open_db);
}
#[test_traced("WARN")]
pub fn test_current_db_proving_repeated_updates() {
shared::test_proving_repeated_updates(open_db);
}
}