mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
swarm: Cleanup after rebase on swarm-mutableresources-extsign
This commit is contained in:
parent
aff40c4e8c
commit
703051b1aa
3 changed files with 7 additions and 8 deletions
|
|
@ -40,7 +40,7 @@ func init() {
|
||||||
log.Root().SetHandler(log.CallerFileHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))))
|
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)
|
srv := testutil.NewTestSwarmServer(t)
|
||||||
defer srv.Close()
|
defer srv.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
const (
|
const (
|
||||||
signatureLength = 65
|
signatureLength = 65
|
||||||
indexSize = 16
|
indexSize = 16
|
||||||
dbDirName = "resource"
|
DbDirName = "resource"
|
||||||
chunkSize = 4096 // temporary until we implement DPA in the resourcehandler
|
chunkSize = 4096 // temporary until we implement DPA in the resourcehandler
|
||||||
defaultStoreTimeout = 4000 * time.Millisecond
|
defaultStoreTimeout = 4000 * time.Millisecond
|
||||||
)
|
)
|
||||||
|
|
@ -133,8 +133,6 @@ type ResourceHandler struct {
|
||||||
hasher SwarmHash
|
hasher SwarmHash
|
||||||
nameHash nameHashFunc
|
nameHash nameHashFunc
|
||||||
storeTimeout time.Duration
|
storeTimeout time.Duration
|
||||||
ctx context.Context
|
|
||||||
cancelFunc func()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create or open resource update chunk store
|
// 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())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
rh := &ResourceHandler{
|
rh := &ResourceHandler{
|
||||||
ChunkStore: newResourceChunkStore(path, hashfunc, localStore, cloudStore),
|
ChunkStore: newResourceChunkStore(path, hashfunc, localStore, cloudStore),
|
||||||
rpcClient: rpcClient,
|
ethClient: ethClient,
|
||||||
resources: make(map[string]*resource),
|
resources: make(map[string]*resource),
|
||||||
hasher: hashfunc(),
|
hasher: hashfunc(),
|
||||||
validator: validator,
|
validator: validator,
|
||||||
|
|
@ -481,7 +479,7 @@ func (self *ResourceHandler) parseUpdate(chunkdata []byte) (*Signature, uint32,
|
||||||
datalength := binary.LittleEndian.Uint16(chunkdata[cursor : cursor+2])
|
datalength := binary.LittleEndian.Uint16(chunkdata[cursor : cursor+2])
|
||||||
if int(headerlength+datalength+4) > len(chunkdata) {
|
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))
|
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
|
var period uint32
|
||||||
|
|
@ -501,13 +499,14 @@ func (self *ResourceHandler) parseUpdate(chunkdata []byte) (*Signature, uint32,
|
||||||
copy(data, chunkdata[cursor:cursor+intdatalength])
|
copy(data, chunkdata[cursor:cursor+intdatalength])
|
||||||
|
|
||||||
// omit signatures if we have no validator
|
// omit signatures if we have no validator
|
||||||
|
var signature *Signature
|
||||||
if self.validator != nil {
|
if self.validator != nil {
|
||||||
cursor += intdatalength
|
cursor += intdatalength
|
||||||
signature = &Signature{}
|
signature = &Signature{}
|
||||||
copy(signature[:], chunkdata[cursor:cursor+signatureLength])
|
copy(signature[:], chunkdata[cursor:cursor+signatureLength])
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return signature, period, version, name, data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds an actual data update
|
// Adds an actual data update
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func NewTestSwarmServer(t *testing.T) *TestSwarmServer {
|
||||||
CacheCapacity: 5000,
|
CacheCapacity: 5000,
|
||||||
Radius: 0,
|
Radius: 0,
|
||||||
}
|
}
|
||||||
localStore, err := storage.NewLocalStore(storage.MakeHashFunc(storage.SHA3Hash), storeparams)
|
localStore, err := storage.NewLocalStore(storage.MakeHashFunc(storage.SHA3Hash), storeparams, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.RemoveAll(dir)
|
os.RemoveAll(dir)
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue