Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions trie/hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ func (h *hasher) hashShortNodeChildren(n *shortNode) *shortNode {
// hashFullNodeChildren returns a copy of the supplied fullNode, with its child
// being replaced by either the hash or an embedded node if the child is small.
func (h *hasher) hashFullNodeChildren(n *fullNode) *fullNode {
var children [17]node
fullNode := fullNode{flags: nodeFlag{}}
if h.parallel {
var wg sync.WaitGroup
wg.Add(16)
for i := 0; i < 16; i++ {
go func(i int) {
hasher := newHasher(false)
if child := n.Children[i]; child != nil {
children[i] = hasher.hash(child, false)
fullNode.Children[i] = hasher.hash(child, false)
} else {
children[i] = nilValueNode
fullNode.Children[i] = nilValueNode
}
returnHasherToPool(hasher)
wg.Done()
Expand All @@ -122,16 +122,16 @@ func (h *hasher) hashFullNodeChildren(n *fullNode) *fullNode {
} else {
for i := 0; i < 16; i++ {
if child := n.Children[i]; child != nil {
children[i] = h.hash(child, false)
fullNode.Children[i] = h.hash(child, false)
} else {
children[i] = nilValueNode
fullNode.Children[i] = nilValueNode
}
}
}
if n.Children[16] != nil {
children[16] = n.Children[16]
fullNode.Children[16] = n.Children[16]
}
return &fullNode{flags: nodeFlag{}, Children: children}
return &fullNode
}

// shortNodeToHash computes the hash of the given shortNode. The shortNode must
Expand Down