commonware_consensus/threshold_simplex/
config.rs1use super::{Context, View};
2use crate::{Automaton, Committer, Relay, ThresholdSupervisor};
3use commonware_cryptography::{bls12381::primitives::group, Scheme};
4use commonware_utils::Array;
5use governor::Quota;
6use std::time::Duration;
7
8pub struct Config<
10 C: Scheme,
11 D: Array,
12 A: Automaton<Context = Context<D>>,
13 R: Relay,
14 F: Committer,
15 S: ThresholdSupervisor<Seed = group::Signature, Index = View, Share = group::Share>,
16> {
17 pub crypto: C,
19
20 pub automaton: A,
22
23 pub relay: R,
25
26 pub committer: F,
28
29 pub supervisor: S,
31
32 pub mailbox_size: usize,
35
36 pub namespace: Vec<u8>,
38
39 pub replay_concurrency: usize,
41
42 pub leader_timeout: Duration,
45
46 pub notarization_timeout: Duration,
49
50 pub nullify_retry: Duration,
53
54 pub activity_timeout: View,
57
58 pub fetch_timeout: Duration,
60
61 pub max_fetch_count: usize,
63
64 pub max_fetch_size: usize,
66
67 pub fetch_rate_per_peer: Quota,
71
72 pub fetch_concurrent: usize,
74}
75
76impl<
77 C: Scheme,
78 D: Array,
79 A: Automaton<Context = Context<D>>,
80 R: Relay,
81 F: Committer,
82 S: ThresholdSupervisor<Seed = group::Signature, Index = View, Share = group::Share>,
83 > Config<C, D, A, R, F, S>
84{
85 pub fn assert(&self) {
87 assert!(
88 self.leader_timeout > Duration::default(),
89 "leader timeout must be greater than zero"
90 );
91 assert!(
92 self.notarization_timeout > Duration::default(),
93 "notarization timeout must be greater than zero"
94 );
95 assert!(
96 self.leader_timeout <= self.notarization_timeout,
97 "leader timeout must be less than or equal to notarization timeout"
98 );
99 assert!(
100 self.nullify_retry > Duration::default(),
101 "nullify retry broadcast must be greater than zero"
102 );
103 assert!(
104 self.activity_timeout > 0,
105 "activity timeout must be greater than zero"
106 );
107 assert!(
108 self.fetch_timeout > Duration::default(),
109 "fetch timeout must be greater than zero"
110 );
111 assert!(
112 self.max_fetch_count > 0,
113 "it must be possible to fetch at least one container per request"
114 );
115 assert!(
116 self.max_fetch_size > 0,
117 "it must be possible to fetch at least one byte"
118 );
119 assert!(
120 self.fetch_concurrent > 0,
121 "it must be possible to fetch from at least one peer at a time"
122 );
123 assert!(
124 self.replay_concurrency > 0,
125 "it must be possible to replay at least one view at a time"
126 );
127 }
128}