1use crate::*;
2use std::collections::HashSet;
3use std::fmt::Debug;
4
5#[derive(Debug, Clone, PartialEq, PartialOrd, Ord, Eq)]
6pub enum ValidationLevel {
7 Invalid = 0, MaybeValid = 1, FullyValid = 2, }
11
12pub trait Consensus: ConsensusNotify + Clone + Debug {
13 fn validate_ballot_value(
14 &self,
15 slot_index: thruput_scp::SCPSlotIndex,
16 value: &thruput_scp::SCPValue,
17 ) -> ValidationLevel;
18
19 fn validate_nomination_value(
20 &self,
21 slot_index: thruput_scp::SCPSlotIndex,
22 value: &thruput_scp::SCPValue,
23 ) -> ValidationLevel;
24
25 fn extract_valid_value(
26 &self,
27 slot_index: thruput_scp::SCPSlotIndex,
28 value: &thruput_scp::SCPValue,
29 ) -> Option<thruput_scp::SCPValue>;
30
31 fn combine_candidates(
32 &self,
33 slot_index: thruput_scp::SCPSlotIndex,
34 candidates: &HashSet<thruput_scp::SCPValue>,
35 ) -> Option<thruput_scp::SCPValue>;
36}
37
38pub trait ConsensusNotify {
39 fn value_externalized(
40 &self,
41 slot_index: SlotIndex,
42 value: &thruput_scp::SCPValue,
43 );
44 fn started_ballot_proto(
45 &self,
46 slot_index: SlotIndex,
47 ballot: &thruput_scp::SCPBallot,
48 );
49 fn accepted_ballot_prepared(
50 &self,
51 slot_index: SlotIndex,
52 ballot: &thruput_scp::SCPBallot,
53 );
54 fn confirmed_ballot_prepared(
55 &self,
56 slot_index: SlotIndex,
57 ballot: &thruput_scp::SCPBallot,
58 );
59 fn accepted_commit(
60 &self,
61 slot_index: SlotIndex,
62 ballot: &thruput_scp::SCPBallot,
63 );
64 fn ballot_did_hear_from_quorum(
65 &self,
66 slot_index: SlotIndex,
67 ballot: &thruput_scp::SCPBallot,
68 );
69 fn nominating_value(
70 &self,
71 slot_index: SlotIndex,
72 value: &thruput_scp::SCPValue,
73 );
74 fn updated_candidate_value(
75 &self,
76 slot_index: SlotIndex,
77 value: &thruput_scp::SCPValue,
78 );
79}