dialPeer -> go h.ids.IdentifyConn(c) -> c.NewStream("/ipfs/id/1.0.0")
SelectProtoOrFail --> ProtocolID + ID
responseHandler.readMsg -> ids.consumeMessage -> consumeObservedAddress -> ids.observedAddrs.Add( EXTERNAL ADDRESS)
peer.ID.Addr will call h.AllAddrs() -> observed := h.ids.ObservedAddrsFor(listen) …
func (oas *ObservedAddrSet) AddrsFor(addr ma.Multiaddr) (addrs []ma.Multiaddr) {
oas.RLock()
defer oas.RUnlock()
if len(oas.addrs) == 0 {
return nil
}
key := string(addr.Bytes())
observedAddrs, ok := oas.addrs[key]
if !ok {
return
}
now := time.Now()
for _, a := range observedAddrs {
if now.Sub(a.LastSeen) <= oas.ttl && a.activated(oas.ttl) {
addrs = append(addrs, a.Addr)
}
}
return addrs
}