referrerpolicy=no-referrer-when-downgrade

Trait sc_network::service::traits::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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<B, H> NetworkBackend<B, H> for NetworkWorker<B, H>
where B: BlockT + 'static, H: ExHashT,

source§

impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> for Litep2pNetworkBackend

§

type NotificationProtocolConfig = NotificationProtocolConfig

§

type RequestResponseProtocolConfig = RequestResponseConfig

§

type NetworkService<Block, Hash> = Arc<Litep2pNetworkService>

§

type PeerStore = Peerstore

§

type BitswapConfig = Config