swarm: fix megacheck warnings
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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() {}
|
||||
|
@ -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() {}
|
||||
|
@ -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() {}
|
||||
|
@ -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() {}
|
||||
|
@ -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))
|
||||
|
Reference in New Issue
Block a user