Closed hackergrrl closed 8 years ago
Still pending: documenting peer.addSafe()
.
@diasdavid what is this?
re: peer.addSafe()
It is to save from multiaddr explosion
what is a "multiaddr explosion"? What is this trying to protect from happening? https://github.com/diasdavid/js-peer-info/blob/master/src/index.js#L37
multiaddr explosion is when you have peers that tell you they see you in a certain addr, but pretty much only then can see you that way ( network topologies ) so we always confirm two times before saying that a multiaddr is valid
Could you take another angle at explaining this again? Is this related to NATs?
First, are you familiar with the Identify protocol, why it exists and how does it work?
This is the only information I can find about Identify. I'm unclear on what "observed addresses" are in this context.
Got it. Identify is to help NAT traversal. We keep exchanging the "Addresses that we see with the peers we connect", it is like STUN, but every time you connect to a peer.
Since we reuse the port for incoming connections, if two peers try to connect to each other, eventually, they will get through a NAT. This is not the perfect solution, as typical hole punching means that you have a way to notify the other peer you are trying to dial them, so that both try to pierce the NAT at the same time (having one of the sides failing on the first try, and succeeding on the second), but this has given us some very good results that have kept us from having to go with more advanced NAT traversal implementations for a while.
However, the number of addrs that we get from other peers that connected to us vary greatly and if two peers are in the same LAN, their respective observed addrs are pretty much irrelevant for the rest of the network, as no one else will be able to dial to them from their local area network, so we use the addSafe to save us from multiaddr explosion, which is filling up our list of multiaddrs with addresses that are of little value. Note that also, LANs have subnets IPs pretty much standardised, it can could be annoying announcing to the network that you are available in a 192.168.. IP, because then other peers would try to dial to non existing peers in their subnets.
Hope this helped :)
Ah, I see now. Thank you for explaining! <3
No problem. Thank you for adding this :):)
addresses part of https://github.com/ipfs/js-ipfs/issues/116