cmd: pretty printing

Signed-off-by: Ciro S. Costa <utxobr@protonmail.com>
This commit is contained in:
Ciro S. Costa 2021-07-31 22:07:52 -04:00
parent e84b32b615
commit e926c48784
2 changed files with 14 additions and 5 deletions

View file

@ -58,7 +58,11 @@ func (c *getTransactionPoolCommand) RunE(_ *cobra.Command, _ []string) error {
// nolint:forbidigo
func (c *getTransactionPoolCommand) pretty(v *daemon.GetTransactionPoolResult) error {
table := display.NewTable()
table.AddRow("Spent Key Images:", len(v.SpentKeyImages))
fmt.Println(table)
fmt.Println()
table = display.NewTable()
table.AddRow("AGE", "HASH", "FEE (µɱ)", "FEE (µɱ per kB)", "IN/OUT", "SIZE")
sort.Slice(v.Transactions, func(i, j int) bool {

View file

@ -2,6 +2,7 @@ package daemon
import (
"fmt"
"sort"
"time"
"github.com/dustin/go-humanize"
@ -59,11 +60,11 @@ func (c *getTransactionPoolStatsCommand) RunE(_ *cobra.Command, _ []string) erro
func (c *getTransactionPoolStatsCommand) pretty(v *daemon.GetTransactionPoolStatsResult) {
table := display.NewTable()
table.AddRow("Bytes Max:", v.PoolStats.BytesMax)
table.AddRow("Bytes Med:", v.PoolStats.BytesMed)
table.AddRow("Bytes Min:", v.PoolStats.BytesMin)
table.AddRow("Bytes Total:", v.PoolStats.BytesTotal)
table.AddRow("Fee Total:", v.PoolStats.FeeTotal)
table.AddRow("Bytes Max:", humanize.Bytes(v.PoolStats.BytesMax))
table.AddRow("Bytes Med:", humanize.Bytes(v.PoolStats.BytesMed))
table.AddRow("Bytes Min:", humanize.Bytes(v.PoolStats.BytesMin))
table.AddRow("Bytes Total:", humanize.Bytes(v.PoolStats.BytesTotal))
table.AddRow("Fee Total:", display.PreciseXMR(v.PoolStats.FeeTotal))
table.AddRow("Histogram 98pct:", v.PoolStats.Histo98Pc)
table.AddRow("Txns in Pool for Longer than 10m:", v.PoolStats.Num10M)
table.AddRow("Double Spends:", v.PoolStats.NumDoubleSpends)
@ -74,6 +75,10 @@ func (c *getTransactionPoolStatsCommand) pretty(v *daemon.GetTransactionPoolStat
table.AddRow("")
table.AddRow("BYTES", "TXNS")
sort.Slice(v.PoolStats.Histo, func(i, j int) bool {
return v.PoolStats.Histo[i].Bytes < v.PoolStats.Histo[j].Bytes
})
for _, h := range v.PoolStats.Histo {
if h.Bytes == 0 {
continue