swarm/storage: Delete gc items direct in loop

This commit is contained in:
lash 2018-10-05 09:16:48 +02:00
parent 7c33de3ebd
commit cd126c2a58

View file

@ -287,7 +287,6 @@ func (s *LDBStore) collectGarbage(ratio float32) {
it := s.db.NewIterator() it := s.db.NewIterator()
defer it.Release() defer it.Release()
garbage := []*gcItem{}
var gcnt uint64 var gcnt uint64
maxGcnt := s.getGCCount() maxGcnt := s.getGCCount()
@ -306,20 +305,9 @@ func (s *LDBStore) collectGarbage(ratio float32) {
log.Trace("parse gc", "index", index, "po", po, "hash", hash) log.Trace("parse gc", "index", index, "po", po, "hash", hash)
gci := &gcItem{ s.delete(index, keyIdx, po)
idxKey: keyIdx,
idx: index,
value: index.Access, // the smaller, the more likely to be gc'd. see sort comparator below.
po: po,
}
garbage = append(garbage, gci)
gcnt++ gcnt++
} }
for _, garbageItem := range garbage {
s.delete(garbageItem.idx, garbageItem.idxKey, garbageItem.po)
}
} }
// Export writes all chunks from the store to a tar archive, returning the // Export writes all chunks from the store to a tar archive, returning the