use bytes::Bytes;
use tetsy_libp2p::core::PeerId;
use tetsy_libp2p::kad::record::Key;
use std::borrow::Cow;
#[derive(Debug, Clone)]
#[must_use]
pub enum DhtEvent {
ValueFound(Vec<(Key, Vec<u8>)>),
ValueNotFound(Key),
ValuePut(Key),
ValuePutFailed(Key),
}
#[derive(Debug, Clone)]
#[must_use]
pub enum Event {
Dht(DhtEvent),
SyncConnected {
remote: PeerId,
},
SyncDisconnected {
remote: PeerId,
},
NotificationStreamOpened {
remote: PeerId,
protocol: Cow<'static, str>,
role: ObservedRole,
},
NotificationStreamClosed {
remote: PeerId,
protocol: Cow<'static, str>,
},
NotificationsReceived {
remote: PeerId,
messages: Vec<(Cow<'static, str>, Bytes)>,
},
}
#[derive(Debug, Clone)]
pub enum ObservedRole {
Full,
Light,
OurSentry,
OurGuardedAuthority,
Authority,
}
impl ObservedRole {
pub fn is_light(&self) -> bool {
matches!(self, ObservedRole::Light)
}
}