简体   繁体   English

在 libp2p 中实现对等发现

[英]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? libp2p 中的对等点发现(例如,对等点互相告诉对方他们知道的对等点,并管理连接节点的列表)在 Rust 中是否完全在 NetworkBehavior 级别控制?

It looks like one option is to use Kademlia which looks like it does this (in the rust version) by defining a NetworkBehavior.看起来一种选择是使用Kademlia ,它看起来像通过定义 NetworkBehavior 来做到这一点(在 rust 版本中)。

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?如果您不想使用 Kademlia 实现对等发现,您可以通过将对等发现定义为 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.我试图避免一种情况,即我开始实现代码来执行此操作,但后来我发现 libp2p 实际上是在为我做这件事。

You have several alternatives, but of course you have to implement a behavior (or combination of behaviors) to discover peers:您有多种选择,但当然您必须实现一种行为(或行为组合)来发现对等点:

  • mDNS移动DNS

    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.我的一些同事正在准备即将发布的教程系列,以分享我们在 Rust 中使用 libp2p 的经验。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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