no need cli

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-08-28 08:10:07 +00:00
parent 11cf3a677b
commit 27d9dc796a
2 changed files with 11 additions and 15 deletions

View file

@ -22,7 +22,6 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"
@ -90,13 +89,7 @@ Remove blockchain and state databases`,
Action: inspect,
Name: "inspect",
ArgsUsage: "<prefix> <start>",
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags, []cli.Flag{
&cli.IntFlag{
Name: "workers",
Usage: "Number of parallel workers for database inspection",
Value: runtime.NumCPU(),
},
}),
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
Usage: "Inspect the storage size for each type of data in the database",
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
}
@ -336,8 +329,7 @@ func inspect(ctx *cli.Context) error {
db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close()
workers := ctx.Int("workers")
return rawdb.InspectDatabase(db, prefix, start, workers)
return rawdb.InspectDatabase(db, prefix, start)
}
func checkStateContent(ctx *cli.Context) error {

View file

@ -23,6 +23,7 @@ import (
"maps"
"os"
"path/filepath"
"runtime"
"slices"
"strings"
"sync"
@ -395,7 +396,7 @@ func (s *stat) GetCount() counter {
// InspectDatabase traverses the entire database and checks the size
// of all different categories of data.
func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte, workers int) error {
func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
var (
start = time.Now()
count atomic.Int64
@ -550,7 +551,10 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte, workers int)
return it.Error()
}
var eg errgroup.Group
var (
eg errgroup.Group
workers = runtime.NumCPU()
)
eg.SetLimit(workers)
log.Info("Starting parallel database inspection", "workers", workers)