pub struct PeerRegistry { /* private fields */ }Expand description
Peer registry for managing known peers
Implementations§
Source§impl PeerRegistry
impl PeerRegistry
Sourcepub fn new(config: PeerConfig, local_peer_id: String) -> PeerRegistry
pub fn new(config: PeerConfig, local_peer_id: String) -> PeerRegistry
Create a new peer registry from config
Sourcepub fn get_active_peers(&self) -> Vec<PeerEndpoint>
pub fn get_active_peers(&self) -> Vec<PeerEndpoint>
Get all active peers
Sourcepub fn get_gossip_peers(&self, count: usize) -> Vec<PeerEndpoint>
pub fn get_gossip_peers(&self, count: usize) -> Vec<PeerEndpoint>
Get a random sample of peers for gossip
Sourcepub fn update_peer_status(&self, peer_id: &str, is_alive: bool)
pub fn update_peer_status(&self, peer_id: &str, is_alive: bool)
Update peer status based on heartbeat
Sourcepub fn add_peer(&self, endpoint: PeerEndpoint)
pub fn add_peer(&self, endpoint: PeerEndpoint)
Add a new peer discovered via gossip
Sourcepub fn remove_peer(&self, peer_id: &str)
pub fn remove_peer(&self, peer_id: &str)
Remove a peer
Sourcepub fn local_peer_id(&self) -> &str
pub fn local_peer_id(&self) -> &str
Get local peer ID
Sourcepub fn config(&self) -> &PeerConfig
pub fn config(&self) -> &PeerConfig
Get config
Trait Implementations§
Source§impl Clone for PeerRegistry
impl Clone for PeerRegistry
Source§fn clone(&self) -> PeerRegistry
fn clone(&self) -> PeerRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PeerRegistry
impl RefUnwindSafe for PeerRegistry
impl Send for PeerRegistry
impl Sync for PeerRegistry
impl Unpin for PeerRegistry
impl UnsafeUnpin for PeerRegistry
impl UnwindSafe for PeerRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more