mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
trie: move wg.Add(1) inside the loop and defer wg.Done() at the beginning of goroutine
This commit is contained in:
parent
2e06fbd409
commit
3e0b52a44a
1 changed files with 2 additions and 2 deletions
|
|
@ -112,9 +112,10 @@ func (h *hasher) hashFullNodeChildren(n *fullNode) (collapsed *fullNode, cached
|
||||||
collapsed = n.copy()
|
collapsed = n.copy()
|
||||||
if h.parallel {
|
if h.parallel {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(16)
|
|
||||||
for i := 0; i < 16; i++ {
|
for i := 0; i < 16; i++ {
|
||||||
|
wg.Add(1)
|
||||||
go func(i int) {
|
go func(i int) {
|
||||||
|
defer wg.Done()
|
||||||
hasher := newHasher(false)
|
hasher := newHasher(false)
|
||||||
if child := n.Children[i]; child != nil {
|
if child := n.Children[i]; child != nil {
|
||||||
collapsed.Children[i], cached.Children[i] = hasher.hash(child, false)
|
collapsed.Children[i], cached.Children[i] = hasher.hash(child, false)
|
||||||
|
|
@ -122,7 +123,6 @@ func (h *hasher) hashFullNodeChildren(n *fullNode) (collapsed *fullNode, cached
|
||||||
collapsed.Children[i] = nilValueNode
|
collapsed.Children[i] = nilValueNode
|
||||||
}
|
}
|
||||||
returnHasherToPool(hasher)
|
returnHasherToPool(hasher)
|
||||||
wg.Done()
|
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue