mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
swarm/storage: fix garbage collection to run until we reach capacity
This commit is contained in:
parent
b11804c2bc
commit
25cd805bea
2 changed files with 8 additions and 1 deletions
|
|
@ -562,9 +562,10 @@ func (s *LDBStore) writeBatches() {
|
||||||
log.Error(fmt.Sprintf("spawn batch write (%d entries): %v", b.Len(), err))
|
log.Error(fmt.Sprintf("spawn batch write (%d entries): %v", b.Len(), err))
|
||||||
}
|
}
|
||||||
close(c)
|
close(c)
|
||||||
if e >= s.capacity {
|
for e > s.capacity {
|
||||||
log.Info("collecting garbage", "entryCnt", e, "capacity", s.capacity)
|
log.Info("collecting garbage", "entryCnt", e, "capacity", s.capacity)
|
||||||
s.collectGarbage(gcArrayFreeRatio)
|
s.collectGarbage(gcArrayFreeRatio)
|
||||||
|
e = s.entryCnt
|
||||||
}
|
}
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,12 @@ type MemStore struct {
|
||||||
disabled bool
|
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) {
|
func NewMemStore(params *StoreParams, _ *LDBStore) (m *MemStore) {
|
||||||
if params.CacheCapacity == 0 {
|
if params.CacheCapacity == 0 {
|
||||||
return &MemStore{
|
return &MemStore{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue