Skip to content

Commit 1bae9a6

Browse files
committed
all: rename Iteratee.NewIteratorWith -> NewIterator
1 parent c138efe commit 1bae9a6

21 files changed

+48
-70
lines changed

cmd/utils/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func ExportPreimages(db ethdb.Database, fn string) error {
301301
defer writer.(*gzip.Writer).Close()
302302
}
303303
// Iterate over the preimages and export them
304-
it := db.NewIteratorWith([]byte("secure-key-"), nil)
304+
it := db.NewIterator([]byte("secure-key-"), nil)
305305
defer it.Release()
306306

307307
for it.Next() {

core/rawdb/accessors_chain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func ReadAllHashes(db ethdb.Iteratee, number uint64) []common.Hash {
6969
prefix := headerKeyPrefix(number)
7070

7171
hashes := make([]common.Hash, 0, 1)
72-
it := db.NewIteratorWith(prefix, nil)
72+
it := db.NewIterator(prefix, nil)
7373
defer it.Release()
7474

7575
for it.Next() {

core/rawdb/accessors_snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func DeleteStorageSnapshot(db ethdb.KeyValueWriter, accountHash, storageHash com
9393
// IterateStorageSnapshots returns an iterator for walking the entire storage
9494
// space of a specific account.
9595
func IterateStorageSnapshots(db ethdb.Iteratee, accountHash common.Hash) ethdb.Iterator {
96-
return db.NewIteratorWith(storageSnapshotsKey(accountHash), nil)
96+
return db.NewIterator(storageSnapshotsKey(accountHash), nil)
9797
}
9898

9999
// ReadSnapshotJournal retrieves the serialized in-memory diff layers saved at

core/rawdb/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func NewLevelDBDatabaseWithFreezer(file string, cache int, handles int, freezer
221221
// InspectDatabase traverses the entire database and checks the size
222222
// of all different categories of data.
223223
func InspectDatabase(db ethdb.Database) error {
224-
it := db.NewIterator()
224+
it := db.NewIterator(nil, nil)
225225
defer it.Release()
226226

227227
var (

core/rawdb/table.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,12 @@ func (t *table) Delete(key []byte) error {
103103
return t.db.Delete(append([]byte(t.prefix), key...))
104104
}
105105

106-
// NewIterator creates a binary-alphabetical iterator over the entire keyspace
107-
// contained within the database.
108-
func (t *table) NewIterator() ethdb.Iterator {
109-
return t.NewIteratorWith(nil, nil)
110-
}
111-
112-
// NewIteratorWith creates a binary-alphabetical iterator over a subset
106+
// NewIterator creates a binary-alphabetical iterator over a subset
113107
// of database content with a particular key prefix, starting at a particular
114108
// initial key (or after, if it does not exist).
115-
func (t *table) NewIteratorWith(prefix []byte, start []byte) ethdb.Iterator {
109+
func (t *table) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
116110
innerPrefix := append([]byte(t.prefix), prefix...)
117-
iter := t.db.NewIteratorWith(innerPrefix, start)
111+
iter := t.db.NewIterator(innerPrefix, start)
118112
return &tableIterator{
119113
iter: iter,
120114
prefix: t.prefix,

core/rawdb/table_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ func testTableDatabase(t *testing.T, prefix string) {
117117
iter.Release()
118118
}
119119
// Test iterators
120-
check(db.NewIterator(), 6, 0)
120+
check(db.NewIterator(nil, nil), 6, 0)
121121
// Test iterators with prefix
122-
check(db.NewIteratorWith([]byte{0xff, 0xff}, nil), 3, 3)
122+
check(db.NewIterator([]byte{0xff, 0xff}, nil), 3, 3)
123123
// Test iterators with start point
124-
check(db.NewIteratorWith(nil, []byte{0xff, 0xff, 0x02}), 2, 4)
124+
check(db.NewIterator(nil, []byte{0xff, 0xff, 0x02}), 2, 4)
125125
// Test iterators with prefix and start point
126-
check(db.NewIteratorWith([]byte{0xee}, nil), 0, 0)
127-
check(db.NewIteratorWith(nil, []byte{0x00}), 6, 0)
126+
check(db.NewIterator([]byte{0xee}, nil), 0, 0)
127+
check(db.NewIterator(nil, []byte{0x00}), 6, 0)
128128
}

core/state/iterator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestNodeIteratorCoverage(t *testing.T) {
5151
t.Errorf("state entry not reported %x", hash)
5252
}
5353
}
54-
it := db.TrieDB().DiskDB().(ethdb.Database).NewIterator()
54+
it := db.TrieDB().DiskDB().(ethdb.Database).NewIterator(nil, nil)
5555
for it.Next() {
5656
key := it.Key()
5757
if bytes.HasPrefix(key, []byte("secure-key-")) {

core/state/snapshot/iterator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (dl *diskLayer) AccountIterator(seek common.Hash) AccountIterator {
151151
pos := common.TrimRightZeroes(seek[:])
152152
return &diskAccountIterator{
153153
layer: dl,
154-
it: dl.diskdb.NewIteratorWith(rawdb.SnapshotAccountPrefix, pos),
154+
it: dl.diskdb.NewIterator(rawdb.SnapshotAccountPrefix, pos),
155155
}
156156
}
157157

core/state/snapshot/wipe.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func wipeKeyRange(db ethdb.KeyValueStore, kind string, prefix []byte, keylen int
9292
// Iterate over the key-range and delete all of them
9393
start, logged := time.Now(), time.Now()
9494

95-
it := db.NewIteratorWith(prefix, nil)
95+
it := db.NewIterator(prefix, nil)
9696
for it.Next() {
9797
// Skip any keys with the correct prefix but wrong lenth (trie nodes)
9898
key := it.Key()
@@ -114,7 +114,7 @@ func wipeKeyRange(db ethdb.KeyValueStore, kind string, prefix []byte, keylen int
114114
}
115115
batch.Reset()
116116
seekPos := key[len(prefix):]
117-
it = db.NewIteratorWith(prefix, seekPos)
117+
it = db.NewIterator(prefix, seekPos)
118118

119119
if time.Since(logged) > 8*time.Second {
120120
log.Info("Deleting state snapshot leftovers", "kind", kind, "wiped", items, "elapsed", common.PrettyDuration(time.Since(start)))

core/state/snapshot/wipe_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestWipe(t *testing.T) {
6060
// Sanity check that all the keys are present
6161
var items int
6262

63-
it := db.NewIteratorWith(rawdb.SnapshotAccountPrefix, nil)
63+
it := db.NewIterator(rawdb.SnapshotAccountPrefix, nil)
6464
defer it.Release()
6565

6666
for it.Next() {
@@ -69,7 +69,7 @@ func TestWipe(t *testing.T) {
6969
items++
7070
}
7171
}
72-
it = db.NewIteratorWith(rawdb.SnapshotStoragePrefix, nil)
72+
it = db.NewIterator(rawdb.SnapshotStoragePrefix, nil)
7373
defer it.Release()
7474

7575
for it.Next() {
@@ -88,7 +88,7 @@ func TestWipe(t *testing.T) {
8888
<-wipeSnapshot(db, true)
8989

9090
// Iterate over the database end ensure no snapshot information remains
91-
it = db.NewIteratorWith(rawdb.SnapshotAccountPrefix, nil)
91+
it = db.NewIterator(rawdb.SnapshotAccountPrefix, nil)
9292
defer it.Release()
9393

9494
for it.Next() {
@@ -97,7 +97,7 @@ func TestWipe(t *testing.T) {
9797
t.Errorf("snapshot entry remained after wipe: %x", key)
9898
}
9999
}
100-
it = db.NewIteratorWith(rawdb.SnapshotStoragePrefix, nil)
100+
it = db.NewIterator(rawdb.SnapshotStoragePrefix, nil)
101101
defer it.Release()
102102

103103
for it.Next() {
@@ -112,7 +112,7 @@ func TestWipe(t *testing.T) {
112112
// Iterate over the database and ensure miscellaneous items are present
113113
items = 0
114114

115-
it = db.NewIterator()
115+
it = db.NewIterator(nil, nil)
116116
defer it.Release()
117117

118118
for it.Next() {

0 commit comments

Comments
 (0)