aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2019-06-24 22:16:44 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-06-24 22:16:44 +0800
commit1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5 (patch)
tree5b37b2225f4ac75c5468d7a29b045b62204fb9f0 /cmd/geth
parente4a1488b2f9b0d8dbe51f8eda067374985d8b188 (diff)
downloadgo-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.gz
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.bz2
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.lz
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.xz
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.zst
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.zip
core/state, cmd/geth: streaming json output for dump command (#15475)
* core/state, cmd/geth: streaming json output dump cmd + optional code+storage * dump: add option to continue even if preimages are missing * core, evm: lint nits * cmd: use local flags for dump, omit empty code/storage * core/state: fix state dump test
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/chaincmd.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index c91545c7f..49e6a0594 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -162,6 +162,10 @@ Remove blockchain and state databases`,
utils.DataDirFlag,
utils.CacheFlag,
utils.SyncModeFlag,
+ utils.IterativeOutputFlag,
+ utils.ExcludeCodeFlag,
+ utils.ExcludeStorageFlag,
+ utils.IncludeIncompletesFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
@@ -287,7 +291,7 @@ func importChain(ctx *cli.Context) error {
fmt.Printf("Allocations: %.3f million\n", float64(mem.Mallocs)/1000000)
fmt.Printf("GC pause: %v\n\n", time.Duration(mem.PauseTotalNs))
- if ctx.GlobalIsSet(utils.NoCompactionFlag.Name) {
+ if ctx.GlobalBool(utils.NoCompactionFlag.Name) {
return nil
}
@@ -504,6 +508,7 @@ func dump(ctx *cli.Context) error {
defer stack.Close()
chain, chainDb := utils.MakeChain(ctx, stack)
+ defer chainDb.Close()
for _, arg := range ctx.Args() {
var block *types.Block
if hashish(arg) {
@@ -520,10 +525,20 @@ func dump(ctx *cli.Context) error {
if err != nil {
utils.Fatalf("could not create new state: %v", err)
}
- fmt.Printf("%s\n", state.Dump())
+ excludeCode := ctx.Bool(utils.ExcludeCodeFlag.Name)
+ excludeStorage := ctx.Bool(utils.ExcludeStorageFlag.Name)
+ includeMissing := ctx.Bool(utils.IncludeIncompletesFlag.Name)
+ if ctx.Bool(utils.IterativeOutputFlag.Name) {
+ state.IterativeDump(excludeCode, excludeStorage, !includeMissing, json.NewEncoder(os.Stdout))
+ } else {
+ if includeMissing {
+ fmt.Printf("If you want to include accounts with missing preimages, you need iterative output, since" +
+ " otherwise the accounts will overwrite each other in the resulting mapping.")
+ }
+ fmt.Printf("%v %s\n", includeMissing, state.Dump(excludeCode, excludeStorage, false))
+ }
}
}
- chainDb.Close()
return nil
}