sc_network::service::traits

Trait NetworkBackend

Source
pub trait NetworkBackend<B: BlockT + 'static, H: ExHashT>: Send + 'static {
    type NotificationProtocolConfig: NotificationConfig;
    type RequestResponseProtocolConfig: RequestResponseConfig;
    type NetworkService<Block, Hash>: NetworkService + Clone;
    type PeerStore: PeerStore;
    type BitswapConfig;

    // Required methods
    fn new(params: Params<B, H, Self>) -> Result<Self, Error>
       where Self: Sized;
    fn network_service(&self) -> Arc<dyn NetworkService>;
    fn peer_store(
        bootnodes: Vec<PeerId>,
        metrics_registry: Option<Registry>,
    ) -> Self::PeerStore;
    fn register_notification_metrics(
        registry: Option<&Registry>,
    ) -> NotificationMetrics;
    fn bitswap_server(
        client: Arc<dyn BlockBackend<B> + Send + Sync>,
    ) -> (Pin<Box<dyn Future<Output = ()> + Send>>, Self::BitswapConfig);
    fn notification_config(
        protocol_name: ProtocolName,
        fallback_names: Vec<ProtocolName>,
        max_notification_size: u64,
        handshake: Option<NotificationHandshake>,
        set_config: SetConfig,
        metrics: NotificationMetrics,
        peerstore_handle: Arc<dyn PeerStoreProvider>,
    ) -> (Self::NotificationProtocolConfig, Box<dyn NotificationService>);
    fn request_response_config(
        protocol_name: ProtocolName,
        fallback_names: Vec<ProtocolName>,
        max_request_size: u64,
        max_response_size: u64,
        request_timeout: Duration,
        inbound_queue: Option<Sender<IncomingRequest>>,
    ) -> Self::RequestResponseProtocolConfig;
    fn run<'async_trait>(
        self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

Networking backend.

Required Associated Types§

Source

type NotificationProtocolConfig: NotificationConfig

Type representing notification protocol-related configuration.

Source

type RequestResponseProtocolConfig: RequestResponseConfig

Type representing request-response protocol-related configuration.

Source

type NetworkService<Block, Hash>: NetworkService + Clone

Type implementing NetworkService for the networking backend.

NetworkService allows other subsystems of the blockchain to interact with sc-network using NetworkService.

Source

type PeerStore: PeerStore

Type implementing PeerStore.

Source

type BitswapConfig

Bitswap config.

Required Methods§

Source

fn new(params: Params<B, H, Self>) -> Result<Self, Error>
where Self: Sized,

Create new NetworkBackend.

Source

fn network_service(&self) -> Arc<dyn NetworkService>

Get handle to NetworkService of the NetworkBackend.

Source

fn peer_store( bootnodes: Vec<PeerId>, metrics_registry: Option<Registry>, ) -> Self::PeerStore

Create PeerStore.

Source

fn register_notification_metrics( registry: Option<&Registry>, ) -> NotificationMetrics

Register metrics that are used by the notification protocols.

Source

fn bitswap_server( client: Arc<dyn BlockBackend<B> + Send + Sync>, ) -> (Pin<Box<dyn Future<Output = ()> + Send>>, Self::BitswapConfig)

Create Bitswap server.

Source

fn notification_config( protocol_name: ProtocolName, fallback_names: Vec<ProtocolName>, max_notification_size: u64, handshake: Option<NotificationHandshake>, set_config: SetConfig, metrics: NotificationMetrics, peerstore_handle: Arc<dyn PeerStoreProvider>, ) -> (Self::NotificationProtocolConfig, Box<dyn NotificationService>)

Create notification protocol configuration and an associated NotificationService for the protocol.

Source

fn request_response_config( protocol_name: ProtocolName, fallback_names: Vec<ProtocolName>, max_request_size: u64, max_response_size: u64, request_timeout: Duration, inbound_queue: Option<Sender<IncomingRequest>>, ) -> Self::RequestResponseProtocolConfig

Create request-response protocol configuration.

Source

fn run<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,

Start NetworkBackend event loop.

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.

Implementors§