use commonware_utils::Array; use prometheus_client::encoding::{EncodeLabelSet, EncodeLabelValue}; #[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelValue)] pub enum MessageType { Notarize, Notarization, Nullify, Nullification, Finalize, Finalization, } #[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelSet)] pub struct Outbound { pub message: MessageType, } impl Outbound { pub fn notarize() -> &'static Self { &Self { message: MessageType::Notarize, } } pub fn notarization() -> &'static Self { &Self { message: MessageType::Notarization, } } pub fn nullify() -> &'static Self { &Self { message: MessageType::Nullify, } } pub fn nullification() -> &'static Self { &Self { message: MessageType::Nullification, } } pub fn finalize() -> &'static Self { &Self { message: MessageType::Finalize, } } pub fn finalization() -> &'static Self { &Self { message: MessageType::Finalization, } } } #[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelSet)] pub struct Inbound { pub peer: String, pub message: MessageType, } impl Inbound { pub fn notarize(peer: &impl Array) -> Self { Self { peer: peer.to_string(), message: MessageType::Notarize, } } pub fn notarization(peer: &impl Array) -> Self { Self { peer: peer.to_string(), message: MessageType::Notarization, } } pub fn nullify(peer: &impl Array) -> Self { Self { peer: peer.to_string(), message: MessageType::Nullify, } } pub fn nullification(peer: &impl Array) -> Self { Self { peer: peer.to_string(), message: MessageType::Nullification, } } pub fn finalize(peer: &impl Array) -> Self { Self { peer: peer.to_string(), message: MessageType::Finalize, } } pub fn finalization(peer: &impl Array) -> Self { Self { peer: peer.to_string(), message: MessageType::Finalization, } } }