swarm/network/stream: remove dead code

This commit is contained in:
Anton Evangelatov 2019-05-31 12:33:36 +02:00
parent 7a22da98b9
commit 654a51a88a
5 changed files with 2 additions and 58 deletions

View file

@ -314,10 +314,6 @@ func (c *testExternalClient) NeedData(ctx context.Context, hash []byte) func(con
return wait return wait
} }
func (c *testExternalClient) BatchDone(Stream, uint64, []byte, []byte) func() (*TakeoverProof, error) {
return nil
}
func (c *testExternalClient) Close() {} func (c *testExternalClient) Close() {}
type testExternalServer struct { type testExternalServer struct {

View file

@ -265,7 +265,7 @@ func (p *Peer) handleOfferedHashesMsg(ctx context.Context, req *OfferedHashesMsg
} }
} }
select { select {
case c.next <- c.batchDone(p, req, hashes): case c.next <- c.AddInterval(req.From, req.To):
case <-c.quit: case <-c.quit:
log.Debug("client.handleOfferedHashesMsg() quit") log.Debug("client.handleOfferedHashesMsg() quit")
case <-ctx.Done(): case <-ctx.Done():

View file

@ -544,7 +544,6 @@ func (c *client) NextInterval() (start, end uint64, err error) {
// Client interface for incoming peer Streamer // Client interface for incoming peer Streamer
type Client interface { type Client interface {
NeedData(context.Context, []byte) func(context.Context) error NeedData(context.Context, []byte) func(context.Context) error
BatchDone(Stream, uint64, []byte, []byte) func() (*TakeoverProof, error)
Close() Close()
} }
@ -574,24 +573,6 @@ func (c *client) nextBatch(from uint64) (nextFrom uint64, nextTo uint64) {
return return
} }
func (c *client) batchDone(p *Peer, req *OfferedHashesMsg, hashes []byte) error {
if tf := c.BatchDone(req.Stream, req.From, hashes, req.Root); tf != nil {
tp, err := tf()
if err != nil {
return err
}
if err := p.Send(context.TODO(), tp); err != nil {
return err
}
if c.to > 0 && tp.Takeover.End >= c.to {
return p.streamer.Unsubscribe(p.Peer.ID(), req.Stream)
}
return nil
}
return c.AddInterval(req.From, req.To)
}
func (c *client) close() { func (c *client) close() {
select { select {
case <-c.quit: case <-c.quit:

View file

@ -81,7 +81,6 @@ type testClient struct {
t string t string
wait0 chan bool wait0 chan bool
wait2 chan bool wait2 chan bool
batchDone chan bool
receivedHashes map[string][]byte receivedHashes map[string][]byte
} }
@ -90,7 +89,6 @@ func newTestClient(t string) *testClient {
t: t, t: t,
wait0: make(chan bool), wait0: make(chan bool),
wait2: make(chan bool), wait2: make(chan bool),
batchDone: make(chan bool),
receivedHashes: make(map[string][]byte), receivedHashes: make(map[string][]byte),
} }
} }
@ -111,11 +109,6 @@ func (self *testClient) NeedData(ctx context.Context, hash []byte) func(context.
return nil return nil
} }
func (self *testClient) BatchDone(Stream, uint64, []byte, []byte) func() (*TakeoverProof, error) {
close(self.batchDone)
return nil
}
func (self *testClient) Close() {} func (self *testClient) Close() {}
type testServer struct { type testServer struct {
@ -620,26 +613,9 @@ func TestStreamerDownstreamOfferedHashesMsgExchange(t *testing.T) {
close(tc.wait0) close(tc.wait0)
timeout := time.NewTimer(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
defer timeout.Stop()
select {
case <-tc.batchDone:
t.Fatal("batch done early")
case <-timeout.C:
}
close(tc.wait2) close(tc.wait2)
timeout2 := time.NewTimer(10000 * time.Millisecond)
defer timeout2.Stop()
select {
case <-tc.batchDone:
case <-timeout2.C:
t.Fatal("timeout waiting batchdone call")
}
} }
func TestStreamerRequestSubscriptionQuitMsgExchange(t *testing.T) { func TestStreamerRequestSubscriptionQuitMsgExchange(t *testing.T) {

View file

@ -203,15 +203,6 @@ func (s *SwarmSyncerClient) NeedData(ctx context.Context, key []byte) (wait func
return s.netStore.FetchFunc(ctx, key) return s.netStore.FetchFunc(ctx, key)
} }
// BatchDone
func (s *SwarmSyncerClient) BatchDone(stream Stream, from uint64, hashes []byte, root []byte) func() (*TakeoverProof, error) {
// TODO: reenable this with putter/getter refactored code
// if s.chunker != nil {
// return func() (*TakeoverProof, error) { return s.TakeoverProof(stream, from, hashes, root) }
// }
return nil
}
func (s *SwarmSyncerClient) Close() {} func (s *SwarmSyncerClient) Close() {}
// base for parsing and formating sync bin key // base for parsing and formating sync bin key