Skip to main content

tempo_commonware_node/feed/
ingress.rs

1//! Mailbox for sending consensus activity to the feed actor.
2
3use commonware_consensus::{
4    Reporter,
5    simplex::{scheme::bls12381_threshold::vrf::Scheme, types::Activity},
6};
7use commonware_cryptography::{bls12381::primitives::variant::MinSig, ed25519::PublicKey};
8use futures::channel::mpsc;
9use tracing::error;
10
11use super::actor::FeedActivity;
12use crate::consensus::Digest;
13
14/// Sender half of the feed channel.
15pub(super) type Sender = mpsc::UnboundedSender<FeedActivity>;
16
17/// Mailbox for sending consensus activity to the feed actor.
18#[derive(Clone, Debug)]
19pub(crate) struct Mailbox {
20    sender: Sender,
21}
22
23impl Mailbox {
24    pub(super) fn new(sender: Sender) -> Self {
25        Self { sender }
26    }
27}
28
29impl Reporter for Mailbox {
30    type Activity = Activity<Scheme<PublicKey, MinSig>, Digest>;
31
32    async fn report(&mut self, activity: Self::Activity) {
33        if self.sender.unbounded_send(activity).is_err() {
34            error!("failed sending activity to feed because it is no longer running");
35        }
36    }
37}