From fba5f56834156f26ce1a270c48345326789648c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 20 Jun 2019 17:06:37 -0400 Subject: [PATCH] print shortened version of ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- json.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/json.go b/json.go index d7b2013..3c99fb4 100644 --- a/json.go +++ b/json.go @@ -4,7 +4,7 @@ import "fmt" type Peer struct { Enode string `json:"enode"` - Id string `json:"id"` + Id peerId `json:"id"` Name string `json:"na"` Caps []string `json:"caps"` Network NetworkInfo `json:"netrowkr"` @@ -15,6 +15,15 @@ func (p Peer) String() string { return fmt.Sprintf("Peer(id=%s)", p.Id) } +type peerId string + +// the ID is too long to display in full in most places +func (id peerId) String() string { + return fmt.Sprintf("%s...%s", + string(id[:6]), + string(id[len(id)-6:])) +} + type NetworkInfo struct { LocalAddress string `json:"localAddress"` RemoteAddress string `json:"remoteAddress"`