//! Inbound communication channel for epoch transitions. use commonware_consensus::types::Epoch; use commonware_cryptography::{ bls12381::primitives::{group, sharing::Sharing, variant::Variant}, PublicKey, }; use commonware_utils::ordered::Set; use futures::{channel::mpsc, SinkExt}; use tracing::error; /// Messages that can be sent to the orchestrator. pub enum Message { Enter(EpochTransition), Exit(Epoch), } /// A notification of an epoch transition. pub struct EpochTransition { /// The epoch to transition to. pub epoch: Epoch, /// The public polynomial for the epoch. pub poly: Option>, /// The share for the local participant for the epoch, if participating. pub share: Option, /// The dealers for the epoch. pub dealers: Set

, } /// Inbound communication channel for epoch transitions. #[derive(Debug, Clone)] pub struct Mailbox { sender: mpsc::Sender>, } impl Mailbox { /// Create a new [Mailbox]. pub const fn new(sender: mpsc::Sender>) -> Self { Self { sender } } pub async fn enter(&mut self, transition: EpochTransition) { if let Err(err) = self.sender.send(Message::Enter(transition)).await { error!(?err, "failed to send epoch transition"); } } pub async fn exit(&mut self, epoch: Epoch) { if let Err(err) = self.sender.send(Message::Exit(epoch)).await { error!(?err, "failed to send epoch exit"); } } }