@cryptotaxi247 / kubo / commits / e511b4cc5

ping: return an error on failure

Use PingResult errors for errors attached to individual pings. This is a (minor) BREAKING CHANGE. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed May 8, 2019 at 23:02 UTC e511b4cc570e53ac7d8caf521719c73b446ebc33
1 file changed +2 -2
core/commands/ping.go
+2 -2
@@ -91,7 +91,7 @@ trip latency information.
91 p, err := n.Routing.FindPeer(ctx, pid)
92 cancel()
93 if err != nil {
94 - return res.Emit(&PingResult{Text: fmt.Sprintf("Peer lookup error: %s", err)})
94 + return fmt.Errorf("peer lookup failed: %s", err)
95 }
96 n.Peerstore.AddAddrs(p.ID, p.Addrs, pstore.TempAddrTTL)
97 }
@@ -144,7 +144,7 @@ trip latency information.
144 }
145 }
146 if count == 0 {
147 - return nil
147 + return fmt.Errorf("ping failed")
148 }
149 averagems := total.Seconds() * 1000 / float64(count)
150 return res.Emit(&PingResult{