Add node cache info

pull/18/head
rkfg 2 years ago
parent be60dd99c8
commit f37db52009

@ -48,6 +48,7 @@ type configParams struct {
StatFilename string `short:"s" long:"stat" description:"save successful rebalance information to the specified CSV file" json:"stat" toml:"stat"`
NodeCacheFilename string `long:"node-cache-filename" description:"save and load other nodes information to this file, improves cold start performance" json:"node_cache_filename" toml:"node_cache_filename"`
NodeCacheLifetime int `long:"node-cache-lifetime" description:"nodes with last update older than this time (in minutes) will be removed from cache after loading it" json:"node_cache_lifetime" toml:"node_cache_lifetime" default:"1440"`
NodeCacheInfo bool `long:"node-cache-info" description:"show red and cyan 'x' characters in routes to indicate node cache misses and hits respectively" json:"node_cache_info" toml:"node_cache_info"`
}
var params, cfgParams configParams

@ -138,6 +138,14 @@ func (r *regolancer) printRoute(ctx context.Context, route *lnrpc.Route) {
fmt.Printf("%s %s sat | %s ppm\n", faintWhiteColor("Total fee:"),
formatFee(route.TotalFeesMsat), formatFeePPM(route.TotalAmtMsat, route.TotalFeesMsat))
for i, hop := range route.Hops {
cached := ""
if params.NodeCacheInfo {
cached = errColor("x")
if _, ok := r.nodeCache[hop.PubKey]; ok {
cached = cyanColor("x")
}
cached += "|"
}
nodeInfo, err := r.getNodeInfo(ctx, hop.PubKey)
if err != nil {
errs = errs + err.Error() + "\n"
@ -147,7 +155,7 @@ func (r *regolancer) printRoute(ctx context.Context, route *lnrpc.Route) {
if i > 0 {
fee = hiWhiteColorF("%-6d", route.Hops[i-1].FeeMsat)
}
fmt.Printf("%s %s [%s|%sch|%ssat|%s]\n", faintWhiteColor(hop.ChanId), fee, cyanColor(nodeInfo.Node.Alias),
fmt.Printf("%s %s [%s%s|%sch|%ssat|%s]\n", faintWhiteColor(hop.ChanId), fee, cached, cyanColor(nodeInfo.Node.Alias),
infoColor(nodeInfo.NumChannels), formatAmt(nodeInfo.TotalCapacity), infoColor(nodeInfo.Node.PubKey))
}
if errs != "" {

Loading…
Cancel
Save