pub struct PeerManager { /* private fields */ }Expand description
Peer manager for handling peer operations
Implementations§
Source§impl PeerManager
impl PeerManager
Sourcepub async fn new(config: PeerManagerConfig) -> Result<Self>
pub async fn new(config: PeerManagerConfig) -> Result<Self>
Create a new peer manager
Sourcepub async fn save_peers(&self) -> Result<()>
pub async fn save_peers(&self) -> Result<()>
Save peers to disk
Sourcepub async fn auto_save_if_needed(&self) -> Result<()>
pub async fn auto_save_if_needed(&self) -> Result<()>
Auto-save if needed
Sourcepub async fn add_peer(
&self,
address: String,
nickname: Option<String>,
) -> Result<String>
pub async fn add_peer( &self, address: String, nickname: Option<String>, ) -> Result<String>
Add a new peer
Sourcepub async fn remove_peer(&self, peer_id: String) -> Result<()>
pub async fn remove_peer(&self, peer_id: String) -> Result<()>
Remove a peer
Sourcepub async fn list_peers(&self) -> Result<Vec<PeerInfo>>
pub async fn list_peers(&self) -> Result<Vec<PeerInfo>>
List all peers
Sourcepub async fn get_peer_info(&self, peer_id: String) -> Result<PeerInfo>
pub async fn get_peer_info(&self, peer_id: String) -> Result<PeerInfo>
Get detailed information about a specific peer
Sourcepub async fn update_peer_metadata(
&self,
peer_id: String,
nickname: Option<String>,
trust_level: Option<u8>,
tags: Option<Vec<String>>,
) -> Result<()>
pub async fn update_peer_metadata( &self, peer_id: String, nickname: Option<String>, trust_level: Option<u8>, tags: Option<Vec<String>>, ) -> Result<()>
Update peer metadata
Sourcepub async fn unban_peer(&self, address: String) -> Result<()>
pub async fn unban_peer(&self, address: String) -> Result<()>
Unban a peer by address
Sourcepub async fn import_peers(&self, path: PathBuf, merge: bool) -> Result<usize>
pub async fn import_peers(&self, path: PathBuf, merge: bool) -> Result<usize>
Import peers from JSON file
Sourcepub async fn export_peers(
&self,
path: PathBuf,
filter_tags: Option<Vec<String>>,
) -> Result<usize>
pub async fn export_peers( &self, path: PathBuf, filter_tags: Option<Vec<String>>, ) -> Result<usize>
Export peers to JSON file
Sourcepub async fn test_all_peers(
&self,
progress_callback: impl Fn(usize, usize),
) -> Result<Vec<(String, bool, Option<f64>)>>
pub async fn test_all_peers( &self, progress_callback: impl Fn(usize, usize), ) -> Result<Vec<(String, bool, Option<f64>)>>
Test connectivity to all known peers
Sourcepub async fn get_network_stats(&self) -> Result<NetworkStats>
pub async fn get_network_stats(&self) -> Result<NetworkStats>
Get network statistics
Sourcepub fn is_valid_address(address: &str) -> bool
pub fn is_valid_address(address: &str) -> bool
Validate peer address format
Auto Trait Implementations§
impl Freeze for PeerManager
impl !RefUnwindSafe for PeerManager
impl Send for PeerManager
impl Sync for PeerManager
impl Unpin for PeerManager
impl !UnwindSafe for PeerManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more