From 30a7adfc64622e4ea60f3665c5e7df0516079278 Mon Sep 17 00:00:00 2001 From: rkfg Date: Mon, 31 Jan 2022 15:04:49 +0300 Subject: [PATCH] Add remote balance and update count columns --- README.md | 2 ++ config/default.go | 2 ++ ui/views/channels.go | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/README.md b/README.md index 1a1afe2..6384601 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ columns = [ "ALIAS", # alias of the channel node "GAUGE", # ascii bar with percent local/capacity "LOCAL", # the local amount of the channel + # "REMOTE", # the remote amount of the channel "CAP", # the total capacity of the channel "SENT", # the total amount sent "RECEIVED", # the total amount received @@ -78,6 +79,7 @@ columns = [ "PRIVATE", # true if channel is private "ID", # the id of the channel # "SCID", # short channel id (BxTxO formatted) + # "NUPD", # number of channel updates ] [views.transactions] diff --git a/config/default.go b/config/default.go index 9b48361..02e81a9 100644 --- a/config/default.go +++ b/config/default.go @@ -35,6 +35,7 @@ columns = [ "ALIAS", # alias of the channel node "GAUGE", # ascii bar with percent local/capacity "LOCAL", # the local amount of the channel + # "REMOTE", # the remote amount of the channel "CAP", # the total capacity of the channel "SENT", # the total amount sent "RECEIVED", # the total amount received @@ -45,6 +46,7 @@ columns = [ "PRIVATE", # true if channel is private "ID", # the id of the channel # "SCID", # short channel id (BxTxO formatted) + # "NUPD", # number of channel updates ] [views.transactions] diff --git a/ui/views/channels.go b/ui/views/channels.go index 93dc7bf..9cdd066 100644 --- a/ui/views/channels.go +++ b/ui/views/channels.go @@ -367,6 +367,19 @@ func NewChannels(cfg *config.View, chans *models.Channels) *Channels { return color.Cyan(opts...)(printer.Sprintf("%12d", c.LocalBalance)) }, } + case "REMOTE": + channels.columns[i] = channelsColumn{ + width: 12, + name: fmt.Sprintf("%12s", columns[i]), + sort: func(order models.Order) models.ChannelsSort { + return func(c1, c2 *netmodels.Channel) bool { + return models.Int64Sort(c1.RemoteBalance, c2.RemoteBalance, order) + } + }, + display: func(c *netmodels.Channel, opts ...color.Option) string { + return color.Cyan(opts...)(printer.Sprintf("%12d", c.RemoteBalance)) + }, + } case "CAP": channels.columns[i] = channelsColumn{ width: 12, @@ -512,6 +525,19 @@ func NewChannels(cfg *config.View, chans *models.Channels) *Channels { return color.White(opts...)(fmt.Sprintf("%-14s", ToScid(c.ID))) }, } + case "NUPD": + channels.columns[i] = channelsColumn{ + width: 8, + name: fmt.Sprintf("%-8s", columns[i]), + sort: func(order models.Order) models.ChannelsSort { + return func(c1, c2 *netmodels.Channel) bool { + return models.UInt64Sort(c1.UpdatesCount, c2.UpdatesCount, order) + } + }, + display: func(c *netmodels.Channel, opts ...color.Option) string { + return color.White(opts...)(printer.Sprintf("%8d", c.UpdatesCount)) + }, + } default: channels.columns[i] = channelsColumn{ width: 21,