main,import: Add --nocompaction flag + multiple import files

This commit is contained in:
Martin Holst Swende 2017-03-07 18:28:43 +01:00
parent 4c6f4e569e
commit 36fb59d699
2 changed files with 18 additions and 3 deletions

View file

@ -122,7 +122,7 @@ func initGenesis(ctx *cli.Context) error {
} }
func importChain(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.") utils.Fatalf("This command requires an argument.")
} }
stack := makeFullNode(ctx) stack := makeFullNode(ctx)
@ -146,9 +146,19 @@ func importChain(ctx *cli.Context) error {
}() }()
// Import the chain // Import the chain
start := time.Now() 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", "err", err)
}
}
} }
fmt.Printf("Import done in %v.\n\n", time.Since(start)) fmt.Printf("Import done in %v.\n\n", time.Since(start))
// Output pre-compaction stats mostly to see the import trashing // Output pre-compaction stats mostly to see the import trashing
@ -171,6 +181,10 @@ func importChain(ctx *cli.Context) error {
fmt.Printf("Allocations: %.3f million\n", float64(mem.Mallocs)/1000000) fmt.Printf("Allocations: %.3f million\n", float64(mem.Mallocs)/1000000)
fmt.Printf("GC pause: %v\n\n", time.Duration(mem.PauseTotalNs)) 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 // Compact the entire database to more accurately measure disk io and print the stats
start = time.Now() start = time.Now()
fmt.Println("Compacting entire database...") fmt.Println("Compacting entire database...")

View file

@ -140,6 +140,7 @@ func init() {
utils.EthStatsURLFlag, utils.EthStatsURLFlag,
utils.MetricsEnabledFlag, utils.MetricsEnabledFlag,
utils.FakePoWFlag, utils.FakePoWFlag,
utils.NoCompactionFlag,
utils.SolcPathFlag, utils.SolcPathFlag,
utils.GpoMinGasPriceFlag, utils.GpoMinGasPriceFlag,
utils.GpoMaxGasPriceFlag, utils.GpoMaxGasPriceFlag,