5 unstable releases

0.3.0 Apr 23, 2021
0.2.2 Mar 2, 2021
0.2.1 Jan 26, 2021
0.2.0 Jan 14, 2021
0.1.0 Oct 26, 2020

#6 in #local-node

Download history 13/week @ 2024-02-12 8/week @ 2024-02-19 23/week @ 2024-02-26 7/week @ 2024-03-04 10/week @ 2024-03-11 19/week @ 2024-03-18

59 downloads per month
Used in 5 crates

MIT license

480KB
8K SLoC

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.

Dependencies

~19–34MB
~607K SLoC