views channel node alias

pull/1/head
Edouard Paris 5 years ago
parent b763317014
commit a11abb8225

@ -37,6 +37,7 @@ type Channel struct {
Private bool
PendingHTLC []*HTLC
LastUpdate *time.Time
Node *Node
}
func (m Channel) MarshalLogObject(enc logging.ObjectEncoder) error {

@ -58,6 +58,14 @@ func (m *Models) RefreshChannels(ctx context.Context) error {
return err
}
if channels[i].Node == nil {
channels[i].Node, err = m.App.Network.GetNode(ctx,
channels[i].RemotePubKey)
if err != nil {
return err
}
}
m.Channels.Update(channels[i])
}
}

@ -60,32 +60,44 @@ func (c *Channels) Set(g *gocui.Gui, x0, y0, x1, y1 int) error {
func displayChannelsColumns(v *gocui.View) {
v.Clear()
fmt.Fprintln(v, fmt.Sprintf("%-9s %-26s %12s %12s %5s %-15s",
fmt.Fprintln(v, fmt.Sprintf("%-9s %-20s %-26s %12s %12s %5s %-15s %s",
"Status",
"Alias",
"Gauge",
"Local",
"Capacity",
"pHTLC",
"Last Update",
"ID",
))
}
func (c *Channels) display(v *gocui.View) {
v.Clear()
for _, item := range c.channels.List() {
line := fmt.Sprintf("%s %s %s %12d %5d %15s %500s",
line := fmt.Sprintf("%s %-20s %s %s %12d %5d %15s %d %500s",
active(item),
alias(item),
gauge(item),
color.Cyan(fmt.Sprintf("%12d", item.LocalBalance)),
item.Capacity,
len(item.PendingHTLC),
lastUpdate(item),
item.ID,
"",
)
fmt.Fprintln(v, line)
}
}
func alias(c *netmodels.Channel) string {
if c.Node == nil || c.Node.Alias == "" {
return c.RemotePubKey[:19]
}
return c.Node.Alias
}
func lastUpdate(c *netmodels.Channel) string {
if c.LastUpdate != nil {
return c.LastUpdate.Format("15:04:05 Jan _2")

Loading…
Cancel
Save