hotshot_types/new_protocol/
event.rs1use crate::{
2 data::ViewNumber,
3 event::{Event, LeafInfo},
4 message::Proposal as SignedProposal,
5 new_protocol::Proposal,
6 simple_certificate::{SimpleCertificate, SuccessThreshold},
7 simple_vote::{QuorumData2, Vote2Data},
8 traits::node_implementation::NodeType,
9};
10
11#[derive(Clone, Debug)]
14pub enum CoordinatorEvent<TYPES: NodeType> {
15 LegacyEvent(Event<TYPES>),
16 NewDecide {
17 leaf_infos: Vec<LeafInfo<TYPES>>,
18 cert1: SimpleCertificate<TYPES, QuorumData2<TYPES>, SuccessThreshold>,
21 cert2: Option<SimpleCertificate<TYPES, Vote2Data<TYPES>, SuccessThreshold>>,
23 },
24 QuorumProposal {
25 proposal: SignedProposal<TYPES, Proposal<TYPES>>,
26 sender: TYPES::SignatureKey,
27 },
28 ExternalMessageReceived {
29 sender: TYPES::SignatureKey,
30 data: Vec<u8>,
31 },
32 BlockPayloadReconstructed {
36 view: ViewNumber,
37 header: TYPES::BlockHeader,
38 payload: TYPES::BlockPayload,
39 },
40}
41
42impl<TYPES: NodeType> std::fmt::Display for CoordinatorEvent<TYPES> {
43 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44 match self {
45 Self::LegacyEvent(event) => {
46 write!(f, "Legacy: {} view={}", event.event, event.view_number)
47 },
48 Self::NewDecide { leaf_infos, .. } => {
49 let view = leaf_infos
50 .first()
51 .map(|info| *info.leaf.view_number())
52 .unwrap_or_default();
53 write!(f, "NewDecide: view={view}")
54 },
55 Self::QuorumProposal { proposal, .. } => {
56 write!(
57 f,
58 "QuorumProposal: view={} epoch={}",
59 proposal.data.view_number, proposal.data.epoch
60 )
61 },
62 Self::ExternalMessageReceived { .. } => {
63 write!(f, "ExternalMessageReceived")
64 },
65 Self::BlockPayloadReconstructed { view, .. } => {
66 write!(f, "BlockPayloadReconstructed: view={view}")
67 },
68 }
69 }
70}