Closed Warchant closed 5 years ago
I believe this is trying to handle a race condition:
FindLocal
) to see if we're connected to the target peer, we aren't.NearestPeers
.But we should probably do an additional sanity check to make sure that the peer info isn't empty, just in case.
Found something interesting.
https://sourcegraph.com/github.com/libp2p/go-libp2p-kad-dht/-/blob/routing.go#L607-620
FindLocal
is essentially the same asdht.peerstore.PeerInfo(id)
.Then
dht.routingTable.NearestPeers(kb.ConvertPeerID(id), AlphaValue)
is executed. It does something, but it definitely does not modify peerstore.Then, if
id
is found amongnearest peers
, we go to peerstore again and executedht.peerstore.PeerInfo(id)
again. But previous call did not find addresses, andNearestPeers
did not modify peerstore, so what do we expect to get here?:)It will also return empty PeerInfo.
This execution path returns no error, and at the same time returns empty PeerInfo and in my opinion, wrong.