简体   繁体   中英

Implementing peer discovery in libp2p

Is peer discovery in libp2p (eg peers telling each other about peers they know about, and managing lists of connected nodes) in Rust controlled entirely at the level of a NetworkBehavior?

It looks like one option is to use Kademlia which looks like it does this (in the rust version) by defining a NetworkBehavior.

Is it correct that if you don't want to use Kademlia to implement peer discovery, you do this by defining peer discovery as part of your NetworkBehavior?

I'm trying to avoid a situation whereby I start to implement code to do this, but then I find that libp2p is actually doing this for me under the covers.

You have several alternatives, but of course you have to implement a behavior (or combination of behaviors) to discover peers:

  • mDNS

    It allows peers to discover each other when they are on the same local network without any configuration. It is obviously the simplest discovery mode, but limited to local networks. This is the example .

  • Rendezvous

    It's goal is to provide a lightweight mechanism for generalized peer discovery. As its name indicates, it requires that there be nodes that act as rendezvous. In the protocol implementation examples you can see it better.

  • Kademlia

    This is the best option in the context of a network with many nodes, where a portion of these nodes may offer limited connectivity. It's simpler than it seems, but at the time we did not find practical examples, and we learned through trial and error.

Some of my colleagues are preparing a tutorial series to be published soon, to share our experience with libp2p in Rust.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM