swarm/network: fix light node code so that it compiles

This commit is contained in:
Anton Evangelatov 2018-02-05 09:38:22 +01:00
parent 00a4fdf503
commit 6098446d55
3 changed files with 9 additions and 4 deletions

View file

@ -117,6 +117,8 @@ func (r *RemoteSectionReader) Read(b []byte) (n int64, err error) {
}
}
func (r *RemoteSectionReader) Close() {}
// RemoteSectionServer implements OutgoingStreamer
type RemoteSectionServer struct {
// quit chan struct{}
@ -134,12 +136,12 @@ func NewRemoteSectionServer(db *storage.DBAPI, r *storage.LazyChunkReader) *Remo
}
// 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))
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
@ -152,6 +154,8 @@ func (s *RemoteSectionServer) SetNextBatch(from, to uint64) ([]byte, uint64, uin
return batch, from, to, nil, nil
}
func (s *RemoteSectionServer) Close() {}
// RegisterRemoteSectionReader registers RemoteSectionReader on light downstream node
func RegisterRemoteSectionReader(s *stream.Registry, db *storage.DBAPI) {
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 (
"context"