use sn_interface::messaging::{
data::ServiceMsg,
system::{NodeCmd, NodeQuery, NodeQueryResponse},
AuthorityProof, DstLocation, EndUser, MsgId, ServiceAuth, SrcLocation,
};
use bls::PublicKey as BlsPublicKey;
use ed25519_dalek::Keypair;
use std::{collections::BTreeSet, sync::Arc};
use xor_name::{Prefix, XorName};
#[derive(Debug)]
pub enum NodeElderChange {
Promoted,
Demoted,
None,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Elders {
pub prefix: Prefix,
pub key: BlsPublicKey,
pub remaining: BTreeSet<XorName>,
pub added: BTreeSet<XorName>,
pub removed: BTreeSet<XorName>,
}
#[allow(clippy::large_enum_variant)]
#[derive(custom_debug::Debug)]
pub enum Event {
MessageReceived {
msg_id: MsgId,
src: SrcLocation,
dst: DstLocation,
msg: Box<MessageReceived>,
},
MemberJoined {
name: XorName,
previous_name: Option<XorName>,
age: u8,
},
MemberLeft {
name: XorName,
age: u8,
},
SectionSplit {
elders: Elders,
self_status_change: NodeElderChange,
},
EldersChanged {
elders: Elders,
self_status_change: NodeElderChange,
},
RelocationStarted {
previous_name: XorName,
},
Relocated {
previous_name: XorName,
#[debug(skip)]
new_keypair: Arc<Keypair>,
},
ServiceMsgReceived {
msg_id: MsgId,
msg: Box<ServiceMsg>,
auth: AuthorityProof<ServiceAuth>,
user: EndUser,
dst_location: DstLocation,
},
AdultsChanged {
remaining: BTreeSet<XorName>,
added: BTreeSet<XorName>,
removed: BTreeSet<XorName>,
},
}
#[derive(Debug, Clone)]
#[allow(clippy::large_enum_variant)]
pub enum MessageReceived {
NodeCmd(NodeCmd),
NodeQuery(NodeQuery),
NodeQueryResponse {
response: NodeQueryResponse,
correlation_id: MsgId,
},
}