[][src]Crate libp2prs_swarm

High level manager of the network.

A Swarm contains the state of the network as a whole. The entire behaviour of a libp2p network can be controlled through the Swarm. The Swarm struct contains all established connections to remotes and manages the state of all the substreams that have been opened, and all the upgrades that were built upon these substreams.

Initializing a Swarm

Creating a Swarm requires three things:

  1. A network identity of the local node in form of a PeerId.
  2. One or more implementations of the [Transport] trait. This is the type that will be used in order to reach nodes on the network based on their address. See the transport module for more information.
  3. One or more implementations of the [ProtocolHandler] trait. This is the protocols that Swarm is going to support.

Protocol Handler

The [ProtocolHandler] trait defines how each active connection to a remote should behave: how to handle incoming substreams, which protocols are supported, etc.

Re-exports

pub use protocol_handler::DummyProtocolHandler;

Modules

cli
connection

Communication channel to the remote peer.

identify

Implementation of the Identify protocol.

metrics
network
ping

This module implements the /ipfs/ping/1.0.0 protocol.

protocol_handler

A handler for a set of protocols used on a connection with a remote.

substream

Logical Substream for peer-to-peer communication.

Structs

Control

The Swarm controller.

Swarm

Contains the state of the network, plus the way it should behave.

Enums

SwarmError

The possible failures of Swarm.

SwarmEvent

Event generated by the Swarm.

Constants

PEERSTORE_GC_PURGE_INTERVAL