use crate::{
marshal::{application::gates::Gates, core::Mailbox, standard::Standard},
simplex::Plan,
Block,
};
use commonware_actor::Feedback;
use commonware_cryptography::certificate::Scheme;
use commonware_p2p::Recipients;
use tracing::debug;
pub(super) fn broadcast<S, B>(
gates: &Gates<B::Digest, B>,
marshal: &Mailbox<S, Standard<B>>,
commitment: B::Digest,
plan: Plan<S::PublicKey>,
) -> Feedback
where
S: Scheme,
B: Block,
{
match plan {
Plan::Propose { round } => {
let Some((block, ack)) = gates.take_staged(round, commitment) else {
debug!(%round, %commitment, "no staged proposal to relay, attempting forwarding");
return marshal.forward(round, commitment, Recipients::All);
};
marshal.proposed(round, block, Recipients::All, ack)
}
Plan::Forward { round, recipients } => marshal.forward(round, commitment, recipients),
}
}