mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
remove "ex|import-preimages" and move snapshot preimages to snapshot.go
This commit is contained in:
parent
8eb2786762
commit
a915bda7a5
3 changed files with 39 additions and 108 deletions
|
|
@ -120,34 +120,6 @@ Optional second and third arguments control the first and
|
||||||
last block to write. In this mode, the file will be appended
|
last block to write. In this mode, the file will be appended
|
||||||
if already existing. If the file ends with .gz, the output will
|
if already existing. If the file ends with .gz, the output will
|
||||||
be gzipped.`,
|
be gzipped.`,
|
||||||
}
|
|
||||||
importPreimagesCommand = &cli.Command{
|
|
||||||
Action: importPreimages,
|
|
||||||
Name: "import-preimages",
|
|
||||||
Usage: "Import the preimage database from an RLP stream",
|
|
||||||
ArgsUsage: "<datafile>",
|
|
||||||
Flags: flags.Merge([]cli.Flag{
|
|
||||||
utils.CacheFlag,
|
|
||||||
utils.SyncModeFlag,
|
|
||||||
}, utils.DatabaseFlags),
|
|
||||||
Description: `
|
|
||||||
The import-preimages command imports hash preimages from an RLP encoded stream.
|
|
||||||
It's deprecated, please use "geth db import" instead.
|
|
||||||
`,
|
|
||||||
}
|
|
||||||
exportPreimagesCommand = &cli.Command{
|
|
||||||
Action: exportPreimages,
|
|
||||||
Name: "export-preimages",
|
|
||||||
Usage: "Export the preimage database into an RLP stream",
|
|
||||||
ArgsUsage: "<dumpfile>",
|
|
||||||
Flags: flags.Merge([]cli.Flag{
|
|
||||||
utils.CacheFlag,
|
|
||||||
utils.SyncModeFlag,
|
|
||||||
}, utils.DatabaseFlags),
|
|
||||||
Description: `
|
|
||||||
The export-preimages command exports hash preimages to an RLP encoded stream.
|
|
||||||
It's deprecated, please use "geth db export" instead.
|
|
||||||
`,
|
|
||||||
}
|
}
|
||||||
dumpCommand = &cli.Command{
|
dumpCommand = &cli.Command{
|
||||||
Action: dump,
|
Action: dump,
|
||||||
|
|
@ -165,17 +137,6 @@ It's deprecated, please use "geth db export" instead.
|
||||||
}, utils.DatabaseFlags),
|
}, utils.DatabaseFlags),
|
||||||
Description: `
|
Description: `
|
||||||
This command dumps out the state for a given block (or latest, if none provided).
|
This command dumps out the state for a given block (or latest, if none provided).
|
||||||
`,
|
|
||||||
}
|
|
||||||
exportSnapshotPreimagesCommand = &cli.Command{
|
|
||||||
Action: exportSnapshotPreimages,
|
|
||||||
Name: "export-snapshot-preimages",
|
|
||||||
Usage: "Export the preimage in snapshot enumeration order",
|
|
||||||
ArgsUsage: "<dumpfile> [<root>]",
|
|
||||||
Flags: utils.DatabaseFlags,
|
|
||||||
Description: `
|
|
||||||
The export-snapshot-preimages command exports hash preimages to a flat file, in exactly
|
|
||||||
the expected order for the overlay tree migration.
|
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -378,72 +339,6 @@ func exportChain(ctx *cli.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// importPreimages imports preimage data from the specified file.
|
|
||||||
func importPreimages(ctx *cli.Context) error {
|
|
||||||
if ctx.Args().Len() < 1 {
|
|
||||||
utils.Fatalf("This command requires an argument.")
|
|
||||||
}
|
|
||||||
|
|
||||||
stack, _ := makeConfigNode(ctx)
|
|
||||||
defer stack.Close()
|
|
||||||
|
|
||||||
db := utils.MakeChainDatabase(ctx, stack, false)
|
|
||||||
defer db.Close()
|
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
if err := utils.ImportPreimages(db, ctx.Args().First()); err != nil {
|
|
||||||
utils.Fatalf("Import error: %v\n", err)
|
|
||||||
}
|
|
||||||
fmt.Printf("Import done in %v\n", time.Since(start))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// exportPreimages dumps the preimage data to specified json file in streaming way.
|
|
||||||
func exportPreimages(ctx *cli.Context) error {
|
|
||||||
if ctx.Args().Len() < 1 {
|
|
||||||
utils.Fatalf("This command requires an argument.")
|
|
||||||
}
|
|
||||||
stack, _ := makeConfigNode(ctx)
|
|
||||||
defer stack.Close()
|
|
||||||
|
|
||||||
db := utils.MakeChainDatabase(ctx, stack, true)
|
|
||||||
defer db.Close()
|
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
if err := utils.ExportPreimages(db, ctx.Args().First()); err != nil {
|
|
||||||
utils.Fatalf("Export error: %v\n", err)
|
|
||||||
}
|
|
||||||
fmt.Printf("Export done in %v\n", time.Since(start))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// exportSnapshotPreimages dumps the preimage data to a flat file.
|
|
||||||
func exportSnapshotPreimages(ctx *cli.Context) error {
|
|
||||||
if ctx.NArg() < 1 {
|
|
||||||
utils.Fatalf("This command requires an argument.")
|
|
||||||
}
|
|
||||||
stack, _ := makeConfigNode(ctx)
|
|
||||||
defer stack.Close()
|
|
||||||
|
|
||||||
chain, _ := utils.MakeChain(ctx, stack, true)
|
|
||||||
|
|
||||||
var root common.Hash
|
|
||||||
if ctx.NArg() > 1 {
|
|
||||||
rootBytes := common.FromHex(ctx.Args().Get(1))
|
|
||||||
if len(rootBytes) != common.HashLength {
|
|
||||||
return fmt.Errorf("invalid hash: %s", ctx.Args().Get(1))
|
|
||||||
}
|
|
||||||
root = common.BytesToHash(rootBytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
start := time.Now()
|
|
||||||
if err := utils.ExportSnapshotPreimages(chain, ctx.Args().First(), root); err != nil {
|
|
||||||
utils.Fatalf("Export error: %v\n", err)
|
|
||||||
}
|
|
||||||
fmt.Printf("Export done in %v\n", time.Since(start))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseDumpConfig(ctx *cli.Context, stack *node.Node) (*state.DumpConfig, ethdb.Database, common.Hash, error) {
|
func parseDumpConfig(ctx *cli.Context, stack *node.Node) (*state.DumpConfig, ethdb.Database, common.Hash, error) {
|
||||||
db := utils.MakeChainDatabase(ctx, stack, true)
|
db := utils.MakeChainDatabase(ctx, stack, true)
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
|
||||||
|
|
@ -207,9 +207,6 @@ func init() {
|
||||||
initCommand,
|
initCommand,
|
||||||
importCommand,
|
importCommand,
|
||||||
exportCommand,
|
exportCommand,
|
||||||
importPreimagesCommand,
|
|
||||||
exportPreimagesCommand,
|
|
||||||
exportSnapshotPreimagesCommand,
|
|
||||||
removedbCommand,
|
removedbCommand,
|
||||||
dumpCommand,
|
dumpCommand,
|
||||||
dumpGenesisCommand,
|
dumpGenesisCommand,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -147,6 +148,17 @@ as the backend data source, making this command a lot faster.
|
||||||
|
|
||||||
The argument is interpreted as block number or hash. If none is provided, the latest
|
The argument is interpreted as block number or hash. If none is provided, the latest
|
||||||
block is used.
|
block is used.
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Action: snapshotExportPreimages,
|
||||||
|
Name: "export-preimages",
|
||||||
|
Usage: "Export the preimage in snapshot enumeration order",
|
||||||
|
ArgsUsage: "<dumpfile> [<root>]",
|
||||||
|
Flags: utils.DatabaseFlags,
|
||||||
|
Description: `
|
||||||
|
The export-preimages command exports hash preimages to a flat file, in exactly
|
||||||
|
the expected order for the overlay tree migration.
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -604,6 +616,33 @@ func dumpState(ctx *cli.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// snapshotExportPreimages dumps the preimage data to a flat file.
|
||||||
|
func snapshotExportPreimages(ctx *cli.Context) error {
|
||||||
|
if ctx.NArg() < 1 {
|
||||||
|
utils.Fatalf("This command requires an argument.")
|
||||||
|
}
|
||||||
|
stack, _ := makeConfigNode(ctx)
|
||||||
|
defer stack.Close()
|
||||||
|
|
||||||
|
chain, _ := utils.MakeChain(ctx, stack, true)
|
||||||
|
|
||||||
|
var root common.Hash
|
||||||
|
if ctx.NArg() > 1 {
|
||||||
|
rootBytes := common.FromHex(ctx.Args().Get(1))
|
||||||
|
if len(rootBytes) != common.HashLength {
|
||||||
|
return fmt.Errorf("invalid hash: %s", ctx.Args().Get(1))
|
||||||
|
}
|
||||||
|
root = common.BytesToHash(rootBytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
|
if err := utils.ExportSnapshotPreimages(chain, ctx.Args().First(), root); err != nil {
|
||||||
|
utils.Fatalf("Export error: %v\n", err)
|
||||||
|
}
|
||||||
|
log.Info("Export done", "duration", time.Since(start))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// checkAccount iterates the snap data layers, and looks up the given account
|
// checkAccount iterates the snap data layers, and looks up the given account
|
||||||
// across all layers.
|
// across all layers.
|
||||||
func checkAccount(ctx *cli.Context) error {
|
func checkAccount(ctx *cli.Context) error {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue