How does the ipfs discover other peers when it initialize?

I’ve noticed that there are many bootstrap peers written on configure files like below:
“/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN”,
“/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa”,
“/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb”,
“/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt”,

After swarming these peers, I had many peers who linked with each other. However, I really want to know what happened with the bootstrap when I was swarming these peers. Where do the peers come from? How do the bootstrap peers bring me these ones.

I believe there are a few well known and reliable peers that are included by default. You need something to get started. Your node will reach out to these bootstrap nodes and say, “Hey is there anybody else I should know about?” As long as you can get the process started you’re good to go but you need that initial push.

Thoses nodes are protocol labs hosted one. You can any integrated IPFS peer. For example I use a collection of 50 random node I have found on the network instead.

IPFS runs on a DHT (Distributed Hash Table), when you join the network your node will search for itself, in the process of the DHT that will cause the first boostrap peers to send you in the direction of your node and you will find your neighbors in key space.

3 Likes

Great. I already found the code that is highly correlated with what you talked to me about. thanks.