Skip to content

Commit 5a95a46

Browse files
protocols/: Add documentation on peer discovery (#2465)
Co-authored-by: Max Inden <[email protected]>
1 parent 0bb8ee9 commit 5a95a46

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

protocols/gossipsub/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@
5151
//! integers. They are chosen at random in this implementation of gossipsub, but are sequential in
5252
//! the current go implementation.
5353
//!
54+
//! # Peer Discovery
55+
//!
56+
//! Gossipsub does not provide peer discovery by itself. Peer discovery is the process by which
57+
//! peers in a p2p network exchange information about each other among other reasons to become resistant
58+
//! against the failure or replacement of the
59+
//! [boot nodes](https://docs.libp2p.io/reference/glossary/#boot-node) of the network.
60+
//!
61+
//! Peer
62+
//! discovery can e.g. be implemented with the help of the [Kademlia](https://github.com/libp2p/specs/blob/master/kad-dht/README.md) protocol
63+
//! in combination with the [Identify](https://github.com/libp2p/specs/tree/master/identify) protocol. See the
64+
//! Kademlia implementation documentation for more information.
65+
//!
5466
//! # Using Gossipsub
5567
//!
5668
//! ## GossipsubConfig

protocols/identify/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
//! At least one identification request is sent on a newly established
2727
//! connection, beyond which the behaviour does not keep connections alive.
2828
//!
29+
//! # Important Discrepancies
30+
//!
31+
//! - **Using Identify with other protocols** Unlike some other libp2p implementations,
32+
//! rust-libp2p does not treat Identify as a core protocol. This means that other protocols cannot
33+
//! rely upon the existence of Identify, and need to be manually hooked up to Identify in order to
34+
//! make use of its capabilities.
35+
//!
2936
//! # Usage
3037
//!
3138
//! The [`Identify`] struct implements a `NetworkBehaviour` that negotiates

protocols/kad/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919
// DEALINGS IN THE SOFTWARE.
2020

2121
//! Implementation of the libp2p-specific Kademlia protocol.
22+
//!
23+
//! See [specification](https://github.com/libp2p/specs/blob/master/kad-dht/README.md) for details.
24+
//!
25+
//! # Important Discrepancies
26+
//!
27+
//! - **Peer Discovery with Identify** In other libp2p implementations, the
28+
//! [Identify](https://github.com/libp2p/specs/tree/master/identify) protocol might be seen as a core protocol. Rust-libp2p
29+
//! tries to stay as generic as possible, and does not make this assumption.
30+
//! This means that the Identify protocol must be manually hooked up to Kademlia through calls
31+
//! to [`Kademlia::add_address`].
32+
//! If you choose not to use the Identify protocol, and do not provide an alternative peer
33+
//! discovery mechanism, a Kademlia node will not discover nodes beyond the network's
34+
//! [boot nodes](https://docs.libp2p.io/reference/glossary/#boot-node). Without the Identify protocol,
35+
//! existing nodes in the kademlia network cannot obtain the listen addresses
36+
//! of nodes querying them, and thus will not be able to add them to their routing table.
2237
2338
// TODO: we allow dead_code for now because this library contains a lot of unused code that will
2439
// be useful later for record store

0 commit comments

Comments
 (0)