use super::tracker::FinalizationUpdate;
use commonware_cryptography::PublicKey;
use commonware_p2p::simulated::{self, Oracle};
use commonware_runtime::{deterministic, Handle, Quota};
use commonware_utils::channel::mpsc;
use std::future::Future;
pub type ChannelPair<P> = (
simulated::Sender<P, deterministic::Context>,
simulated::Receiver<P>,
);
pub struct InitContext<'a, P: PublicKey> {
pub context: deterministic::Context,
pub index: usize,
pub public_key: &'a P,
pub oracle: &'a Oracle<P, deterministic::Context>,
pub channels: Vec<ChannelPair<P>>,
pub participants: &'a [P],
pub monitor: mpsc::Sender<FinalizationUpdate<P>>,
}
pub trait EngineDefinition: Clone + Send + 'static {
type PublicKey: PublicKey;
type Engine: Send + 'static;
type State: Send + Sync + 'static;
fn participants(&self) -> Vec<Self::PublicKey>;
fn channels(&self) -> Vec<(u64, Quota)>;
fn init(
&self,
ctx: InitContext<'_, Self::PublicKey>,
) -> impl Future<Output = (Self::Engine, Self::State)> + Send;
fn start(engine: Self::Engine) -> Handle<()>;
}