commonware_broadcast/linked/config.rs
1use crate::{
2 linked::{Context, Epoch},
3 Application, Collector, ThresholdCoordinator,
4};
5use commonware_cryptography::Scheme;
6use commonware_utils::Array;
7use std::time::Duration;
8
9/// Configuration for the [`Engine`](super::Engine).
10pub struct Config<
11 C: Scheme,
12 D: Array,
13 A: Application<Context = Context<C::PublicKey>, Digest = D>,
14 Z: Collector<Digest = D>,
15 S: ThresholdCoordinator<Index = Epoch>,
16> {
17 /// The cryptographic scheme used if the engine is a sequencer.
18 pub crypto: C,
19
20 /// Manages the set of sequencers and signers.
21 /// Also manages the cryptographic partial share if the engine is a signer.
22 pub coordinator: S,
23
24 /// Verifies chunks.
25 pub application: A,
26
27 /// Notified when a chunk receives a threshold of acks.
28 pub collector: Z,
29
30 /// The maximum size of the mailbox backlog.
31 pub mailbox_size: usize,
32
33 /// The maximum number of concurrent pending requests to the application.
34 pub verify_concurrent: usize,
35
36 /// The application namespace used to sign over different types of messages.
37 /// Used to prevent replay attacks on other applications.
38 pub namespace: Vec<u8>,
39
40 /// How often the epoch is refreshed.
41 pub refresh_epoch_timeout: Duration,
42
43 /// How often the chunk is rebroadcast to all signers if no threshold is reached.
44 pub rebroadcast_timeout: Duration,
45
46 /// A tuple representing the epochs to keep in memory.
47 /// The first element is the number of old epochs to keep.
48 /// The second element is the number of future epochs to accept.
49 ///
50 /// For example, if the current epoch is 10, and the bounds are (1, 2), then
51 /// epochs 9, 10, 11, and 12 are kept (and accepted);
52 /// all others are pruned or rejected.
53 pub epoch_bounds: (u64, u64),
54
55 /// The number of future heights to accept acks for.
56 /// This is used to prevent spam of acks for arbitrary heights.
57 ///
58 /// For example, if the current tip for a sequencer is at height 100,
59 /// and the height_bound is 10, then acks for heights 100-110 are accepted.
60 pub height_bound: u64,
61
62 /// A prefix for the journal names.
63 /// The rest of the name is the hex-encoded public keys of the relevant sequencer.
64 pub journal_name_prefix: String,
65
66 /// The number of entries to keep per journal section.
67 pub journal_heights_per_section: u64,
68
69 /// Upon replaying a journal, the number of entries to replay concurrently.
70 pub journal_replay_concurrency: usize,
71}