diff --git a/json.go b/json.go index cfde5c1..fd3e80a 100644 --- a/json.go +++ b/json.go @@ -4,7 +4,7 @@ import "fmt" type Peer struct { Enode string `json:"enode"` - Id peerId `json:"id"` + ID PeerId `json:"id"` Name string `json:"name"` Caps []string `json:"caps"` Network NetworkInfo `json:"network"` @@ -12,13 +12,13 @@ type Peer struct { } func (p Peer) String() string { - return fmt.Sprintf("Peer(id=%s)", p.Id) + return fmt.Sprintf("Peer(ID=%s)", p.ID) } -type peerId string +type PeerId string // the ID is too long to display in full in most places -func (id peerId) String() string { +func (id PeerId) String() string { return fmt.Sprintf("%s...%s", string(id[:6]), string(id[len(id)-6:])) diff --git a/render.go b/render.go index f8a6dea..f4a1495 100644 --- a/render.go +++ b/render.go @@ -47,7 +47,7 @@ func renderPeerInfo(g *gocui.Gui, peer *Peer) { v.Clear() fmt.Fprintf(v, strings.Repeat("%-8s: %v\n", 8), "Name", peer.Name, - "ID", string(peer.Id), + "ID", string(peer.ID), "Enode", peer.Enode, "Static", peer.Network.Static, "Trusted", peer.Network.Trusted, @@ -76,9 +76,9 @@ func updatePeerCursor(g *gocui.Gui, current int) { func (p Peer) AsTable(maxWidth int) string { var id string if maxWidth > 160 { - id = string(p.Id) + id = string(p.ID) } else { - id = p.Id.String() + id = p.ID.String() } return fmt.Sprintf("%s | %-15s | %-21s | %-7s | %-8s", id, p.Name,