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.
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.