pub struct NetworkNode { /* private fields */ }Expand description
IPFRS network node
Implementations§
Source§impl NetworkNode
impl NetworkNode
Sourcepub fn new(config: NetworkConfig) -> Result<Self>
pub fn new(config: NetworkConfig) -> Result<Self>
Create a new network node
Sourcepub fn connected_peers(&self) -> Vec<PeerId>
pub fn connected_peers(&self) -> Vec<PeerId>
Get connected peers
Sourcepub async fn disconnect(&mut self, peer_id: PeerId) -> Result<()>
pub async fn disconnect(&mut self, peer_id: PeerId) -> Result<()>
Disconnect from a peer
Sourcepub async fn find_providers(&mut self, cid: &Cid) -> Result<()>
pub async fn find_providers(&mut self, cid: &Cid) -> Result<()>
Find providers for content in DHT
Sourcepub async fn find_node(&mut self, peer_id: PeerId) -> Result<()>
pub async fn find_node(&mut self, peer_id: PeerId) -> Result<()>
Find node (closest peers to a given peer ID) using Kademlia
Sourcepub async fn get_closest_local_peers(&mut self) -> Result<Vec<PeerId>>
pub async fn get_closest_local_peers(&mut self) -> Result<Vec<PeerId>>
Get the k-closest peers to our local peer ID
Sourcepub async fn bootstrap_dht(&mut self) -> Result<()>
pub async fn bootstrap_dht(&mut self) -> Result<()>
Bootstrap the DHT (search for our own peer ID to populate routing table)
Sourcepub fn add_peer_address(
&mut self,
peer_id: PeerId,
addr: Multiaddr,
) -> Result<()>
pub fn add_peer_address( &mut self, peer_id: PeerId, addr: Multiaddr, ) -> Result<()>
Add an address for a peer to the routing table
Sourcepub fn get_routing_table_info(&mut self) -> Result<RoutingTableInfo>
pub fn get_routing_table_info(&mut self) -> Result<RoutingTableInfo>
Get routing table information
Sourcepub fn stats(&self) -> NetworkStats
pub fn stats(&self) -> NetworkStats
Get network statistics
Sourcepub fn take_event_receiver(&mut self) -> Option<Receiver<NetworkEvent>>
pub fn take_event_receiver(&mut self) -> Option<Receiver<NetworkEvent>>
Take the event receiver
Sourcepub fn get_external_addresses(&self) -> Vec<Multiaddr>
pub fn get_external_addresses(&self) -> Vec<Multiaddr>
Get confirmed external addresses
Sourcepub fn is_publicly_reachable(&self) -> bool
pub fn is_publicly_reachable(&self) -> bool
Check if node has public reachability
Sourcepub fn is_connected_to(&self, peer_id: &PeerId) -> bool
pub fn is_connected_to(&self, peer_id: &PeerId) -> bool
Check if connected to a specific peer
Sourcepub fn get_peer_count(&self) -> usize
pub fn get_peer_count(&self) -> usize
Get number of connected peers
Sourcepub async fn connect_to_peers(
&mut self,
addrs: Vec<Multiaddr>,
) -> Vec<Result<()>> ⓘ
pub async fn connect_to_peers( &mut self, addrs: Vec<Multiaddr>, ) -> Vec<Result<()>> ⓘ
Connect to multiple peers in batch
Sourcepub async fn disconnect_all(&mut self) -> Result<()>
pub async fn disconnect_all(&mut self) -> Result<()>
Disconnect from all connected peers
Sourcepub fn update_bandwidth(&self, bytes_sent: u64, bytes_received: u64)
pub fn update_bandwidth(&self, bytes_sent: u64, bytes_received: u64)
Update bandwidth statistics manually (for custom tracking)
Sourcepub fn get_bytes_sent(&self) -> u64
pub fn get_bytes_sent(&self) -> u64
Get total bandwidth sent
Sourcepub fn get_bytes_received(&self) -> u64
pub fn get_bytes_received(&self) -> u64
Get total bandwidth received
Sourcepub fn reset_bandwidth_stats(&self)
pub fn reset_bandwidth_stats(&self)
Reset bandwidth statistics
Sourcepub fn get_network_health(&self) -> NetworkHealthSummary
pub fn get_network_health(&self) -> NetworkHealthSummary
Get network health summary
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Check if node is healthy
Auto Trait Implementations§
impl !Freeze for NetworkNode
impl !RefUnwindSafe for NetworkNode
impl Send for NetworkNode
impl !Sync for NetworkNode
impl Unpin for NetworkNode
impl !UnwindSafe for NetworkNode
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> 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
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>
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>
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