core/state/snapshot: polishes

This commit is contained in:
Martin Holst Swende 2024-11-14 15:42:51 +01:00
parent 5fcf093668
commit 1b0705e2f5
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
2 changed files with 3 additions and 6 deletions

View file

@ -118,14 +118,13 @@ func (dl *diffLayer) initBinaryStorageIterator(account, seek common.Hash) Iterat
// becomes stale and garbage collected). // becomes stale and garbage collected).
func (it *binaryIterator) Next() bool { func (it *binaryIterator) Next() bool {
for { for {
ok := it.next() if !it.next() {
if !ok { return false
return ok
} }
if len(it.Account()) == 0 && len(it.Slot()) == 0 { if len(it.Account()) == 0 && len(it.Slot()) == 0 {
continue continue
} }
return ok return true
} }
} }

View file

@ -567,7 +567,6 @@ func TestAccountIteratorFlattening(t *testing.T) {
t.Run("binary", func(t *testing.T) { t.Run("binary", func(t *testing.T) {
testAccountIteratorFlattening(t, func(snaps *Tree, root, seek common.Hash) AccountIterator { testAccountIteratorFlattening(t, func(snaps *Tree, root, seek common.Hash) AccountIterator {
return snaps.layers[root].(*diffLayer).newBinaryAccountIterator(seek) return snaps.layers[root].(*diffLayer).newBinaryAccountIterator(seek)
}) })
}) })
} }
@ -769,7 +768,6 @@ func TestAccountIteratorDeletions(t *testing.T) {
t.Run("binary", func(t *testing.T) { t.Run("binary", func(t *testing.T) {
testAccountIteratorDeletions(t, func(snaps *Tree, root, seek common.Hash) AccountIterator { testAccountIteratorDeletions(t, func(snaps *Tree, root, seek common.Hash) AccountIterator {
return snaps.layers[root].(*diffLayer).newBinaryAccountIterator(seek) return snaps.layers[root].(*diffLayer).newBinaryAccountIterator(seek)
}) })
}) })
} }