use alloc::vec::Vec;
use codec::{Decode, Encode};
use scale_info::TypeInfo;
mod app {
use sp_application_crypto::{app_crypto, key_types::MIXNET, sr25519};
app_crypto!(sr25519, MIXNET);
}
pub type AuthorityId = app::Public;
pub type AuthoritySignature = app::Signature;
pub type SessionIndex = u32;
#[derive(Decode, Encode, TypeInfo, PartialEq, Eq)]
pub enum SessionPhase {
CoverToCurrent,
RequestsToCurrent,
CoverToPrev,
DisconnectFromPrev,
}
#[derive(Decode, Encode, TypeInfo)]
pub struct SessionStatus {
pub current_index: SessionIndex,
pub phase: SessionPhase,
}
pub const KX_PUBLIC_SIZE: usize = 32;
pub type KxPublic = [u8; KX_PUBLIC_SIZE];
pub type PeerId = [u8; 32];
#[derive(Decode, Encode, TypeInfo)]
pub struct Mixnode {
pub kx_public: KxPublic,
pub peer_id: PeerId,
pub external_addresses: Vec<Vec<u8>>,
}
#[derive(Decode, Encode, TypeInfo)]
pub enum MixnodesErr {
InsufficientRegistrations {
num: u32,
min: u32,
},
}
impl core::fmt::Display for MixnodesErr {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
MixnodesErr::InsufficientRegistrations { num, min } =>
write!(fmt, "{num} mixnode(s) registered; {min} is the minimum"),
}
}
}