cmd: use local flags for dump, omit empty code/storage

This commit is contained in:
Péter Szilágyi 2019-06-24 15:48:32 +03:00
parent 419b4240b4
commit 4528c8fa09
No known key found for this signature in database
GPG key ID: E9AE538CEDF8293D
4 changed files with 16 additions and 24 deletions

View file

@ -165,7 +165,7 @@ Remove blockchain and state databases`,
utils.IterativeOutputFlag, utils.IterativeOutputFlag,
utils.ExcludeCodeFlag, utils.ExcludeCodeFlag,
utils.ExcludeStorageFlag, utils.ExcludeStorageFlag,
utils.IncludeMissingPreimagesFlag, utils.IncludeIncompletesFlag,
}, },
Category: "BLOCKCHAIN COMMANDS", Category: "BLOCKCHAIN COMMANDS",
Description: ` Description: `
@ -525,10 +525,10 @@ func dump(ctx *cli.Context) error {
if err != nil { if err != nil {
utils.Fatalf("could not create new state: %v", err) utils.Fatalf("could not create new state: %v", err)
} }
excludeCode := ctx.GlobalBool(utils.ExcludeCodeFlag.Name) excludeCode := ctx.Bool(utils.ExcludeCodeFlag.Name)
excludeStorage := ctx.GlobalBool(utils.ExcludeStorageFlag.Name) excludeStorage := ctx.Bool(utils.ExcludeStorageFlag.Name)
includeMissing := ctx.GlobalBool(utils.IncludeMissingPreimagesFlag.Name) includeMissing := ctx.Bool(utils.IncludeIncompletesFlag.Name)
if ctx.GlobalBool(utils.IterativeOutputFlag.Name) { if ctx.Bool(utils.IterativeOutputFlag.Name) {
state.IterativeDump(excludeCode, excludeStorage, !includeMissing, json.NewEncoder(os.Stdout)) state.IterativeDump(excludeCode, excludeStorage, !includeMissing, json.NewEncoder(os.Stdout))
} else { } else {
if includeMissing { if includeMissing {

View file

@ -188,13 +188,6 @@ var (
utils.MetricsInfluxDBPasswordFlag, utils.MetricsInfluxDBPasswordFlag,
utils.MetricsInfluxDBTagsFlag, utils.MetricsInfluxDBTagsFlag,
} }
dumpFlags = []cli.Flag{
utils.IterativeOutputFlag,
utils.ExcludeCodeFlag,
utils.ExcludeStorageFlag,
utils.IncludeMissingPreimagesFlag,
}
) )
func init() { func init() {
@ -238,7 +231,6 @@ func init() {
app.Flags = append(app.Flags, debug.Flags...) app.Flags = append(app.Flags, debug.Flags...)
app.Flags = append(app.Flags, whisperFlags...) app.Flags = append(app.Flags, whisperFlags...)
app.Flags = append(app.Flags, metricsFlags...) app.Flags = append(app.Flags, metricsFlags...)
app.Flags = append(app.Flags, dumpFlags...)
app.Before = func(ctx *cli.Context) error { app.Before = func(ctx *cli.Context) error {
logdir := "" logdir := ""

View file

@ -197,20 +197,20 @@ var (
Usage: "List of trusted ULC servers", Usage: "List of trusted ULC servers",
} }
IterativeOutputFlag = cli.BoolFlag{ IterativeOutputFlag = cli.BoolFlag{
Name: "dump.iterative", Name: "iterative",
Usage: "Print streaming JSON iteratively as json objects, delimited by newlines", Usage: "Print streaming JSON iteratively, delimited by newlines",
} }
ExcludeStorageFlag = cli.BoolFlag{ ExcludeStorageFlag = cli.BoolFlag{
Name: "dump.nostorage", Name: "nostorage",
Usage: "When set, exclude storage entries (saves db lookups)", Usage: "Exclude storage entries (save db lookups)",
} }
IncludeMissingPreimagesFlag = cli.BoolFlag{ IncludeIncompletesFlag = cli.BoolFlag{
Name: "dump.includeincomplete", Name: "incompletes",
Usage: "When set, include also those we do not have address of (missing preimage)", Usage: "Include accounts for which we don't have the address (missing preimage)",
} }
ExcludeCodeFlag = cli.BoolFlag{ ExcludeCodeFlag = cli.BoolFlag{
Name: "dump.nocode", Name: "nocode",
Usage: "When set, exclude contract code (saves db lookups)", Usage: "Exclude contract code (save db lookups)",
} }
defaultSyncMode = eth.DefaultConfig.SyncMode defaultSyncMode = eth.DefaultConfig.SyncMode
SyncModeFlag = TextMarshalerFlag{ SyncModeFlag = TextMarshalerFlag{

View file

@ -33,8 +33,8 @@ type DumpAccount struct {
Nonce uint64 `json:"nonce"` Nonce uint64 `json:"nonce"`
Root string `json:"root"` Root string `json:"root"`
CodeHash string `json:"codeHash"` CodeHash string `json:"codeHash"`
Code string `json:"code"` Code string `json:"code,omitempty"`
Storage map[common.Hash]string `json:"storage"` Storage map[common.Hash]string `json:"storage,omitempty"`
Address *common.Address `json:"address,omitempty"` // Address only present in iterative (line-by-line) mode Address *common.Address `json:"address,omitempty"` // Address only present in iterative (line-by-line) mode
SecureKey hexutil.Bytes `json:"key,omitempty"` // If we don't have address, we can output the key SecureKey hexutil.Bytes `json:"key,omitempty"` // If we don't have address, we can output the key