swarm: cleanup

This commit is contained in:
Anton Evangelatov 2018-04-03 16:44:34 +02:00
parent 57fa8a867f
commit fa8acc90fb
4 changed files with 0 additions and 88 deletions

View file

@ -619,10 +619,6 @@ func (s *LDBStore) writeBatches() {
log.Error(fmt.Sprintf("DbStore: spawn batch write (%d chunks): %v", b.Len(), err)) log.Error(fmt.Sprintf("DbStore: spawn batch write (%d chunks): %v", b.Len(), err))
} }
close(c) 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")) log.Trace(fmt.Sprintf("DbStore: quit batch write loop"))
} }
@ -762,9 +758,6 @@ func (s *LDBStore) setCapacity(c uint64) {
if ratio > 1 { if ratio > 1 {
ratio = 1 ratio = 1
} }
//for s.entryCnt > c {
//s.collectGarbage(ratio)
//}
} }
} }

View file

@ -30,7 +30,6 @@ const (
) )
type MemStore struct { type MemStore struct {
//cache *lru.ARCCache
cache *lru.Cache cache *lru.Cache
disabled bool disabled bool
} }
@ -52,7 +51,6 @@ func NewMemStore(_ *LDBStore, capacity uint) (m *MemStore) {
} }
return &MemStore{ return &MemStore{
//cache: lru.NewARC(capacity),
cache: c, cache: c,
} }
} }
@ -88,5 +86,4 @@ func (m *MemStore) setCapacity(n int) {
} }
} }
// Close memstore
func (s *MemStore) Close() {} func (s *MemStore) Close() {}

View file

@ -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 <http://www.gnu.org/licenses/>.
// 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() {}

View file

@ -394,7 +394,6 @@ func (self *Swarm) periodicallyUpdateGauges() {
} }
func (self *Swarm) updateGauges() { func (self *Swarm) updateGauges() {
//cacheSizeGauge.Update(int64(self.lstore.CacheCounter()))
uptimeGauge.Update(time.Since(startTime).Nanoseconds()) uptimeGauge.Update(time.Since(startTime).Nanoseconds())
} }