diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index d3086921b9..ff27a9dfb4 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -94,7 +94,8 @@ processing will proceed even if an individual RLP-file import failure occurs.`, Requires a first argument of the file to write to. Optional second and third arguments control the first and last block to write. In this mode, the file will be appended -if already existing.`, +if already existing. If the file ends with .gz, the output will +be gzipped.`, } importPreimagesCommand = cli.Command{ Action: utils.MigrateFlags(importPreimages), diff --git a/core/blockchain.go b/core/blockchain.go index 0b50e3f377..d0c2c7bd3c 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -448,10 +448,23 @@ func (bc *BlockChain) ExportN(w io.Writer, first uint64, last uint64) error { if first > last { return fmt.Errorf("export failed: first (%d) is greater than last (%d)", first, last) } - log.Info("Exporting batch of blocks", "count", last-first+1) + batchSize := last - first + 1 + log.Info("Exporting batch of blocks", "count", batchSize) + exportTimeElapsed := mclock.Now() for nr := first; nr <= last; nr++ { block := bc.GetBlockByNumber(nr) + var ( + now = mclock.Now() + elapsed = time.Duration(now) - time.Duration(exportTimeElapsed) + ) + + if elapsed >= statsReportLimit { + exportedBlocks := block.NumberU64() - first + log.Info("Exporting blocks", "exported", exportedBlocks, "elapsed", common.PrettyDuration(elapsed)) + exportTimeElapsed = mclock.Now() + } + if block == nil { return fmt.Errorf("export failed on #%d: not found", nr) } @@ -1203,7 +1216,7 @@ type insertStats struct { startTime mclock.AbsTime } -// statsReportLimit is the time limit during import after which we always print +// statsReportLimit is the time limit during import and export after which we always print // out progress. This avoids the user wondering what's going on. const statsReportLimit = 8 * time.Second