mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 19:30:44 +00:00
trie: avoid spawning goroutines for empty children (#32220)
This commit is contained in:
parent
e94123acc2
commit
61d7279e1f
1 changed files with 10 additions and 10 deletions
|
|
@ -105,18 +105,18 @@ func (h *hasher) hashFullNodeChildren(n *fullNode) *fullNode {
|
||||||
var children [17]node
|
var children [17]node
|
||||||
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++ {
|
||||||
|
if child := n.Children[i]; child != nil {
|
||||||
|
wg.Add(1)
|
||||||
go func(i int) {
|
go func(i int) {
|
||||||
hasher := newHasher(false)
|
hasher := newHasher(false)
|
||||||
if child := n.Children[i]; child != nil {
|
|
||||||
children[i] = hasher.hash(child, false)
|
children[i] = hasher.hash(child, false)
|
||||||
} else {
|
|
||||||
children[i] = nilValueNode
|
|
||||||
}
|
|
||||||
returnHasherToPool(hasher)
|
returnHasherToPool(hasher)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(i)
|
}(i)
|
||||||
|
} else {
|
||||||
|
children[i] = nilValueNode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue