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

#7 in #local-node

Download history 10/week @ 2024-03-11 19/week @ 2024-03-18 6/week @ 2024-03-25 43/week @ 2024-04-01 8/week @ 2024-04-08 7/week @ 2024-04-15 10/week @ 2024-04-22 8/week @ 2024-04-29 12/week @ 2024-05-06 7/week @ 2024-05-13 12/week @ 2024-05-20 5/week @ 2024-05-27 10/week @ 2024-06-03 14/week @ 2024-06-10 13/week @ 2024-06-17 14/week @ 2024-06-24

51 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–33MB
~599K SLoC