mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
fix: capture child node as goroutine parameter to avoid closure bug, add clarifying comments about fullNode Children structure
This commit is contained in:
parent
4bc5c5c374
commit
56325ab7c5
1 changed files with 5 additions and 3 deletions
|
|
@ -98,7 +98,9 @@ func (c *committer) commitChildren(path []byte, n *fullNode, parallel bool) {
|
||||||
}
|
}
|
||||||
// If it's the hashed child, save the hash value directly.
|
// If it's the hashed child, save the hash value directly.
|
||||||
// Note: it's impossible that the child in range [0, 15]
|
// Note: it's impossible that the child in range [0, 15]
|
||||||
// is a valueNode.
|
// is a valueNode. Values are only stored in Children[16]
|
||||||
|
// (the 17th slot) when a key terminates at a branch node.
|
||||||
|
// Children[0-15] are structural slots for hex digit routing.
|
||||||
if _, ok := child.(hashNode); ok {
|
if _, ok := child.(hashNode); ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -109,14 +111,14 @@ func (c *committer) commitChildren(path []byte, n *fullNode, parallel bool) {
|
||||||
n.Children[i] = c.commit(append(path, byte(i)), child, false)
|
n.Children[i] = c.commit(append(path, byte(i)), child, false)
|
||||||
} else {
|
} else {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(index int) {
|
go func(index int, child node) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
subset := trienode.NewNodeSet(c.nodes.Owner)
|
subset := trienode.NewNodeSet(c.nodes.Owner)
|
||||||
subCom := newCommitter(subset, c.tracer, c.collectLeaf)
|
subCom := newCommitter(subset, c.tracer, c.collectLeaf)
|
||||||
n.Children[index] = subCom.commit(append(path, byte(index)), child, false)
|
n.Children[index] = subCom.commit(append(path, byte(index)), child, false)
|
||||||
subsets[index] = subset
|
subsets[index] = subset
|
||||||
}(i)
|
}(i, child)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if parallel {
|
if parallel {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue