core/state/snapshot: faster account iteration, CLI integration
This commit is contained in:
committed by
Péter Szilágyi
parent
6ddb92a089
commit
19099421dc
@ -63,8 +63,9 @@ func (its weightedAccountIterators) Swap(i, j int) {
|
||||
// fastAccountIterator is a more optimized multi-layer iterator which maintains a
|
||||
// direct mapping of all iterators leading down to the bottom layer.
|
||||
type fastAccountIterator struct {
|
||||
tree *Tree // Snapshot tree to reinitialize stale sub-iterators with
|
||||
root common.Hash // Root hash to reinitialize stale sub-iterators through
|
||||
tree *Tree // Snapshot tree to reinitialize stale sub-iterators with
|
||||
root common.Hash // Root hash to reinitialize stale sub-iterators through
|
||||
curAccount []byte
|
||||
|
||||
iterators weightedAccountIterators
|
||||
initiated bool
|
||||
@ -160,9 +161,20 @@ func (fi *fastAccountIterator) Next() bool {
|
||||
// Don't forward first time -- we had to 'Next' once in order to
|
||||
// do the sorting already
|
||||
fi.initiated = true
|
||||
return true
|
||||
fi.curAccount = fi.iterators[0].it.Account()
|
||||
if innerErr := fi.iterators[0].it.Error(); innerErr != nil {
|
||||
fi.fail = innerErr
|
||||
}
|
||||
return fi.Error() == nil
|
||||
}
|
||||
return fi.next(0)
|
||||
if !fi.next(0) {
|
||||
return false
|
||||
}
|
||||
fi.curAccount = fi.iterators[0].it.Account()
|
||||
if innerErr := fi.iterators[0].it.Error(); innerErr != nil {
|
||||
fi.fail = innerErr
|
||||
}
|
||||
return fi.Error() == nil
|
||||
}
|
||||
|
||||
// next handles the next operation internally and should be invoked when we know
|
||||
@ -259,7 +271,7 @@ func (fi *fastAccountIterator) Hash() common.Hash {
|
||||
|
||||
// Account returns the current key
|
||||
func (fi *fastAccountIterator) Account() []byte {
|
||||
return fi.iterators[0].it.Account()
|
||||
return fi.curAccount
|
||||
}
|
||||
|
||||
// Release iterates over all the remaining live layer iterators and releases each
|
||||
|
Reference in New Issue
Block a user