mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
trie: minor polish
This commit is contained in:
parent
3aa1cf71f7
commit
05326f055b
3 changed files with 6 additions and 5 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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...)
|
||||
|
|
|
|||
Loading…
Reference in a new issue