libp2p - How to discover initial peers?

499 Views Asked by At

In the bitcoin p2p core client, the initial peers are found, as stated, as:

When started for the first time, programs don’t know the IP addresses of any active full nodes. In order to discover some IP addresses, they query one or more DNS names (called DNS seeds) hardcoded into Bitcoin Core and BitcoinJ. The response to the lookup should include one or more DNS A records with the IP addresses of full nodes that may accept new incoming connections. For example, using the Unix ``dig command https://en.wikipedia.org/wiki/Dig_%28Unix_command%29>`__:

source: https://developer.bitcoin.org/devguide/p2p_network.html

Is the same approach required for libp2p for initial peer discovery? I was not able to find any tutorial which covers this information. I was hoping libp2p would handle this problem. Does the libp2p provide guidance or facilities for this?

1

There are 1 best solutions below

0
On

For libp2p peer discovery can be accomplished a variety of ways:

Peer discovery can be done using various protocols, such as broadcasting a message to all peers in the network or using a bootstrap node to provide a list of known peers.

source: https://docs.libp2p.io/concepts/discovery-routing/overview/#peer-discovery

The most common ways to begin peer discovery are:

  1. Hard-coded bootstrap list (details in A Rusty Bootstrapper)
  2. mDNS, for local peer discovery (libp2p mDNS spec)

Your node will connect to initial bootstrap peers, and ask them about what peers they're aware of, and try to connect to those peers until it's sufficiently "bootstrapped".