mod wire_msg;
mod wire_msg_header;
use xor_name::XorName;
use crate::types::PublicKey;
pub use self::wire_msg::WireMsg;
use super::{
data::ServiceMsg, system::SystemMsg, AuthorityProof, BlsShareAuth, DstLocation, MessageId,
NodeAuth, SectionAuth, ServiceAuth,
};
#[derive(PartialEq, Debug, Clone)]
#[allow(clippy::large_enum_variant)]
pub enum MessageType {
Service {
msg_id: MessageId,
auth: AuthorityProof<ServiceAuth>,
dst_location: DstLocation,
msg: ServiceMsg,
},
System {
msg_id: MessageId,
msg_authority: NodeMsgAuthority,
dst_location: DstLocation,
msg: SystemMsg,
},
}
#[derive(PartialEq, Debug, Clone)]
pub enum NodeMsgAuthority {
Node(AuthorityProof<NodeAuth>),
BlsShare(AuthorityProof<BlsShareAuth>),
Section(AuthorityProof<SectionAuth>),
}
impl NodeMsgAuthority {
pub(crate) fn get_auth_xorname(&self) -> XorName {
match self.clone() {
NodeMsgAuthority::BlsShare(auth_proof) => {
let auth = auth_proof.into_inner();
auth.src_name
}
NodeMsgAuthority::Node(auth_proof) => {
let auth = auth_proof.into_inner();
let pk = auth.public_key;
XorName::from(PublicKey::from(pk))
}
NodeMsgAuthority::Section(auth_proof) => {
let auth = auth_proof.into_inner();
auth.src_name
}
}
}
}