diff --git a/swarm/storage/localstore/gc.go b/swarm/storage/localstore/gc.go index 8795a11bbb..8958cf7f62 100644 --- a/swarm/storage/localstore/gc.go +++ b/swarm/storage/localstore/gc.go @@ -78,7 +78,7 @@ func (db *DB) collectGarbage() (collectedCount int64, done bool, err error) { target := db.gcTarget() done = true - err = db.gcIndex.IterateAll(func(item shed.Item) (stop bool, err error) { + err = db.gcIndex.Iterate(func(item shed.Item) (stop bool, err error) { gcSize := atomic.LoadInt64(&db.gcSize) if gcSize-collectedCount <= target { return true, nil @@ -96,7 +96,7 @@ func (db *DB) collectGarbage() (collectedCount int64, done bool, err error) { return true, nil } return false, nil - }) + }, nil) if err != nil { return 0, false, err } @@ -183,7 +183,7 @@ func (db *DB) writeGCSize(gcSize int64) (err error) { // use only one iterator as it acquires its snapshot // not to remove hashes from index that are added // after stored gc size is written - err = db.gcUncountedHashesIndex.IterateAll(func(item shed.Item) (stop bool, err error) { + err = db.gcUncountedHashesIndex.Iterate(func(item shed.Item) (stop bool, err error) { db.gcUncountedHashesIndex.DeleteInBatch(batch, item) batchSize++ if batchSize >= maxBatchSize { @@ -195,7 +195,7 @@ func (db *DB) writeGCSize(gcSize int64) (err error) { batchSize = 0 } return false, nil - }) + }, nil) if err != nil { return err } diff --git a/swarm/storage/localstore/localstore_test.go b/swarm/storage/localstore/localstore_test.go index 08d15c46f9..cd2812a138 100644 --- a/swarm/storage/localstore/localstore_test.go +++ b/swarm/storage/localstore/localstore_test.go @@ -381,10 +381,13 @@ func newGCIndexTest(db *DB, chunk storage.Chunk, storeTimestamp, accessTimestamp func newItemsCountTest(i shed.Index, want int) func(t *testing.T) { return func(t *testing.T) { var c int - i.IterateAll(func(item shed.Item) (stop bool, err error) { + err := i.Iterate(func(item shed.Item) (stop bool, err error) { c++ return - }) + }, nil) + if err != nil { + t.Fatal(err) + } if c != want { t.Errorf("got %v items in index, want %v", c, want) } @@ -396,10 +399,13 @@ func newItemsCountTest(i shed.Index, want int) func(t *testing.T) { func newIndexGCSizeTest(db *DB) func(t *testing.T) { return func(t *testing.T) { var want int64 - db.gcIndex.IterateAll(func(item shed.Item) (stop bool, err error) { + err := db.gcIndex.Iterate(func(item shed.Item) (stop bool, err error) { want++ return - }) + }, nil) + if err != nil { + t.Fatal(err) + } got := atomic.LoadInt64(&db.gcSize) if got != want { t.Errorf("got gc size %v, want %v", got, want) @@ -424,7 +430,7 @@ func testItemsOrder(t *testing.T, i shed.Index, chunks []testIndexChunk, sortFun } var cursor int - err := i.IterateAll(func(item shed.Item) (stop bool, err error) { + err := i.Iterate(func(item shed.Item) (stop bool, err error) { want := chunks[cursor].Address() got := item.Address if !bytes.Equal(got, want) { @@ -432,7 +438,7 @@ func testItemsOrder(t *testing.T, i shed.Index, chunks []testIndexChunk, sortFun } cursor++ return false, nil - }) + }, nil) if err != nil { t.Fatal(err) }