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) {
|
go func(index int) {
|
||||||
p := append(path, byte(index))
|
p := append(path, byte(index))
|
||||||
childSet := trienode.NewNodeSet(c.nodes.Owner)
|
childSet := trienode.NewNodeSet(c.nodes.Owner)
|
||||||
childComitter := newCommitter(childSet, c.tracer, c.collectLeaf)
|
childCommitter := newCommitter(childSet, c.tracer, c.collectLeaf)
|
||||||
h := childComitter.commit(p, child, false)
|
children[index] = childCommitter.commit(p, child, false)
|
||||||
children[index] = h
|
|
||||||
nodesMu.Lock()
|
nodesMu.Lock()
|
||||||
c.nodes.MergeSet(childSet)
|
c.nodes.MergeSet(childSet)
|
||||||
nodesMu.Unlock()
|
nodesMu.Unlock()
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ type Trie struct {
|
||||||
// hashing operation. This number will not directly map to the number of
|
// hashing operation. This number will not directly map to the number of
|
||||||
// actually unhashed nodes.
|
// actually unhashed nodes.
|
||||||
unhashed int
|
unhashed int
|
||||||
|
|
||||||
// uncommitted is the number of updates since last commit.
|
// uncommitted is the number of updates since last commit.
|
||||||
uncommitted int
|
uncommitted int
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,8 @@ func (set *NodeSet) AddNode(path []byte, n *Node) {
|
||||||
set.Nodes[string(path)] = n
|
set.Nodes[string(path)] = n
|
||||||
}
|
}
|
||||||
|
|
||||||
// MergeSet merges this 'set' with 'other'. It assumes that the sets are disjoint, and
|
// MergeSet merges this 'set' with 'other'. It assumes that the sets are disjoint,
|
||||||
// thus does not deduplicate data (count deletes, dedup leaves etc).
|
// and thus does not deduplicate data (count deletes, dedup leaves etc).
|
||||||
func (set *NodeSet) MergeSet(other *NodeSet) error {
|
func (set *NodeSet) MergeSet(other *NodeSet) error {
|
||||||
if set.Owner != other.Owner {
|
if set.Owner != other.Owner {
|
||||||
return fmt.Errorf("nodesets belong to different owner are not mergeable %x-%x", 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.deletes += other.deletes
|
||||||
set.updates += other.updates
|
set.updates += other.updates
|
||||||
|
|
||||||
// Since we assume the sets are disjoint, we can safely append leaves
|
// Since we assume the sets are disjoint, we can safely append leaves
|
||||||
// like this without deduplication.
|
// like this without deduplication.
|
||||||
set.Leaves = append(set.Leaves, other.Leaves...)
|
set.Leaves = append(set.Leaves, other.Leaves...)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue