Skip to content

Commit

Permalink
fix: progress display error
Browse files Browse the repository at this point in the history
  • Loading branch information
fynnss committed Sep 21, 2023
1 parent 82fe65e commit ac1779a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions trie/hash2path.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func (h2p *Hash2Path) Run() {
h2p.ConcurrentTraversal(h2p.trie, h2p.root, []byte{})
h2p.wg.Wait()

fmt.Println("hash2Path run finished.")
fmt.Printf("Total complete: %v, go routines Num: %v, h2p concurrentQueue: %v\n", h2p.totalNum, runtime.NumGoroutine(), len(h2p.concurrentQueue))

rawdb.WritePersistentStateID(h2p.db.DiskDB(), h2p.blocknum)
rawdb.WriteStateID(h2p.db.DiskDB(), h2p.stateRootHash, h2p.blocknum)
}
Expand All @@ -94,15 +95,11 @@ func (h2p *Hash2Path) SubConcurrentTraversal(theTrie *Trie, theNode node, path [
h2p.ConcurrentTraversal(theTrie, theNode, path)
<-h2p.concurrentQueue
h2p.wg.Done()

}

func (h2p *Hash2Path) ConcurrentTraversal(theTrie *Trie, theNode node, path []byte) {
// print process progress
total_num := atomic.AddUint64(&h2p.totalNum, 1)
if total_num%100000 == 0 {
fmt.Printf("Complete progress: %v, go routines Num: %v, h2p concurrentQueue: %v\n", total_num, runtime.NumGoroutine(), len(h2p.concurrentQueue))
}

total_num := uint64(0)
// nil node
if theNode == nil {
return
Expand All @@ -116,6 +113,7 @@ func (h2p *Hash2Path) ConcurrentTraversal(theTrie *Trie, theNode node, path []by
h2p.writeNode(path, trienode.New(common.BytesToHash(hash), nodeToBytes(collapsed)), theTrie.owner)

h2p.ConcurrentTraversal(theTrie, current.Val, append(path, current.Key...))

case *fullNode:
// copy from trie/Committer (*committer).commit
collapsed := current.copy()
Expand Down Expand Up @@ -144,6 +142,11 @@ func (h2p *Hash2Path) ConcurrentTraversal(theTrie *Trie, theNode node, path []by
return
}
h2p.ConcurrentTraversal(theTrie, n, path)
total_num = atomic.AddUint64(&h2p.totalNum, 1)
if total_num%100000 == 0 {
fmt.Printf("Complete progress: %v, go routines Num: %v, h2p concurrentQueue: %v\n", total_num, runtime.NumGoroutine(), len(h2p.concurrentQueue))
}

return
case valueNode:
if !hasTerm(path) {
Expand Down

0 comments on commit ac1779a

Please sign in to comment.