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 std::sync::Arc;
15
16use commonware_consensus::types::FixedEpocher;
17use commonware_runtime::Spawner;
18use futures::channel::mpsc;
19use tempo_node::TempoFullNode;
20
21use crate::alias::marshal;
22pub(crate) use actor::Actor;
23pub(crate) use ingress::Mailbox;
24pub use state::FeedStateHandle;
25
26/// Initialize the feed actor and mailbox.
27pub(crate) fn init<TContext: Spawner>(
28    context: TContext,
29    marshal: marshal::Mailbox,
30    epocher: FixedEpocher,
31    execution_node: Arc<TempoFullNode>,
32    state: FeedStateHandle,
33) -> (Actor<TContext>, Mailbox) {
34    let (tx, rx) = mpsc::unbounded();
35    let mailbox = Mailbox::new(tx);
36    let actor = Actor::new(context, marshal, epocher, execution_node, rx, state);
37    (actor, mailbox)
38}