Skip to main content

tempo_commonware_node/feed/
mod.rs

1//! Feed module for consensus event tracking and RPC.
2//!
3//! Architecture:
4//! - `Mailbox` implements `Reporter` and sends Activity to the actor
5//! - `Actor` processes Activity and updates shared [`FeedStateHandle`]
6//! - [`FeedStateHandle`] implements `ConsensusFeed` for RPC access
7//!
8//! This design ensures RPC traffic cannot block consensus activity processing.
9
10mod actor;
11mod ingress;
12mod state;
13
14use commonware_consensus::types::FixedEpocher;
15use commonware_runtime::Spawner;
16use futures::channel::mpsc;
17use tempo_node::TempoFullNode;
18
19use crate::alias::marshal;
20pub(crate) use actor::Actor;
21pub(crate) use ingress::Mailbox;
22pub use state::FeedStateHandle;
23
24/// Initialize the feed actor and mailbox.
25pub(crate) fn init<TContext: Spawner>(
26    context: TContext,
27    marshal: marshal::Mailbox,
28    epocher: FixedEpocher,
29    execution_node: TempoFullNode,
30    state: FeedStateHandle,
31) -> (Actor<TContext>, Mailbox) {
32    let (tx, rx) = mpsc::unbounded();
33    let mailbox = Mailbox::new(tx);
34    let actor = Actor::new(context, marshal, epocher, execution_node, rx, state);
35    (actor, mailbox)
36}