@cryptotaxi247 / kubo / commits / dd1093f43

fix: use connect instead of findpeer so we ensure we actually connect

Otherwise, the ID is going to be incorrect. Note: technically, the previous logic didn't need to connect to the target peer to complete. However, I'm fine dropping that capability in favor of more up-to-date information.

Steven Allen committed May 27, 2020 at 14:52 UTC dd1093f4382dbddc9efb04541756e98c903b6f07
1 file changed +7 -5
core/commands/id.go
+7 -5
@@ -97,15 +97,17 @@ EXAMPLE:
97 return errors.New(offlineIdErrorMessage)
98 }
99
100 - p, err := n.Routing.FindPeer(req.Context, id)
101 - if err == kb.ErrLookupFailure {
100 + // We need to actually connect to run identify.
101 + err = n.PeerHost.Connect(req.Context, peer.AddrInfo{ID: id})
102 + switch err {
103 + case nil:
104 + case kb.ErrLookupFailure:
105 return errors.New(offlineIdErrorMessage)
103 - }
104 - if err != nil {
106 + default:
107 return err
108 }
109
108 - output, err := printPeer(n.Peerstore, p.ID)
110 + output, err := printPeer(n.Peerstore, id)
111 if err != nil {
112 return err
113 }