mirror of
https://github.com/status-im/status-go-monitor.git
synced 2025-01-13 12:54:44 +00:00
move table formatting to peers.go
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
fd834252fb
commit
f22a1554f5
19
json.go
19
json.go
@ -1,9 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
import "fmt"
|
||||
|
||||
type Peer struct {
|
||||
Enode string `json:"enode"`
|
||||
@ -20,19 +17,11 @@ func (p Peer) String() string {
|
||||
|
||||
type peerId string
|
||||
|
||||
func (p Peer) AsTable(maxWidth int) string {
|
||||
var id string
|
||||
if maxWidth > 50 {
|
||||
id = string(p.Id)
|
||||
} else {
|
||||
id = p.Id.String()
|
||||
}
|
||||
return fmt.Sprintf("%15s | %30s | %s", id, p.Name, strings.Join(p.Caps, ", "))
|
||||
}
|
||||
|
||||
// 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:]))
|
||||
return fmt.Sprintf("%s...%s",
|
||||
string(id[:6]),
|
||||
string(id[len(id)-6:]))
|
||||
}
|
||||
|
||||
type NetworkInfo struct {
|
||||
|
11
peers.go
11
peers.go
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/jroimartin/gocui"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -38,3 +39,13 @@ func WritePeers(g *gocui.Gui, peers []Peer) {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (p Peer) AsTable(maxWidth int) string {
|
||||
var id string
|
||||
if maxWidth > 50 {
|
||||
id = string(p.Id)
|
||||
} else {
|
||||
id = p.Id.String()
|
||||
}
|
||||
return fmt.Sprintf("%15s | %30s | %s", id, p.Name, strings.Join(p.Caps, ", "))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user