diff --git a/trie/committer.go b/trie/committer.go index ca4847df5b..6c4374ccfd 100644 --- a/trie/committer.go +++ b/trie/committer.go @@ -120,9 +120,8 @@ func (c *committer) commitChildren(path []byte, n *fullNode, parallel bool) [17] go func(index int) { p := append(path, byte(index)) childSet := trienode.NewNodeSet(c.nodes.Owner) - childComitter := newCommitter(childSet, c.tracer, c.collectLeaf) - h := childComitter.commit(p, child, false) - children[index] = h + childCommitter := newCommitter(childSet, c.tracer, c.collectLeaf) + children[index] = childCommitter.commit(p, child, false) nodesMu.Lock() c.nodes.MergeSet(childSet) nodesMu.Unlock() diff --git a/trie/trie.go b/trie/trie.go index de871a946e..372684683c 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -48,6 +48,7 @@ type Trie struct { // hashing operation. This number will not directly map to the number of // actually unhashed nodes. unhashed int + // uncommitted is the number of updates since last commit. uncommitted int diff --git a/trie/trienode/node.go b/trie/trienode/node.go index af04fbf15e..7debe6ecbc 100644 --- a/trie/trienode/node.go +++ b/trie/trienode/node.go @@ -100,8 +100,8 @@ func (set *NodeSet) AddNode(path []byte, n *Node) { set.Nodes[string(path)] = n } -// MergeSet merges this 'set' with 'other'. It assumes that the sets are disjoint, and -// thus does not deduplicate data (count deletes, dedup leaves etc). +// MergeSet merges this 'set' with 'other'. It assumes that the sets are disjoint, +// and thus does not deduplicate data (count deletes, dedup leaves etc). func (set *NodeSet) MergeSet(other *NodeSet) error { if set.Owner != other.Owner { return fmt.Errorf("nodesets belong to different owner are not mergeable %x-%x", set.Owner, other.Owner) @@ -110,6 +110,7 @@ func (set *NodeSet) MergeSet(other *NodeSet) error { set.deletes += other.deletes set.updates += other.updates + // Since we assume the sets are disjoint, we can safely append leaves // like this without deduplication. set.Leaves = append(set.Leaves, other.Leaves...)