Module smoldot_light::network_service
source · Expand description
Background network service.
The NetworkService
manages background tasks dedicated to connecting to other nodes.
Importantly, its design is oriented towards the particular use case of the light client.
The NetworkService
spawns one background task (using PlatformRef::spawn_task
) for
each active connection.
The objective of the NetworkService
in general is to try stay connected as much as
possible to the nodes of the peer-to-peer network of the chain, and maintain open substreams
with them in order to send out requests (e.g. block requests) and notifications (e.g. block
announces).
Connectivity to the network is performed in the background as an implementation detail of the service. The public API only allows emitting requests and notifications towards the already-connected nodes.
After a NetworkService
is created, one can add chains using NetworkService::add_chain
.
If all references to a NetworkServiceChain
are destroyed, the chain is automatically
purged.
An important part of the API is the list of channel receivers of Event
returned by
NetworkServiceChain::subscribe
. These channels inform the foreground about updates to the
network connectivity.
Structs§
- Description of a call proof request that can be sent to a peer.
- Identifier of a chain added through
ChainNetwork::add_chain
. - Configuration for a
NetworkService
. - Undecoded but valid Merkle proof.
- Identifier of a node of the network.
Enums§
- Severity of a ban. See
NetworkServiceChain::ban_and_disconnect
. - Error returned by
NetworkServiceChain::blocks_request
. - Error returned by
NetworkServiceChain::call_proof_request
. - Event that can happen on the network service.
- Error potentially returned when queueing a notification.
- Role a node reports playing on the network.
- Error returned by
NetworkServiceChain::storage_proof_request
. - Error returned by
NetworkServiceChain::grandpa_warp_sync_request
.