use crate::{
simplex::types::Finalization,
types::{Epoch, Epocher, ViewDelta},
Block,
};
use commonware_cryptography::{
certificate::{Provider, Scheme},
Digest, Digestible,
};
use commonware_parallel::Strategy;
use commonware_runtime::buffer::paged::CacheRef;
use std::num::{NonZeroU64, NonZeroUsize};
pub enum Start<S: Scheme, C: Digest, B> {
Genesis(B),
Floor(Finalization<S, C>),
}
pub struct Config<P, ES, T, AB, B, C = <AB as Digestible>::Digest>
where
AB: Block,
C: Digest,
P: Provider<Scope = Epoch>,
ES: Epocher,
T: Strategy,
{
pub provider: P,
pub epocher: ES,
pub start: Start<P::Scheme, C, B>,
pub partition_prefix: String,
pub mailbox_size: NonZeroUsize,
pub view_retention_timeout: ViewDelta,
pub prunable_items_per_section: NonZeroU64,
pub page_cache: CacheRef,
pub replay_buffer: NonZeroUsize,
pub key_write_buffer: NonZeroUsize,
pub value_write_buffer: NonZeroUsize,
pub block_codec_config: AB::Cfg,
pub max_repair: NonZeroUsize,
pub max_pending_acks: NonZeroUsize,
pub strategy: T,
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{
marshal::{coding::types::CodedBlock, mocks::block::Block as MockBlock},
simplex::{scheme::ed25519, types::Context},
types::{coding::Commitment, FixedEpocher},
};
use commonware_coding::ReedSolomon;
use commonware_cryptography::{
certificate::ConstantProvider,
ed25519::PublicKey,
sha256::{Digest as Sha256Digest, Sha256},
};
use commonware_parallel::Sequential;
#[test]
fn config_compiles_with_distinct_application_and_start_blocks() {
type AB = MockBlock<Sha256Digest, Context<Commitment, PublicKey>>;
type B = CodedBlock<AB, ReedSolomon<Sha256>, Sha256>;
type Provider = ConstantProvider<ed25519::Scheme, Epoch>;
fn assert_well_formed<T>() {}
assert_well_formed::<Config<Provider, FixedEpocher, Sequential, AB, B, Commitment>>();
}
}