mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2025-01-30 05:10:08 +08:00
Implement fmt.Stringer for PeerInfo
This commit is contained in:
parent
d2a21b6d4a
commit
d9cfa764ad
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user