Skip to content

web3infra-foundation/libp2p-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9526311 · Apr 7, 2023
Mar 1, 2022
Mar 9, 2022
Mar 1, 2022
Mar 8, 2022
Mar 9, 2022
Mar 9, 2022
Mar 9, 2022
Apr 7, 2023
Mar 9, 2022
Jun 18, 2021
Mar 9, 2022
Mar 9, 2022
May 24, 2021
Oct 27, 2020
May 24, 2021
Mar 1, 2022
Mar 9, 2022
Apr 7, 2023
Jan 26, 2021
Jan 14, 2021
Apr 7, 2023
May 24, 2021
Apr 7, 2023
Oct 27, 2020

Repository files navigation

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.