print shortened version of ID

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-06-20 17:06:37 -04:00 committed by Jakub
parent c6b3fa3b9d
commit fba5f56834
1 changed files with 10 additions and 1 deletions

11
json.go
View File

@ -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"`