@@ -44,7 +44,8 @@ func newCommitter(owner common.Hash, collectLeaf bool) *committer {
4444 }
4545}
4646
47- // Commit collapses a node down into a hash node and inserts it into the database
47+ // Commit collapses a node down into a hash node and returns it along with
48+ // the modified nodeset.
4849func (c * committer ) Commit (n node ) (hashNode , * NodeSet , error ) {
4950 h , err := c .commit (nil , n )
5051 if err != nil {
@@ -53,7 +54,7 @@ func (c *committer) Commit(n node) (hashNode, *NodeSet, error) {
5354 return h .(hashNode ), c .nodes , nil
5455}
5556
56- // commit collapses a node down into a hash node and inserts it into the database
57+ // commit collapses a node down into a hash node and returns it.
5758func (c * committer ) commit (path []byte , n node ) (node , error ) {
5859 // if this path is clean, use available cached data
5960 hash , dirty := n .cache ()
@@ -75,7 +76,8 @@ func (c *committer) commit(path []byte, n node) (node, error) {
7576 }
7677 collapsed .Val = childV
7778 }
78- // The key needs to be copied, since we're delivering it to database
79+ // The key needs to be copied, since we're adding it to the
80+ // modified nodeset.
7981 collapsed .Key = hexToCompact (cn .Key )
8082 hashedNode := c .store (path , collapsed )
8183 if hn , ok := hashedNode .(hashNode ); ok {
@@ -134,17 +136,16 @@ func (c *committer) commitChildren(path []byte, n *fullNode) ([17]node, error) {
134136 return children , nil
135137}
136138
137- // store hashes the node n and if we have a storage layer specified, it writes
138- // the key/value pair to it and tracks any node->child references as well as any
139- // node->external trie references.
139+ // store hashes the node n and adds it to the modified nodeset. If leaf collection
140+ // is enabled, leaf nodes will be tracked in the modified nodeset as well.
140141func (c * committer ) store (path []byte , n node ) node {
141142 // Larger nodes are replaced by their hash and stored in the database.
142143 var hash , _ = n .cache ()
143144
144145 // This was not generated - must be a small node stored in the parent.
145146 // In theory, we should check if the node is leaf here (embedded node
146- // usually is leaf node). But small value(less than 32bytes) is not
147- // our target(leaves in account trie only).
147+ // usually is leaf node). But small value (less than 32bytes) is not
148+ // our target (leaves in account trie only).
148149 if hash == nil {
149150 return n
150151 }
0 commit comments