func Peers(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Writer) error { enc := json.NewEncoder(out) peers := make([]peerInfo, len(*n.PeerMap)) for i, p := range *n.PeerMap { addrs := make([]string, len(p.Addresses)) for j, addr := range p.Addresses { addrStr, err := addr.String() if err != nil { return err } addrs[j] = addrStr } pubkeyBytes, err := p.PubKey.Bytes() if err != nil { return err } peer := peerInfo{ ID: p.ID.Pretty(), Addresses: addrs, PubKey: b58.Encode(pubkeyBytes), Latency: p.GetLatency().Nanoseconds(), } peers[i] = peer } enc.Encode(peers) return nil }
func (m Multihash) B58String() string { return b58.Encode([]byte(m)) }
func (k Key) Pretty() string { return b58.Encode([]byte(k)) }
func (id ID) Pretty() string { return b58.Encode(id) }