mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
trie: add progress indicator
This commit is contained in:
parent
6e191e7758
commit
3b8e7b6221
1 changed files with 25 additions and 0 deletions
|
|
@ -106,6 +106,27 @@ func Inspect(triedb database.NodeDatabase, root common.Hash, config *InspectConf
|
||||||
dumpFile: dumpFile,
|
dumpFile: dumpFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start progress reporter
|
||||||
|
start := time.Now()
|
||||||
|
done := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
ticker := time.NewTicker(8 * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ticker.C:
|
||||||
|
accountNodes := in.accountStat.TotalNodes()
|
||||||
|
storageRecords := atomic.LoadUint64(&in.storageRecordsWritten)
|
||||||
|
log.Info("Inspecting trie",
|
||||||
|
"accountNodes", accountNodes,
|
||||||
|
"storageRecords", storageRecords,
|
||||||
|
"elapsed", common.PrettyDuration(time.Since(start)))
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
in.recordRootSize(trie, root, in.accountStat)
|
in.recordRootSize(trie, root, in.accountStat)
|
||||||
in.inspect(trie, trie.root, 0, []byte{}, in.accountStat)
|
in.inspect(trie, trie.root, 0, []byte{}, in.accountStat)
|
||||||
|
|
||||||
|
|
@ -117,6 +138,10 @@ func Inspect(triedb database.NodeDatabase, root common.Hash, config *InspectConf
|
||||||
if err := in.closeDump(); err != nil {
|
if err := in.closeDump(); err != nil {
|
||||||
in.setError(err)
|
in.setError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stop progress reporter
|
||||||
|
close(done)
|
||||||
|
|
||||||
if err := in.getError(); err != nil {
|
if err := in.getError(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue