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

#98 in #libp2p

Download history 63/week @ 2023-10-19 57/week @ 2023-10-26 49/week @ 2023-11-02 56/week @ 2023-11-09 59/week @ 2023-11-16 64/week @ 2023-11-23 49/week @ 2023-11-30 52/week @ 2023-12-07 55/week @ 2023-12-14 52/week @ 2023-12-21 39/week @ 2023-12-28 47/week @ 2024-01-04 52/week @ 2024-01-11 50/week @ 2024-01-18 42/week @ 2024-01-25 23/week @ 2024-02-01

179 downloads per month
Used in 15 crates

MIT license

305KB
5.5K SLoC

Alternative repository for work on libp2p

Continuous integration

This repository is an alternative implementation in Rust of the libp2p spec. Not like rust-libp2p, libp2p-rs is written with async/await syntax, and driven by async runtime. Even though, many codes are borrowed from rust-libp2p and some from go-libp2p. We are trying to keep compatible with the two implementations, but it is unfortunately not guaranteed.

Documentations

How to use the library?

As mentioned above, the API is completely different from rust-libp2p. There is no such thing as 'NetworkBehaviour' in libp2p-rs at all. Instead, you should build the Swarm with the transports you like to use, then you have to create a Swarm::Control from it. The Swarm::Control is exposing all Swarm APIs which can be used to manipulate the Swarm - open/read/write/close streams and even more. This is quite similar as the BasicHost in go-libp2p. As for Kad-DHT, similarly you should get the Kad::Control for the same reason. Furthermore, you can combine the Swarm with Kad, after that you have the RoutedHost, which has a routing functionality over the BasicHost.

It is strongly recommended to check the docs and sample code in details:

Code examples:

  • Details about how to write your code can be found in examples
    • swarm_simple demonstrates how to build transport and create sub-stream for communication
    • kad_simple demonstrates how to run a Kad-DHT server. In this example, the interactive shell is integrated for debugging/observing Kad-DHT internal data structures
    • ...

Releases

NOTE: The master branch is now an active development branch (starting with v0.1.0), which means breaking changes could be made at any time.


lib.rs:

Transports, upgrades, multiplexing and node handling of libp2p.

The main concepts of libp2p-core are:

  • A PeerId is a unique global identifier for a node on the network. Each node must have a different PeerId. Normally, a PeerId is the hash of the public key used to negotiate encryption on the communication channel, thereby guaranteeing that they cannot be spoofed.
  • The Transport trait defines how to reach a remote node or listen for incoming remote connections. See the transport module.
  • The StreamMuxer trait is implemented on structs that hold a connection to a remote and can subdivide this connection into multiple substreams. See the muxing module.
  • The UpgradeInfo and Upgrader traits define how to upgrade each individual substream to use a protocol. See the upgrade module.

Dependencies

~19MB
~427K SLoC