Skip to main content

tempo_commonware_node/epoch/manager/
mod.rs

1mod actor;
2pub(super) mod ingress;
3
4use std::time::Duration;
5
6pub(crate) use actor::Actor;
7use commonware_cryptography::ed25519::PublicKey;
8pub(crate) use ingress::Mailbox;
9
10use commonware_consensus::types::{FixedEpocher, ViewDelta};
11use commonware_p2p::Blocker;
12use commonware_runtime::{
13    BufferPooler, Clock, Metrics, Network, Spawner, Storage, buffer::paged::CacheRef,
14};
15use rand_08::{CryptoRng, Rng};
16
17use crate::{epoch::scheme_provider::SchemeProvider, feed, subblocks};
18
19pub(crate) struct Config<TBlocker> {
20    pub(crate) application: crate::consensus::application::Mailbox,
21    pub(crate) blocker: TBlocker,
22    pub(crate) page_cache: CacheRef,
23    pub(crate) epoch_strategy: FixedEpocher,
24    pub(crate) time_for_peer_response: Duration,
25    pub(crate) time_to_propose: Duration,
26    pub(crate) mailbox_size: usize,
27    pub(crate) subblocks: Option<subblocks::Mailbox>,
28    pub(crate) marshal: crate::alias::marshal::Mailbox,
29    pub(crate) feed: feed::Mailbox,
30    pub(crate) scheme_provider: SchemeProvider,
31    pub(crate) time_to_collect_notarizations: Duration,
32    pub(crate) time_to_retry_nullify_broadcast: Duration,
33    pub(crate) partition_prefix: String,
34    pub(crate) views_to_track: ViewDelta,
35    pub(crate) views_until_leader_skip: ViewDelta,
36}
37
38pub(crate) fn init<TContext, TBlocker>(
39    context: TContext,
40    config: Config<TBlocker>,
41) -> (Actor<TContext, TBlocker>, Mailbox)
42where
43    TBlocker: Blocker<PublicKey = PublicKey>,
44    TContext: BufferPooler
45        + Spawner
46        + Metrics
47        + Rng
48        + CryptoRng
49        + Clock
50        + governor::clock::Clock
51        + Storage
52        + Network,
53{
54    let (tx, rx) = futures::channel::mpsc::unbounded();
55    let actor = Actor::new(config, context, rx);
56    let mailbox = Mailbox::new(tx);
57    (actor, mailbox)
58}