diff --git a/swarm/storage/ldbstore.go b/swarm/storage/ldbstore.go index ae5caf700d..8c18e88a12 100644 --- a/swarm/storage/ldbstore.go +++ b/swarm/storage/ldbstore.go @@ -562,9 +562,10 @@ func (s *LDBStore) writeBatches() { log.Error(fmt.Sprintf("spawn batch write (%d entries): %v", b.Len(), err)) } close(c) - if e >= s.capacity { + for e > s.capacity { log.Info("collecting garbage", "entryCnt", e, "capacity", s.capacity) s.collectGarbage(gcArrayFreeRatio) + e = s.entryCnt } s.lock.Unlock() } diff --git a/swarm/storage/memstore_lrucache.go b/swarm/storage/memstore_lrucache.go index 7e93a5a8e7..a66dcd0c22 100644 --- a/swarm/storage/memstore_lrucache.go +++ b/swarm/storage/memstore_lrucache.go @@ -31,6 +31,12 @@ type MemStore struct { disabled bool } +//NewMemStore is instantiating a MemStore cache. We are keeping a record of all outgoing requests for chunks, that +//should later be delivered by peer nodes, in the `requests` LRU cache. We are also keeping all frequently requested +//chunks in the `cache` LRU cache. +// +//`requests` LRU cache capacity should ideally never be reached, this is why for the time being it should be initialised +//with the same value as the LDBStore capacity. func NewMemStore(params *StoreParams, _ *LDBStore) (m *MemStore) { if params.CacheCapacity == 0 { return &MemStore{