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
51 downloads per month
Used in 5 crates
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:
- A network identity of the local node in form of a
PeerId
. - 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 thetransport
module for more information. - One or more implementations of the
ProtocolHandler
trait. This is the protocols thatSwarm
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