From 6098446d558f3d8e883d2d8f6ca6ac446951237f Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Mon, 5 Feb 2018 09:38:22 +0100 Subject: [PATCH] swarm/network: fix light node code so that it compiles --- swarm/network/light/lightnode.go | 10 +++++++--- swarm/network/simulations/discovery/discovery.go | 1 + swarm/network/simulations/discovery/discovery_test.go | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 swarm/network/simulations/discovery/discovery.go diff --git a/swarm/network/light/lightnode.go b/swarm/network/light/lightnode.go index 7bf769d468..93ebbc8a78 100644 --- a/swarm/network/light/lightnode.go +++ b/swarm/network/light/lightnode.go @@ -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) { diff --git a/swarm/network/simulations/discovery/discovery.go b/swarm/network/simulations/discovery/discovery.go new file mode 100644 index 0000000000..5844159aeb --- /dev/null +++ b/swarm/network/simulations/discovery/discovery.go @@ -0,0 +1 @@ +package discovery diff --git a/swarm/network/simulations/discovery/discovery_test.go b/swarm/network/simulations/discovery/discovery_test.go index 33a1c04868..dfce8059c7 100644 --- a/swarm/network/simulations/discovery/discovery_test.go +++ b/swarm/network/simulations/discovery/discovery_test.go @@ -1,4 +1,4 @@ -package discovery_test +package discovery import ( "context"