From fa8acc90fb44afe37e098eb3b57dcf920c1bc831 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Tue, 3 Apr 2018 16:44:34 +0200 Subject: [PATCH] swarm: cleanup --- swarm/storage/ldbstore.go | 7 --- swarm/storage/memstore_lrucache.go | 3 -- swarm/storage/memstore_map.god | 77 ------------------------------ swarm/swarm.go | 1 - 4 files changed, 88 deletions(-) delete mode 100644 swarm/storage/memstore_map.god diff --git a/swarm/storage/ldbstore.go b/swarm/storage/ldbstore.go index 90db493a64..a09834fdd7 100644 --- a/swarm/storage/ldbstore.go +++ b/swarm/storage/ldbstore.go @@ -619,10 +619,6 @@ func (s *LDBStore) writeBatches() { log.Error(fmt.Sprintf("DbStore: spawn batch write (%d chunks): %v", b.Len(), err)) } close(c) - //if e >= s.capacity { - //log.Trace(fmt.Sprintf("DbStore: collecting garbage...(%d chunks)", e)) - //s.collectGarbage(gcArrayFreeRatio) - //} } log.Trace(fmt.Sprintf("DbStore: quit batch write loop")) } @@ -762,9 +758,6 @@ func (s *LDBStore) setCapacity(c uint64) { if ratio > 1 { ratio = 1 } - //for s.entryCnt > c { - //s.collectGarbage(ratio) - //} } } diff --git a/swarm/storage/memstore_lrucache.go b/swarm/storage/memstore_lrucache.go index 0a6834a3f9..130491a19b 100644 --- a/swarm/storage/memstore_lrucache.go +++ b/swarm/storage/memstore_lrucache.go @@ -30,7 +30,6 @@ const ( ) type MemStore struct { - //cache *lru.ARCCache cache *lru.Cache disabled bool } @@ -52,7 +51,6 @@ func NewMemStore(_ *LDBStore, capacity uint) (m *MemStore) { } return &MemStore{ - //cache: lru.NewARC(capacity), cache: c, } } @@ -88,5 +86,4 @@ func (m *MemStore) setCapacity(n int) { } } -// Close memstore func (s *MemStore) Close() {} diff --git a/swarm/storage/memstore_map.god b/swarm/storage/memstore_map.god deleted file mode 100644 index c2f2855268..0000000000 --- a/swarm/storage/memstore_map.god +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -// memory storage layer for the package blockhash - -package storage - -import ( - "bytes" - "fmt" - "sync" - - "github.com/ethereum/go-ethereum/metrics" -) - -//metrics variables -var ( - memstorePutCounter = metrics.NewRegisteredCounter("storage.db.memstore.put.count", nil) - memstoreRemoveCounter = metrics.NewRegisteredCounter("storage.db.memstore.rm.count", nil) -) - -const ( - memTreeLW = 2 // log2(subtree count) of the subtrees - memTreeFLW = 14 // log2(subtree count) of the root layer - dbForceUpdateAccessCnt = 1000 - defaultCacheCapacity = 5000 -) - -type MemStore struct { - m map[string]*Chunk - mu sync.RWMutex -} - -func NewMemStore(d *LDBStore, capacity uint) (m *MemStore) { - return &MemStore{ - m: make(map[string]*Chunk), - } -} - -func (m *MemStore) Get(key Key) (*Chunk, error) { - m.mu.RLock() - defer m.mu.RUnlock() - c, ok := m.m[string(key[:])] - if !ok { - return nil, ErrChunkNotFound - } - if !bytes.Equal(c.Key, key) { - panic(fmt.Errorf("MemStore.Get: chunk key %s != req key %s", c.Key.Hex(), key.Hex())) - } - return c, nil -} - -func (m *MemStore) Put(c *Chunk) { - m.mu.Lock() - defer m.mu.Unlock() - m.m[string(c.Key[:])] = c -} - -func (m *MemStore) setCapacity(n int) { - -} - -// Close memstore -func (s *MemStore) Close() {} diff --git a/swarm/swarm.go b/swarm/swarm.go index b37f518790..f0e2b9bdb2 100644 --- a/swarm/swarm.go +++ b/swarm/swarm.go @@ -394,7 +394,6 @@ func (self *Swarm) periodicallyUpdateGauges() { } func (self *Swarm) updateGauges() { - //cacheSizeGauge.Update(int64(self.lstore.CacheCounter())) uptimeGauge.Update(time.Since(startTime).Nanoseconds()) }