diff --git a/core/commands/ping.go b/core/commands/ping.go index 5caec36df1b..d235c45e111 100644 --- a/core/commands/ping.go +++ b/core/commands/ping.go @@ -118,7 +118,8 @@ func pingPeer(ctx context.Context, n *core.IpfsNode, pid peer.ID, numPings int) if len(n.Peerstore.Addrs(pid)) == 0 { // Make sure we can find the node in question outChan <- &PingResult{ - Text: fmt.Sprintf("Looking up peer %s", pid.Pretty()), + Text: fmt.Sprintf("Looking up peer %s", pid.Pretty()), + Success: true, } ctx, cancel := context.WithTimeout(ctx, kPingTimeout) @@ -131,14 +132,20 @@ func pingPeer(ctx context.Context, n *core.IpfsNode, pid peer.ID, numPings int) n.Peerstore.AddAddrs(p.ID, p.Addrs, pstore.TempAddrTTL) } - outChan <- &PingResult{Text: fmt.Sprintf("PING %s.", pid.Pretty())} + outChan <- &PingResult{ + Text: fmt.Sprintf("PING %s.", pid.Pretty()), + Success: true, + } ctx, cancel := context.WithTimeout(ctx, kPingTimeout*time.Duration(numPings)) defer cancel() pings, err := n.Ping.Ping(ctx, pid) if err != nil { log.Debugf("Ping error: %s", err) - outChan <- &PingResult{Text: fmt.Sprintf("Ping error: %s", err)} + outChan <- &PingResult{ + Success: false, + Text: fmt.Sprintf("Ping error: %s", err), + } return } @@ -165,7 +172,8 @@ func pingPeer(ctx context.Context, n *core.IpfsNode, pid peer.ID, numPings int) } averagems := total.Seconds() * 1000 / float64(numPings) outChan <- &PingResult{ - Text: fmt.Sprintf("Average latency: %.2fms", averagems), + Success: true, + Text: fmt.Sprintf("Average latency: %.2fms", averagems), } }() return outChan