Skip to content

Commit

Permalink
trie: address comments from martin
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Dec 20, 2024
1 parent 04eb383 commit 9156cec
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions trie/hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func returnHasherToPool(h *hasher) {
hasherPool.Put(h)
}

// hash collapses a node down into a hash node, also returning a copy of the
// original node initialized with the computed hash to replace the original one.
// hash collapses a node down into a hash node.
func (h *hasher) hash(n node, force bool) node {
// Return the cached hash if it's available
if hash, _ := n.cache(); hash != nil {
Expand Down Expand Up @@ -86,8 +85,8 @@ func (h *hasher) hash(n node, force bool) node {
}
}

// hashShortNodeChildren collapses the short node. The returned collapsed node
// holds a live reference to the Key, and must not be modified.
// hashShortNodeChildren returns a copy of the supplied shortNode, with its child
// being replaced by either the hash or an embedded node if the child is small.
func (h *hasher) hashShortNodeChildren(n *shortNode) *shortNode {
var collapsed shortNode
collapsed.Key = hexToCompact(n.Key)
Expand All @@ -100,6 +99,8 @@ func (h *hasher) hashShortNodeChildren(n *shortNode) *shortNode {
return &collapsed
}

// 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
if h.parallel {
Expand Down

0 comments on commit 9156cec

Please sign in to comment.