diff --git a/swarm/api/http/server_test.go b/swarm/api/http/server_test.go index c79922a7f2..2837decfde 100644 --- a/swarm/api/http/server_test.go +++ b/swarm/api/http/server_test.go @@ -40,7 +40,7 @@ func init() { log.Root().SetHandler(log.CallerFileHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))) } -func TestBzzGetDb(t *testing.T) { +func TestBzzResource(t *testing.T) { srv := testutil.NewTestSwarmServer(t) defer srv.Close() diff --git a/swarm/storage/resource.go b/swarm/storage/resource.go index 6a90f2bdfa..bf4404634c 100644 --- a/swarm/storage/resource.go +++ b/swarm/storage/resource.go @@ -19,7 +19,7 @@ import ( const ( signatureLength = 65 indexSize = 16 - dbDirName = "resource" + DbDirName = "resource" chunkSize = 4096 // temporary until we implement DPA in the resourcehandler defaultStoreTimeout = 4000 * time.Millisecond ) @@ -133,8 +133,6 @@ type ResourceHandler struct { hasher SwarmHash nameHash nameHashFunc storeTimeout time.Duration - ctx context.Context - cancelFunc func() } // Create or open resource update chunk store @@ -157,7 +155,7 @@ func NewResourceHandler(datadir string, cloudStore CloudStore, ethClient ethApi, ctx, cancel := context.WithCancel(context.Background()) rh := &ResourceHandler{ ChunkStore: newResourceChunkStore(path, hashfunc, localStore, cloudStore), - rpcClient: rpcClient, + ethClient: ethClient, resources: make(map[string]*resource), hasher: hashfunc(), validator: validator, @@ -481,7 +479,7 @@ func (self *ResourceHandler) parseUpdate(chunkdata []byte) (*Signature, uint32, datalength := binary.LittleEndian.Uint16(chunkdata[cursor : cursor+2]) if int(headerlength+datalength+4) > len(chunkdata) { err = fmt.Errorf("Reported headerlength %d + datalength %d longer than actual chunk data length %d", headerlength, datalength, len(chunkdata)) - return + return nil, 0, 0, "", nil, err } var period uint32 @@ -501,13 +499,14 @@ func (self *ResourceHandler) parseUpdate(chunkdata []byte) (*Signature, uint32, copy(data, chunkdata[cursor:cursor+intdatalength]) // omit signatures if we have no validator + var signature *Signature if self.validator != nil { cursor += intdatalength signature = &Signature{} copy(signature[:], chunkdata[cursor:cursor+signatureLength]) } - return + return signature, period, version, name, data, nil } // Adds an actual data update diff --git a/swarm/testutil/http.go b/swarm/testutil/http.go index 3556101850..4a6a68e43b 100644 --- a/swarm/testutil/http.go +++ b/swarm/testutil/http.go @@ -51,7 +51,7 @@ func NewTestSwarmServer(t *testing.T) *TestSwarmServer { CacheCapacity: 5000, Radius: 0, } - localStore, err := storage.NewLocalStore(storage.MakeHashFunc(storage.SHA3Hash), storeparams) + localStore, err := storage.NewLocalStore(storage.MakeHashFunc(storage.SHA3Hash), storeparams, nil) if err != nil { os.RemoveAll(dir) t.Fatal(err)