Commit 0aff6873 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

fix(peer) perform bounds check on peer Id when printing String

parent 0c530bf5
...@@ -116,7 +116,12 @@ type peer struct { ...@@ -116,7 +116,12 @@ type peer struct {
// String prints out the peer. // String prints out the peer.
func (p *peer) String() string { func (p *peer) String() string {
return "[Peer " + p.id.String()[:12] + "]" pid := p.id.String()
maxRunes := 12
if len(pid) < maxRunes {
maxRunes = len(pid)
}
return "[Peer " + pid[:maxRunes] + "]"
} }
// Key returns the ID as a Key (string) for maps. // Key returns the ID as a Key (string) for maps.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment