Implement fmt.Stringer for PeerInfo
@@ -5,7 +5,7 @@ import (
"fmt"
"strings"
- "github.com/libp2p/go-libp2p-peer"
+ peer "github.com/libp2p/go-libp2p-peer"
ma "github.com/multiformats/go-multiaddr"
)
@@ -18,6 +18,12 @@ type PeerInfo struct {
Addrs []ma.Multiaddr
}
+var _ fmt.Stringer = PeerInfo{}
+
+func (pi PeerInfo) String() string {
+ return fmt.Sprintf("{%v: %v}", pi.ID, pi.Addrs)
+}
+
var ErrInvalidAddr = fmt.Errorf("invalid p2p multiaddr")
func InfoFromP2pAddr(m ma.Multiaddr) (*PeerInfo, error) {
