diff options
Diffstat (limited to 'swarm/storage')
-rw-r--r-- | swarm/storage/chunker.go | 12 | ||||
-rw-r--r-- | swarm/storage/chunker_test.go | 21 | ||||
-rw-r--r-- | swarm/storage/dbstore.go | 7 | ||||
-rw-r--r-- | swarm/storage/dpa.go | 5 | ||||
-rw-r--r-- | swarm/storage/localstore.go | 4 | ||||
-rw-r--r-- | swarm/storage/memstore.go | 10 | ||||
-rw-r--r-- | swarm/storage/netstore.go | 6 | ||||
-rw-r--r-- | swarm/storage/pyramid.go | 7 |
8 files changed, 13 insertions, 59 deletions
diff --git a/swarm/storage/chunker.go b/swarm/storage/chunker.go index d55875369..563793e98 100644 --- a/swarm/storage/chunker.go +++ b/swarm/storage/chunker.go @@ -156,14 +156,12 @@ func (self *TreeChunker) Split(data io.Reader, size int64, chunkC chan *Chunk, s close(errC) }() - select { - case err := <-errC: - if err != nil { - close(quitC) - return nil, err - } - //TODO: add a timeout + //TODO: add a timeout + if err := <-errC; err != nil { + close(quitC) + return nil, err } + return key, nil } diff --git a/swarm/storage/chunker_test.go b/swarm/storage/chunker_test.go index 40f870246..426074e59 100644 --- a/swarm/storage/chunker_test.go +++ b/swarm/storage/chunker_test.go @@ -43,13 +43,6 @@ type chunkerTester struct { t test } -func (self *chunkerTester) checkChunks(t *testing.T, want int) { - l := len(self.chunks) - if l != want { - t.Errorf("expected %v chunks, got %v", want, l) - } -} - func (self *chunkerTester) Split(chunker Splitter, data io.Reader, size int64, chunkC chan *Chunk, swg *sync.WaitGroup, expectedError error) (key Key) { // reset self.chunks = make(map[string]*Chunk) @@ -209,20 +202,6 @@ func TestRandomBrokenData(t *testing.T) { } } -func readAll(reader LazySectionReader, result []byte) { - size := int64(len(result)) - - var end int64 - for pos := int64(0); pos < size; pos += 1000 { - if pos+1000 > size { - end = size - } else { - end = pos + 1000 - } - reader.ReadAt(result[pos:end], pos) - } -} - func benchReadAll(reader LazySectionReader) { size, _ := reader.Size(nil) output := make([]byte, 1000) diff --git a/swarm/storage/dbstore.go b/swarm/storage/dbstore.go index 076113084..cbeddb8cb 100644 --- a/swarm/storage/dbstore.go +++ b/swarm/storage/dbstore.go @@ -514,8 +514,7 @@ func (s *DbStore) setCapacity(c uint64) { s.capacity = c if s.entryCnt > c { - var ratio float32 - ratio = float32(1.01) - float32(c)/float32(s.entryCnt) + ratio := float32(1.01) - float32(c)/float32(s.entryCnt) if ratio < gcArrayFreeRatio { ratio = gcArrayFreeRatio } @@ -528,10 +527,6 @@ func (s *DbStore) setCapacity(c uint64) { } } -func (s *DbStore) getEntryCnt() uint64 { - return s.entryCnt -} - func (s *DbStore) Close() { s.db.Close() } diff --git a/swarm/storage/dpa.go b/swarm/storage/dpa.go index e16e4aacb..44a2669f1 100644 --- a/swarm/storage/dpa.go +++ b/swarm/storage/dpa.go @@ -59,7 +59,6 @@ type DPA struct { lock sync.Mutex running bool - wg *sync.WaitGroup quitC chan bool } @@ -239,6 +238,4 @@ func (self *dpaChunkStore) Put(entry *Chunk) { } // Close chunk store -func (self *dpaChunkStore) Close() { - return -} +func (self *dpaChunkStore) Close() {} diff --git a/swarm/storage/localstore.go b/swarm/storage/localstore.go index 14827e361..58f59d0a2 100644 --- a/swarm/storage/localstore.go +++ b/swarm/storage/localstore.go @@ -74,6 +74,4 @@ func (self *LocalStore) Get(key Key) (chunk *Chunk, err error) { } // Close local store -func (self *LocalStore) Close() { - return -} +func (self *LocalStore) Close() {} diff --git a/swarm/storage/memstore.go b/swarm/storage/memstore.go index f96792c6e..155dd0088 100644 --- a/swarm/storage/memstore.go +++ b/swarm/storage/memstore.go @@ -130,10 +130,6 @@ func (s *MemStore) setCapacity(c uint) { s.capacity = c } -func (s *MemStore) getEntryCnt() uint { - return s.entryCnt -} - // entry (not its copy) is going to be in MemStore func (s *MemStore) Put(entry *Chunk) { if s.capacity == 0 { @@ -206,8 +202,6 @@ func (s *MemStore) Put(entry *Chunk) { node.lastDBaccess = s.dbAccessCnt node.updateAccess(s.accessCnt) s.entryCnt++ - - return } func (s *MemStore) Get(hash Key) (chunk *Chunk, err error) { @@ -323,6 +317,4 @@ func (s *MemStore) removeOldest() { } // Close memstore -func (s *MemStore) Close() { - return -} +func (s *MemStore) Close() {} diff --git a/swarm/storage/netstore.go b/swarm/storage/netstore.go index 7c0436c3f..746dd85f6 100644 --- a/swarm/storage/netstore.go +++ b/swarm/storage/netstore.go @@ -19,7 +19,6 @@ package storage import ( "fmt" "path/filepath" - "sync" "time" "github.com/ethereum/go-ethereum/log" @@ -40,7 +39,6 @@ type NetStore struct { hashfunc Hasher localStore *LocalStore cloud CloudStore - lock sync.Mutex } // backend engine for cloud store @@ -134,6 +132,4 @@ func (self *NetStore) Get(key Key) (*Chunk, error) { } // Close netstore -func (self *NetStore) Close() { - return -} +func (self *NetStore) Close() {} diff --git a/swarm/storage/pyramid.go b/swarm/storage/pyramid.go index 79e1927b9..74e00a497 100644 --- a/swarm/storage/pyramid.go +++ b/swarm/storage/pyramid.go @@ -178,10 +178,9 @@ func (self *PyramidChunker) processor(pend, swg *sync.WaitGroup, tasks chan *Tas if swg != nil { swg.Add(1) } - select { - case chunkC <- &Chunk{Key: hash, SData: data, wg: swg}: - // case <- self.quitC - } + + chunkC <- &Chunk{Key: hash, SData: data, wg: swg} + // TODO: consider selecting on self.quitC to avoid blocking forever on shutdown } if depth+1 < len(results.Levels) { delete(results.Levels[depth+1], task.Index/(pow/self.branches)) |