From 6098446d558f3d8e883d2d8f6ca6ac446951237f Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Mon, 5 Feb 2018 09:38:22 +0100 Subject: [PATCH 1/2] 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" From 6bc4a5bf1b503f07dbcd2f8c79ffe269fb673e94 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Mon, 5 Feb 2018 09:52:38 +0100 Subject: [PATCH 2/2] swarm/network, swarm/pss: update tests so that they compile --- swarm/network/simulations/discovery/discovery_test.go | 2 +- swarm/network/stream/streamer_test.go | 2 ++ swarm/pss/client/client_test.go | 2 +- swarm/pss/pss_test.go | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/swarm/network/simulations/discovery/discovery_test.go b/swarm/network/simulations/discovery/discovery_test.go index dfce8059c7..dd68cd0315 100644 --- a/swarm/network/simulations/discovery/discovery_test.go +++ b/swarm/network/simulations/discovery/discovery_test.go @@ -319,5 +319,5 @@ func newService(ctx *adapters.ServiceContext) (node.Service, error) { HiveParams: hp, } - return network.NewBzz(config, kad, nil, nil), nil + return network.NewBzz(config, kad, nil), nil } diff --git a/swarm/network/stream/streamer_test.go b/swarm/network/stream/streamer_test.go index 71aee61aac..951e008a53 100644 --- a/swarm/network/stream/streamer_test.go +++ b/swarm/network/stream/streamer_test.go @@ -77,6 +77,8 @@ func (self *testClient) BatchDone(string, uint64, []byte, []byte) func() (*Takeo return nil } +func (self *testClient) Close() {} + func (self *testServer) SetNextBatch(from uint64, to uint64) ([]byte, uint64, uint64, *HandoverProof, error) { return make([]byte, HashSize), from + 1, to + 1, nil, nil } diff --git a/swarm/pss/client/client_test.go b/swarm/pss/client/client_test.go index fe11e37c91..f32fa7127a 100644 --- a/swarm/pss/client/client_test.go +++ b/swarm/pss/client/client_test.go @@ -260,7 +260,7 @@ func newServices() adapters.Services { UnderlayAddr: addr.Under(), HiveParams: hp, } - return network.NewBzz(config, kademlia(ctx.Config.ID), stateStore, nil), nil + return network.NewBzz(config, kademlia(ctx.Config.ID), stateStore), nil }, } } diff --git a/swarm/pss/pss_test.go b/swarm/pss/pss_test.go index bda1490c9d..9283b43f72 100644 --- a/swarm/pss/pss_test.go +++ b/swarm/pss/pss_test.go @@ -1178,7 +1178,7 @@ func newServices() adapters.Services { UnderlayAddr: addr.Under(), HiveParams: hp, } - return network.NewBzz(config, kademlia(ctx.Config.ID), stateStore, nil), nil + return network.NewBzz(config, kademlia(ctx.Config.ID), stateStore), nil }, } }