mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 21:26:42 +00:00
timer print
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
1b0289c6c6
commit
f10e78bece
1 changed files with 18 additions and 0 deletions
|
|
@ -541,6 +541,22 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte, workers int)
|
|||
var eg errgroup.Group
|
||||
eg.SetLimit(workers)
|
||||
|
||||
// Start progress reporting goroutine
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
ticker := time.NewTicker(8 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
log.Info("Inspecting database progress", "count", totalCount.Load(), "size", common.StorageSize(totalSize.Load()), "elapsed", common.PrettyDuration(time.Since(start)))
|
||||
case <-done:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
log.Info("Starting parallel database inspection", "workers", workers)
|
||||
|
||||
for i := 0; i < 256; i++ {
|
||||
|
|
@ -549,8 +565,10 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte, workers int)
|
|||
}
|
||||
|
||||
if err := eg.Wait(); err != nil {
|
||||
close(done)
|
||||
return err
|
||||
}
|
||||
close(done)
|
||||
|
||||
// Display the database statistic of key-value store.
|
||||
stats := [][]string{
|
||||
|
|
|
|||
Loading…
Reference in a new issue