Skip to main content

NetworkView

Trait NetworkView 

pub trait NetworkView {
    // Required methods
    fn listening_as(&self) -> HashSet<Multiaddr>;
    fn multiaddress_of(&self, peer: &PeerId) -> Option<HashSet<Multiaddr>>;
    fn discovered_peers(&self) -> HashSet<PeerId>;
    fn connected_peers(&self) -> HashSet<PeerId>;
    fn is_connected(&self, peer: &PeerId) -> bool;
    fn health(&self) -> Health;
    fn subscribe_network_events(
        &self,
    ) -> impl Stream<Item = NetworkEvent> + Send + 'static;
}
Expand description

Trait representing a read-only view of the network state.

Required Methods§

fn listening_as(&self) -> HashSet<Multiaddr>

Multiaddresses used for listening by the local node.

fn multiaddress_of(&self, peer: &PeerId) -> Option<HashSet<Multiaddr>>

Translation of the peer into its known multiaddresses.

fn discovered_peers(&self) -> HashSet<PeerId>

Peers collected by the network discovery mechanism.

fn connected_peers(&self) -> HashSet<PeerId>

Peers currently connected and tracked by the network.

fn is_connected(&self, peer: &PeerId) -> bool

Peers currently connected and tracked by the network.

fn health(&self) -> Health

Represents perceived health of the network.

fn subscribe_network_events( &self, ) -> impl Stream<Item = NetworkEvent> + Send + 'static

Subscribes to network events (peer connected/disconnected).

Each call creates a new independent subscription. Must be called before the network starts processing to avoid missing initial events.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl<'a, T> NetworkView for &'a T
where T: 'a + NetworkView + ?Sized,

§

fn listening_as(&self) -> HashSet<Multiaddr>

§

fn multiaddress_of(&self, peer: &PeerId) -> Option<HashSet<Multiaddr>>

§

fn discovered_peers(&self) -> HashSet<PeerId>

§

fn connected_peers(&self) -> HashSet<PeerId>

§

fn is_connected(&self, peer: &PeerId) -> bool

§

fn health(&self) -> Health

§

fn subscribe_network_events( &self, ) -> impl Stream<Item = NetworkEvent> + Send + 'static

§

impl<T> NetworkView for Arc<T>
where T: NetworkView + ?Sized,

§

fn listening_as(&self) -> HashSet<Multiaddr>

§

fn multiaddress_of(&self, peer: &PeerId) -> Option<HashSet<Multiaddr>>

§

fn discovered_peers(&self) -> HashSet<PeerId>

§

fn connected_peers(&self) -> HashSet<PeerId>

§

fn is_connected(&self, peer: &PeerId) -> bool

§

fn health(&self) -> Health

§

fn subscribe_network_events( &self, ) -> impl Stream<Item = NetworkEvent> + Send + 'static

Implementors§

Source§

impl<Chain, Graph, Net> NetworkView for HoprTransport<Chain, Graph, Net>
where Net: NetworkView + Send + Sync + 'static,