pub struct PeerBook { /* private fields */ }Expand description
Persistent address book of known peers.
Implementations§
Source§impl PeerBook
impl PeerBook
pub fn new(path: impl AsRef<Path>) -> Self
pub fn load(path: impl AsRef<Path>) -> Result<Self>
pub fn save(&self) -> Result<()>
pub fn add_peer(&mut self, info: PeerInfo)
pub fn remove_peer(&mut self, peer_id: &str)
pub fn get(&self, peer_id: &str) -> Option<&PeerInfo>
pub fn get_mut(&mut self, peer_id: &str) -> Option<&mut PeerInfo>
pub fn get_peers_by_role(&self, role: PeerRole) -> Vec<&PeerInfo>
pub fn get_random_peers(&self, n: usize) -> Vec<&PeerInfo>
pub fn adjust_score(&mut self, peer_id: &str, delta: i32)
pub fn prune_stale(&mut self, max_age_secs: u64)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn all_peers(&self) -> impl Iterator<Item = &PeerInfo>
Auto Trait Implementations§
impl Freeze for PeerBook
impl RefUnwindSafe for PeerBook
impl Send for PeerBook
impl Sync for PeerBook
impl Unpin for PeerBook
impl UnsafeUnpin for PeerBook
impl UnwindSafe for PeerBook
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