Merge pull request #234 from ethersphere/fixup-swarm-network-rewrite-syncer

swarm/network: fix light node code so that it compiles
This commit is contained in:
Anton Evangelatov 2018-02-05 09:54:30 +01:00 committed by GitHub
commit dc0acb72a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 7 deletions

View file

@ -117,6 +117,8 @@ func (r *RemoteSectionReader) Read(b []byte) (n int64, err error) {
} }
} }
func (r *RemoteSectionReader) Close() {}
// RemoteSectionServer implements OutgoingStreamer // RemoteSectionServer implements OutgoingStreamer
type RemoteSectionServer struct { type RemoteSectionServer struct {
// quit chan struct{} // quit chan struct{}
@ -134,12 +136,12 @@ func NewRemoteSectionServer(db *storage.DBAPI, r *storage.LazyChunkReader) *Remo
} }
// GetData retrieves the actual chunk from localstore // GetData retrieves the actual chunk from localstore
func (s *RemoteSectionServer) GetData(key []byte) []byte { func (s *RemoteSectionServer) GetData(key []byte) ([]byte, error) {
chunk, err := s.db.Get(storage.Key(key)) chunk, err := s.db.Get(storage.Key(key))
if err != nil { if err != nil {
return nil return nil, err
} }
return chunk.SData return chunk.SData, nil
} }
// GetBatch retrieves the next batch of hashes from the dbstore // GetBatch retrieves the next batch of hashes from the dbstore
@ -152,6 +154,8 @@ func (s *RemoteSectionServer) SetNextBatch(from, to uint64) ([]byte, uint64, uin
return batch, from, to, nil, nil return batch, from, to, nil, nil
} }
func (s *RemoteSectionServer) Close() {}
// RegisterRemoteSectionReader registers RemoteSectionReader on light downstream node // RegisterRemoteSectionReader registers RemoteSectionReader on light downstream node
func RegisterRemoteSectionReader(s *stream.Registry, db *storage.DBAPI) { func RegisterRemoteSectionReader(s *stream.Registry, db *storage.DBAPI) {
s.RegisterClientFunc("REMOTE_SECTION", func(p *stream.Peer, t []byte) (stream.Client, error) { s.RegisterClientFunc("REMOTE_SECTION", func(p *stream.Peer, t []byte) (stream.Client, error) {

View file

@ -0,0 +1 @@
package discovery

View file

@ -1,4 +1,4 @@
package discovery_test package discovery
import ( import (
"context" "context"
@ -319,5 +319,5 @@ func newService(ctx *adapters.ServiceContext) (node.Service, error) {
HiveParams: hp, HiveParams: hp,
} }
return network.NewBzz(config, kad, nil, nil), nil return network.NewBzz(config, kad, nil), nil
} }

View file

@ -77,6 +77,8 @@ func (self *testClient) BatchDone(string, uint64, []byte, []byte) func() (*Takeo
return nil return nil
} }
func (self *testClient) Close() {}
func (self *testServer) SetNextBatch(from uint64, to uint64) ([]byte, uint64, uint64, *HandoverProof, error) { func (self *testServer) SetNextBatch(from uint64, to uint64) ([]byte, uint64, uint64, *HandoverProof, error) {
return make([]byte, HashSize), from + 1, to + 1, nil, nil return make([]byte, HashSize), from + 1, to + 1, nil, nil
} }

View file

@ -260,7 +260,7 @@ func newServices() adapters.Services {
UnderlayAddr: addr.Under(), UnderlayAddr: addr.Under(),
HiveParams: hp, HiveParams: hp,
} }
return network.NewBzz(config, kademlia(ctx.Config.ID), stateStore, nil), nil return network.NewBzz(config, kademlia(ctx.Config.ID), stateStore), nil
}, },
} }
} }

View file

@ -1178,7 +1178,7 @@ func newServices() adapters.Services {
UnderlayAddr: addr.Under(), UnderlayAddr: addr.Under(),
HiveParams: hp, HiveParams: hp,
} }
return network.NewBzz(config, kademlia(ctx.Config.ID), stateStore, nil), nil return network.NewBzz(config, kademlia(ctx.Config.ID), stateStore), nil
}, },
} }
} }