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 d21a74a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions trie/hash2path.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,7 @@ func (h2p *Hash2Path) SubConcurrentTraversal(theTrie *Trie, theNode node, path [
}

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 +111,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 +140,7 @@ func (h2p *Hash2Path) ConcurrentTraversal(theTrie *Trie, theNode node, path []by
return
}
h2p.ConcurrentTraversal(theTrie, n, path)
total_num = atomic.AddUint64(&h2p.totalNum, 1)
return
case valueNode:
if !hasTerm(path) {
Expand Down Expand Up @@ -172,6 +169,9 @@ func (h2p *Hash2Path) ConcurrentTraversal(theTrie *Trie, theNode node, path []by
default:
panic(errors.New("Invalid node type to traverse."))
}
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))
}
}

// copy from trie/Commiter (*committer).commit
Expand Down

0 comments on commit d21a74a

Please sign in to comment.