pub trait NetworkInterface<TMessage: Message + Send, NetworkSender> {
    type AppDataKey: Clone + Debug + Eq + Hash;
    type AppData: Clone + Debug;

    fn peer_metadata_storage(&self) -> &PeerMetadataStorage;
    fn sender(&self) -> NetworkSender;
    fn app_data(&self) -> &LockingHashMap<Self::AppDataKey, Self::AppData>;

    fn connected_peers(
        &self,
        network_id: NetworkId
    ) -> HashMap<PeerNetworkId, PeerInfo> { ... } fn filtered_peers<F: FnMut(&(&PeerId, &PeerInfo)) -> bool>(
        &self,
        network_id: NetworkId,
        filter: F
    ) -> HashMap<PeerNetworkId, PeerInfo> { ... } fn peers(&self, network_id: NetworkId) -> HashMap<PeerNetworkId, PeerInfo> { ... } }
Expand description

A generic NetworkInterface for applications to connect to networking

Each application would implement their own NetworkInterface. This would hold AppData specific to the application as well as a specific Sender for cloning across threads and sending requests.

Required Associated Types

The application specific key for AppData

The application specific data to be stored

Required Methods

Provides the PeerMetadataStorage for other functions. Not expected to be used externally.

Give a copy of the sender for the network

Application specific data interface

Provided Methods

Retrieve only connected peers

Filter peers with according filter

Retrieve PeerInfo for the node

Implementors