aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghav Sood <raghavsood@gmail.com>2018-07-26 19:26:24 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-07-26 19:26:24 +0800
commit11a402f747956816bbf49e5f4b7fb5deeecd3017 (patch)
treebffb2615f85fb67475f3f01fff64467d78647c87
parent021d6fbbbbdfe295dbb3619f8ec3fc8662c1e26a (diff)
downloaddexon-11a402f747956816bbf49e5f4b7fb5deeecd3017.tar
dexon-11a402f747956816bbf49e5f4b7fb5deeecd3017.tar.gz
dexon-11a402f747956816bbf49e5f4b7fb5deeecd3017.tar.bz2
dexon-11a402f747956816bbf49e5f4b7fb5deeecd3017.tar.lz
dexon-11a402f747956816bbf49e5f4b7fb5deeecd3017.tar.xz
dexon-11a402f747956816bbf49e5f4b7fb5deeecd3017.tar.zst
dexon-11a402f747956816bbf49e5f4b7fb5deeecd3017.zip
core: report progress on log chain exports (#17066)
* core/blockchain: export progress * core: polish up chain export progress report a bit
-rw-r--r--cmd/geth/chaincmd.go3
-rw-r--r--core/blockchain.go10
2 files changed, 9 insertions, 4 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index d3086921b..ff27a9dfb 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 2f1e78423..7b7e4e79a 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -450,15 +450,19 @@ func (bc *BlockChain) ExportN(w io.Writer, first uint64, last uint64) error {
}
log.Info("Exporting batch of blocks", "count", last-first+1)
+ start, reported := time.Now(), time.Now()
for nr := first; nr <= last; nr++ {
block := bc.GetBlockByNumber(nr)
if block == nil {
return fmt.Errorf("export failed on #%d: not found", nr)
}
-
if err := block.EncodeRLP(w); err != nil {
return err
}
+ if time.Since(reported) >= statsReportLimit {
+ log.Info("Exporting blocks", "exported", block.NumberU64()-first, "elapsed", common.PrettyDuration(time.Since(start)))
+ reported = time.Now()
+ }
}
return nil
@@ -1203,8 +1207,8 @@ type insertStats struct {
startTime mclock.AbsTime
}
-// statsReportLimit is the time limit during import after which we always print
-// out progress. This avoids the user wondering what's going on.
+// 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
// report prints statistics if some number of blocks have been processed