go-libp2p icon indicating copy to clipboard operation
go-libp2p copied to clipboard

Routed hosts should search for new addresses if the available adresses do not work issue#351

Open jmintb opened this issue 6 years ago • 3 comments

Currently if a routed host attempts a connection, it would only search for new addresses if no addresses were present in the peerinfo for that peer. This means that if the connection using the known addresses failed, there was no attempt to search for new addresses so that the connection might succeed.

This pr alters the Connect function for the routed host, so it searches for new addresses if it cannot connect using the known addresses. If new addresses are found, it attempts to connect using these.

I have also implemented a test that covers this case. It uses a mock test router which keeps peerinfo in a map and implements the Routing interface. Using the mock router makes it easy to manipulate the available peerinfo and avoids depending on an actual routing package.

jmintb avatar Jun 24 '18 18:06 jmintb

I'm not sure if this will work:

  1. Due to our backoff logic in go-libp2p-swarm, I'm kind of surprised the tests work. If we fail a dial, we should refuse to dial for a period of time.
  2. It has to retry all the old addresses.

Before we can fix this, we may need to fix https://github.com/libp2p/go-libp2p/issues/1554. That way, we can backoff on a per-multiaddr basis.

Stebalien avatar Jun 25 '18 17:06 Stebalien

In that case should I leave this until https://github.com/libp2p/go-libp2p/issues/1554 is fixed? Edit: go-libp2p-swarm isn't used when creating the hosts, so that is probably why the tests pass.

jmintb avatar Jun 25 '18 17:06 jmintb

libp2p.New uses go-libp2p-swarm under the hood. I'll have to look at those tests in depth to figure out what's going on.

Stebalien avatar Jun 26 '18 00:06 Stebalien