make Peer.String() return the common case
When we want a string representation of a Peer, we nearly always just want the full name. So make String() return that and introduce Info() to return expanded info.
This commit is contained in:
1 parent
db198652a5
commit
0cbbe9bac3
8 files changed
+20
-20
No files matched your search
+2
-2
@@ -150,13 +150,13 @@ func (peers *Peers) GarbageCollect() []*Peer {
|
||||
func (peers *Peers) String() string {
|
||||
var buf bytes.Buffer
|
||||
peers.ForEach(func(peer *Peer) {
|
||||
fmt.Fprint(&buf, peer, "\n")
|
||||
fmt.Fprintln(&buf, peer.Info())
|
||||
for conn := range peer.Connections() {
|
||||
established := ""
|
||||
if !conn.Established() {
|
||||
established = " (unestablished)"
|
||||
}
|
||||
fmt.Fprintf(&buf, " -> %s [%v%s]\n", conn.Remote().FullName(), conn.RemoteTCPAddr(), established)
|
||||
fmt.Fprintf(&buf, " -> %s [%v%s]\n", conn.Remote(), conn.RemoteTCPAddr(), established)
|
||||
}
|
||||
})
|
||||
return buf.String()
|
||||
|
||||
Reference in new issue
Block a user