mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
cleanup: restore dbcmd.go and rawdb files, remove tablewriter dependency
This commit is contained in:
parent
b863a94dce
commit
9dcea9de65
4 changed files with 20 additions and 41 deletions
|
|
@ -41,6 +41,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/ethereum/go-ethereum/triedb"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
|
@ -759,16 +760,10 @@ func showMetaData(ctx *cli.Context) error {
|
|||
data = append(data, []string{"headHeader.Root", fmt.Sprintf("%v", h.Root)})
|
||||
data = append(data, []string{"headHeader.Number", fmt.Sprintf("%d (%#x)", h.Number, h.Number)})
|
||||
}
|
||||
table.SetHeader([]string{"Key", "Value"})
|
||||
|
||||
for key, value := range stats {
|
||||
table.Append([]string{key, fmt.Sprintf("%v", value)})
|
||||
}
|
||||
|
||||
fmt.Println("Key\tValue")
|
||||
for key, value := range stats {
|
||||
fmt.Printf("%s\t%v\n", key, value)
|
||||
}
|
||||
table := tablewriter.NewWriter(os.Stdout)
|
||||
table.SetHeader([]string{"Field", "Value"})
|
||||
table.AppendBulk(data)
|
||||
table.Render()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -650,21 +650,11 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
|
|||
total.Add(uint64(ancient.size()))
|
||||
}
|
||||
|
||||
// Print header
|
||||
fmt.Println("Database\tCategory\tSize\tItems")
|
||||
|
||||
// Print table rows (stats is [][]string)
|
||||
for _, row := range stats {
|
||||
if len(row) == 4 {
|
||||
fmt.Printf("%s\t%s\t%s\t%s\n", row[0], row[1], row[2], row[3])
|
||||
}
|
||||
}
|
||||
|
||||
// Print footer summary
|
||||
fmt.Printf("\nTotal\t\t%s\t%d\n",
|
||||
common.StorageSize(total.Load()).String(),
|
||||
count.Load(),
|
||||
)
|
||||
table := newTableWriter(os.Stdout)
|
||||
table.SetHeader([]string{"Database", "Category", "Size", "Items"})
|
||||
table.SetFooter([]string{"", "Total", common.StorageSize(total.Load()).String(), fmt.Sprintf("%d", count.Load())})
|
||||
table.AppendBulk(stats)
|
||||
table.Render()
|
||||
|
||||
if !unaccounted.empty() {
|
||||
log.Error("Database contains unaccounted data", "size", unaccounted.sizeString(), "count", unaccounted.countString())
|
||||
|
|
|
|||
|
|
@ -206,11 +206,3 @@ func (t *Table) printRow(row []string, widths []int) {
|
|||
}
|
||||
fmt.Fprintln(t.out)
|
||||
}
|
||||
package rawdb
|
||||
|
||||
import "io"
|
||||
|
||||
// TinyGo doesn't support table formatting; use minimal placeholder.
|
||||
type Table struct{}
|
||||
|
||||
func NewTableWriter(w io.Writer) *Table { return &Table{} }
|
||||
|
|
|
|||
|
|
@ -19,13 +19,15 @@
|
|||
|
||||
package rawdb
|
||||
|
||||
import "io"
|
||||
import (
|
||||
"io"
|
||||
|
||||
// Table is a placeholder struct for manual table rendering.
|
||||
type Table struct {
|
||||
w io.Writer
|
||||
}
|
||||
"github.com/olekukonko/tablewriter"
|
||||
)
|
||||
|
||||
func NewTableWriter(w io.Writer) *Table {
|
||||
return &Table{w: w}
|
||||
// Re-export the real tablewriter types and functions
|
||||
type Table = tablewriter.Table
|
||||
|
||||
func newTableWriter(w io.Writer) *Table {
|
||||
return tablewriter.NewWriter(w)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue