Skip to content

Commit

Permalink
Merge pull request ethereum#234 from ethersphere/fixup-swarm-network-…
Browse files Browse the repository at this point in the history
…rewrite-syncer

swarm/network: fix light node code so that it compiles
  • Loading branch information
nonsense committed Feb 5, 2018
2 parents 00a4fdf + 6bc4a5b commit dc0acb7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
10 changes: 7 additions & 3 deletions swarm/network/light/lightnode.go
Expand Up @@ -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{}
Expand All @@ -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
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions swarm/network/simulations/discovery/discovery.go
@@ -0,0 +1 @@
package discovery
4 changes: 2 additions & 2 deletions swarm/network/simulations/discovery/discovery_test.go
@@ -1,4 +1,4 @@
package discovery_test
package discovery

import (
"context"
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions swarm/network/stream/streamer_test.go
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion swarm/pss/client/client_test.go
Expand Up @@ -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
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion swarm/pss/pss_test.go
Expand Up @@ -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
},
}
}
Expand Down

0 comments on commit dc0acb7

Please sign in to comment.