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§
sourcetype NotificationProtocolConfig: NotificationConfig
type NotificationProtocolConfig: NotificationConfig
Type representing notification protocol-related configuration.
sourcetype RequestResponseProtocolConfig: RequestResponseConfig
type RequestResponseProtocolConfig: RequestResponseConfig
Type representing request-response protocol-related configuration.
sourcetype NetworkService<Block, Hash>: NetworkService + Clone
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
.
sourcetype BitswapConfig
type BitswapConfig
Bitswap config.
Required Methods§
sourcefn new(params: Params<B, H, Self>) -> Result<Self, Error>where
Self: Sized,
fn new(params: Params<B, H, Self>) -> Result<Self, Error>where
Self: Sized,
Create new NetworkBackend
.
sourcefn network_service(&self) -> Arc<dyn NetworkService>
fn network_service(&self) -> Arc<dyn NetworkService>
Get handle to NetworkService
of the NetworkBackend
.
sourcefn peer_store(
bootnodes: Vec<PeerId>,
metrics_registry: Option<Registry>,
) -> Self::PeerStore
fn peer_store( bootnodes: Vec<PeerId>, metrics_registry: Option<Registry>, ) -> Self::PeerStore
Create PeerStore
.
sourcefn register_notification_metrics(
registry: Option<&Registry>,
) -> NotificationMetrics
fn register_notification_metrics( registry: Option<&Registry>, ) -> NotificationMetrics
Register metrics that are used by the notification protocols.
sourcefn bitswap_server(
client: Arc<dyn BlockBackend<B> + Send + Sync>,
) -> (Pin<Box<dyn Future<Output = ()> + Send>>, Self::BitswapConfig)
fn bitswap_server( client: Arc<dyn BlockBackend<B> + Send + Sync>, ) -> (Pin<Box<dyn Future<Output = ()> + Send>>, Self::BitswapConfig)
Create Bitswap server.
sourcefn 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 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.
sourcefn 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 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.
Object Safety§
This trait is not object safe.