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