use std::net::SocketAddr;
use uuid::Uuid;
use crate::Router;
#[derive(Debug)]
pub struct Peer {
identity: Uuid,
net_address: SocketAddr,
is_outbound: bool,
}
impl Peer {
pub fn new(identity: Uuid, net_address: SocketAddr, is_outbound: bool) -> Self {
Self { identity, net_address, is_outbound }
}
pub fn identity(&self) -> Uuid {
self.identity
}
pub fn net_address(&self) -> SocketAddr {
self.net_address
}
pub fn is_outbound(&self) -> bool {
self.is_outbound
}
}
impl From<&Router> for Peer {
fn from(router: &Router) -> Self {
Self::new(router.identity(), router.net_address(), router.is_outbound())
}
}