fedimint_hbbft/sender_queue/
honey_badger.rs1use std::collections::BTreeSet;
2
3use serde::{de::DeserializeOwned, Serialize};
4
5use super::{SenderQueueableConsensusProtocol, SenderQueueableMessage, SenderQueueableOutput};
6use crate::honey_badger::{Batch, HoneyBadger, Message};
7use crate::{Contribution, Epoched, NodeIdT};
8
9impl<C, N> SenderQueueableOutput<N, u64> for Batch<C, N>
10where
11 C: Contribution,
12 N: NodeIdT,
13{
14 fn participant_change(&self) -> Option<BTreeSet<N>> {
15 None
16 }
17
18 fn output_epoch(&self) -> u64 {
19 self.epoch
20 }
21}
22
23impl<N> SenderQueueableMessage for Message<N> {
24 type Epoch = u64;
25
26 fn is_premature(&self, them: u64, max_future_epochs: u64) -> bool {
27 self.epoch() > them + max_future_epochs
28 }
29
30 fn is_obsolete(&self, them: u64) -> bool {
31 self.epoch() < them
32 }
33
34 fn first_epoch(&self) -> u64 {
35 self.epoch()
36 }
37}
38
39impl<C, N> Epoched for HoneyBadger<C, N>
40where
41 C: Contribution + Serialize + DeserializeOwned,
42 N: NodeIdT,
43{
44 type Epoch = u64;
45
46 fn epoch(&self) -> u64 {
47 self.next_epoch()
48 }
49}
50
51impl<C, N> SenderQueueableConsensusProtocol for HoneyBadger<C, N>
52where
53 C: Contribution + Serialize + DeserializeOwned,
54 N: NodeIdT,
55{
56 fn max_future_epochs(&self) -> u64 {
57 self.max_future_epochs()
58 }
59}