forked from cerc-io/plugeth
cmd, core, ethdb, node: move chain freezer one folder deeper (#25487)
* cmd, core, ethdb, node: create chain freezer in a sub folder * core/rawdb: remove unused code * core, ethdb, node: add AncientDatadir API back * cmd, core: extend freezer info dump for sub-ancient-store * core/rawdb: rework freezer inspector * core/rawdb: address comments from Peter * core/rawdb: fix build issue
This commit is contained in:
+22
-31
@@ -22,7 +22,6 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
@@ -160,8 +159,8 @@ WARNING: This is a low-level operation which may cause database corruption!`,
|
||||
dbDumpFreezerIndex = &cli.Command{
|
||||
Action: freezerInspect,
|
||||
Name: "freezer-index",
|
||||
Usage: "Dump out the index of a given freezer type",
|
||||
ArgsUsage: "<type> <start (int)> <end (int)>",
|
||||
Usage: "Dump out the index of a specific freezer table",
|
||||
ArgsUsage: "<freezer-type> <table-type> <start (int)> <end (int)>",
|
||||
Flags: flags.Merge([]cli.Flag{
|
||||
utils.SyncModeFlag,
|
||||
}, utils.NetworkFlags, utils.DatabasePathFlags),
|
||||
@@ -275,7 +274,7 @@ func inspect(ctx *cli.Context) error {
|
||||
start []byte
|
||||
)
|
||||
if ctx.NArg() > 2 {
|
||||
return fmt.Errorf("Max 2 arguments: %v", ctx.Command.ArgsUsage)
|
||||
return fmt.Errorf("max 2 arguments: %v", ctx.Command.ArgsUsage)
|
||||
}
|
||||
if ctx.NArg() >= 1 {
|
||||
if d, err := hexutil.Decode(ctx.Args().Get(0)); err != nil {
|
||||
@@ -536,43 +535,35 @@ func dbDumpTrie(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
func freezerInspect(ctx *cli.Context) error {
|
||||
var (
|
||||
start, end int64
|
||||
disableSnappy bool
|
||||
err error
|
||||
)
|
||||
if ctx.NArg() < 3 {
|
||||
if ctx.NArg() < 4 {
|
||||
return fmt.Errorf("required arguments: %v", ctx.Command.ArgsUsage)
|
||||
}
|
||||
kind := ctx.Args().Get(0)
|
||||
if noSnap, ok := rawdb.FreezerNoSnappy[kind]; !ok {
|
||||
var options []string
|
||||
for opt := range rawdb.FreezerNoSnappy {
|
||||
options = append(options, opt)
|
||||
}
|
||||
sort.Strings(options)
|
||||
return fmt.Errorf("Could read freezer-type '%v'. Available options: %v", kind, options)
|
||||
} else {
|
||||
disableSnappy = noSnap
|
||||
}
|
||||
if start, err = strconv.ParseInt(ctx.Args().Get(1), 10, 64); err != nil {
|
||||
log.Info("Could read start-param", "error", err)
|
||||
var (
|
||||
freezer = ctx.Args().Get(0)
|
||||
table = ctx.Args().Get(1)
|
||||
)
|
||||
start, err := strconv.ParseInt(ctx.Args().Get(2), 10, 64)
|
||||
if err != nil {
|
||||
log.Info("Could not read start-param", "err", err)
|
||||
return err
|
||||
}
|
||||
if end, err = strconv.ParseInt(ctx.Args().Get(2), 10, 64); err != nil {
|
||||
log.Info("Could read count param", "error", err)
|
||||
end, err := strconv.ParseInt(ctx.Args().Get(3), 10, 64)
|
||||
if err != nil {
|
||||
log.Info("Could not read count param", "err", err)
|
||||
return err
|
||||
}
|
||||
stack, _ := makeConfigNode(ctx)
|
||||
defer stack.Close()
|
||||
path := filepath.Join(stack.ResolvePath("chaindata"), "ancient")
|
||||
log.Info("Opening freezer", "location", path, "name", kind)
|
||||
if f, err := rawdb.NewFreezerTable(path, kind, disableSnappy, true); err != nil {
|
||||
|
||||
db := utils.MakeChainDatabase(ctx, stack, true)
|
||||
defer db.Close()
|
||||
|
||||
ancient, err := db.AncientDatadir()
|
||||
if err != nil {
|
||||
log.Info("Failed to retrieve ancient root", "err", err)
|
||||
return err
|
||||
} else {
|
||||
f.DumpIndex(start, end)
|
||||
}
|
||||
return nil
|
||||
return rawdb.InspectFreezerTable(ancient, freezer, table, start, end)
|
||||
}
|
||||
|
||||
func importLDBdata(ctx *cli.Context) error {
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ var (
|
||||
}
|
||||
AncientFlag = &flags.DirectoryFlag{
|
||||
Name: "datadir.ancient",
|
||||
Usage: "Data directory for ancient chain segments (default = inside chaindata)",
|
||||
Usage: "Root directory for ancient data (default = inside chaindata)",
|
||||
Category: flags.EthCategory,
|
||||
}
|
||||
MinFreeDiskSpaceFlag = &flags.DirectoryFlag{
|
||||
|
||||
Reference in New Issue
Block a user