From 2b68624a33d536f392266b547f2568fcf9402f0c Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Fri, 29 Mar 2019 10:06:30 +0100 Subject: [PATCH] enhance header --- network/backend/lnd/proto.go | 2 ++ network/models/info.go | 2 ++ ui/views/header.go | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/network/backend/lnd/proto.go b/network/backend/lnd/proto.go index 40fe4c5..66505eb 100644 --- a/network/backend/lnd/proto.go +++ b/network/backend/lnd/proto.go @@ -156,5 +156,7 @@ func infoProtoToInfo(resp *lnrpc.GetInfoResponse) *models.Info { BlockHash: resp.BlockHash, Synced: resp.SyncedToChain, Version: resp.Version, + Chains: resp.Chains, + Testnet: resp.Testnet, } } diff --git a/network/models/info.go b/network/models/info.go index b22d9ec..5bc1046 100644 --- a/network/models/info.go +++ b/network/models/info.go @@ -13,6 +13,8 @@ type Info struct { BlockHash string Synced bool Version string + Chains []string + Testnet bool } func (i Info) MarshalLogObject(enc logging.ObjectEncoder) error { diff --git a/ui/views/header.go b/ui/views/header.go index 5efbb6f..5d02883 100644 --- a/ui/views/header.go +++ b/ui/views/header.go @@ -34,9 +34,26 @@ func (h *Header) Set(g *gocui.Gui, x0, y0, x1, y1 int) error { version = matches[0] } - fmt.Fprintln(v, fmt.Sprintf("%s %s %s %s", + chain := "" + if len(h.Info.Chains) > 0 { + chain = h.Info.Chains[0] + } + + network := "testnet" + if !h.Info.Testnet { + network = "mainnet" + } + + sync := color.Yellow("[syncing]") + if h.Info.Synced { + sync = color.Green("[synced]") + } + + fmt.Fprintln(v, fmt.Sprintf("%s %s %s %s %s %s", color.CyanBg(h.Info.Alias), color.Cyan(fmt.Sprintf("%s-v%s", "lnd", version)), + fmt.Sprintf("%s %s", chain, network), + sync, fmt.Sprintf("%s %d", color.Cyan("height:"), h.Info.BlockHeight), fmt.Sprintf("%s %d", color.Cyan("peers:"), h.Info.NumPeers), ))