mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
upgrade newFastIterator
This commit is contained in:
parent
86a1f0c394
commit
517694b2a2
1 changed files with 14 additions and 7 deletions
|
|
@ -77,13 +77,21 @@ func newFastIterator(tree *Tree, root common.Hash, account common.Hash, seek com
|
||||||
if snap == nil {
|
if snap == nil {
|
||||||
return nil, fmt.Errorf("unknown snapshot: %x", root)
|
return nil, fmt.Errorf("unknown snapshot: %x", root)
|
||||||
}
|
}
|
||||||
fi := &fastIterator{
|
|
||||||
tree: tree,
|
// Get all the ancestor snaps.
|
||||||
root: root,
|
snaps := make([]snapshot, 0, 128)
|
||||||
account: accountIterator,
|
for current := snap.(snapshot); current != nil; current = current.Parent() {
|
||||||
|
snaps = append(snaps, current)
|
||||||
}
|
}
|
||||||
current := snap.(snapshot)
|
|
||||||
for depth := 0; current != nil; depth++ {
|
fi := &fastIterator{
|
||||||
|
tree: tree,
|
||||||
|
root: root,
|
||||||
|
account: accountIterator,
|
||||||
|
iterators: make([]*weightedIterator, 0, len(snaps)),
|
||||||
|
}
|
||||||
|
|
||||||
|
for depth, current := range snaps {
|
||||||
if accountIterator {
|
if accountIterator {
|
||||||
fi.iterators = append(fi.iterators, &weightedIterator{
|
fi.iterators = append(fi.iterators, &weightedIterator{
|
||||||
it: current.AccountIterator(seek),
|
it: current.AccountIterator(seek),
|
||||||
|
|
@ -103,7 +111,6 @@ func newFastIterator(tree *Tree, root common.Hash, account common.Hash, seek com
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = current.Parent()
|
|
||||||
}
|
}
|
||||||
fi.init()
|
fi.init()
|
||||||
return fi, nil
|
return fi, nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue