aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2017-03-08 19:26:19 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-03-08 19:26:19 +0800
commit544247c91828b5f99d7d2bd61b98cc51e2b23e44 (patch)
treef4b45e6703b17ca32724436bd35f1397467e805f
parent4c6f4e569e66b399c69d4f018f3a3b7919ef144c (diff)
downloadgo-tangerine-544247c91828b5f99d7d2bd61b98cc51e2b23e44.tar
go-tangerine-544247c91828b5f99d7d2bd61b98cc51e2b23e44.tar.gz
go-tangerine-544247c91828b5f99d7d2bd61b98cc51e2b23e44.tar.bz2
go-tangerine-544247c91828b5f99d7d2bd61b98cc51e2b23e44.tar.lz
go-tangerine-544247c91828b5f99d7d2bd61b98cc51e2b23e44.tar.xz
go-tangerine-544247c91828b5f99d7d2bd61b98cc51e2b23e44.tar.zst
go-tangerine-544247c91828b5f99d7d2bd61b98cc51e2b23e44.zip
* cmd/geth: add --nocompaction flag + multiple import files
* main,import: Add --nocompaction flag + multiple import files * geth/import: documentation * import: Added more info to err message * fix :P
-rw-r--r--cmd/geth/chaincmd.go27
-rw-r--r--cmd/geth/main.go1
-rw-r--r--cmd/utils/flags.go5
3 files changed, 27 insertions, 6 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index 784692261..6ea474a9c 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -54,10 +54,13 @@ participating.
Action: importChain,
Name: "import",
Usage: "Import a blockchain file",
- ArgsUsage: "<filename>",
+ ArgsUsage: "<filename> (<filename 2> ... <filename N>) ",
Category: "BLOCKCHAIN COMMANDS",
Description: `
-TODO: Please write this
+The import command imports blocks from an RLP-encoded form. The form can be one file
+with several RLP-encoded blocks, or several files can be used.
+If only one file is used, import error will result in failure. If several files are used,
+processing will proceed even if an individual RLP-file import failure occurs.
`,
}
exportCommand = cli.Command{
@@ -122,7 +125,7 @@ func initGenesis(ctx *cli.Context) error {
}
func importChain(ctx *cli.Context) error {
- if len(ctx.Args()) != 1 {
+ if len(ctx.Args()) < 1 {
utils.Fatalf("This command requires an argument.")
}
stack := makeFullNode(ctx)
@@ -146,9 +149,19 @@ func importChain(ctx *cli.Context) error {
}()
// Import the chain
start := time.Now()
- if err := utils.ImportChain(chain, ctx.Args().First()); err != nil {
- utils.Fatalf("Import error: %v", err)
+
+ if len(ctx.Args()) == 1 {
+ if err := utils.ImportChain(chain, ctx.Args().First()); err != nil {
+ utils.Fatalf("Import error: %v", err)
+ }
+ } else {
+ for _, arg := range ctx.Args() {
+ if err := utils.ImportChain(chain, arg); err != nil {
+ log.Error("Import error", "file", arg, "err", err)
+ }
+ }
}
+
fmt.Printf("Import done in %v.\n\n", time.Since(start))
// Output pre-compaction stats mostly to see the import trashing
@@ -171,6 +184,10 @@ 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) {
+ return nil
+ }
+
// Compact the entire database to more accurately measure disk io and print the stats
start = time.Now()
fmt.Println("Compacting entire database...")
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 79893cc04..1f6f2bb29 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -140,6 +140,7 @@ func init() {
utils.EthStatsURLFlag,
utils.MetricsEnabledFlag,
utils.FakePoWFlag,
+ utils.NoCompactionFlag,
utils.SolcPathFlag,
utils.GpoMinGasPriceFlag,
utils.GpoMaxGasPriceFlag,
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index adc18a203..04db9a16f 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -244,7 +244,10 @@ var (
Name: "fakepow",
Usage: "Disables proof-of-work verification",
}
-
+ NoCompactionFlag = cli.BoolFlag{
+ Name: "nocompaction",
+ Usage: "Disables db compaction after import",
+ }
// RPC settings
RPCEnabledFlag = cli.BoolFlag{
Name: "rpc",