mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
swarm/network/stream: remove dead code
This commit is contained in:
parent
7a22da98b9
commit
654a51a88a
5 changed files with 2 additions and 58 deletions
|
|
@ -314,10 +314,6 @@ func (c *testExternalClient) NeedData(ctx context.Context, hash []byte) func(con
|
|||
return wait
|
||||
}
|
||||
|
||||
func (c *testExternalClient) BatchDone(Stream, uint64, []byte, []byte) func() (*TakeoverProof, error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *testExternalClient) Close() {}
|
||||
|
||||
type testExternalServer struct {
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ func (p *Peer) handleOfferedHashesMsg(ctx context.Context, req *OfferedHashesMsg
|
|||
}
|
||||
}
|
||||
select {
|
||||
case c.next <- c.batchDone(p, req, hashes):
|
||||
case c.next <- c.AddInterval(req.From, req.To):
|
||||
case <-c.quit:
|
||||
log.Debug("client.handleOfferedHashesMsg() quit")
|
||||
case <-ctx.Done():
|
||||
|
|
|
|||
|
|
@ -544,7 +544,6 @@ func (c *client) NextInterval() (start, end uint64, err error) {
|
|||
// Client interface for incoming peer Streamer
|
||||
type Client interface {
|
||||
NeedData(context.Context, []byte) func(context.Context) error
|
||||
BatchDone(Stream, uint64, []byte, []byte) func() (*TakeoverProof, error)
|
||||
Close()
|
||||
}
|
||||
|
||||
|
|
@ -574,24 +573,6 @@ func (c *client) nextBatch(from uint64) (nextFrom uint64, nextTo uint64) {
|
|||
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() {
|
||||
select {
|
||||
case <-c.quit:
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ type testClient struct {
|
|||
t string
|
||||
wait0 chan bool
|
||||
wait2 chan bool
|
||||
batchDone chan bool
|
||||
receivedHashes map[string][]byte
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +89,6 @@ func newTestClient(t string) *testClient {
|
|||
t: t,
|
||||
wait0: make(chan bool),
|
||||
wait2: make(chan bool),
|
||||
batchDone: make(chan bool),
|
||||
receivedHashes: make(map[string][]byte),
|
||||
}
|
||||
}
|
||||
|
|
@ -111,11 +109,6 @@ func (self *testClient) NeedData(ctx context.Context, hash []byte) func(context.
|
|||
return nil
|
||||
}
|
||||
|
||||
func (self *testClient) BatchDone(Stream, uint64, []byte, []byte) func() (*TakeoverProof, error) {
|
||||
close(self.batchDone)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *testClient) Close() {}
|
||||
|
||||
type testServer struct {
|
||||
|
|
@ -620,26 +613,9 @@ func TestStreamerDownstreamOfferedHashesMsgExchange(t *testing.T) {
|
|||
|
||||
close(tc.wait0)
|
||||
|
||||
timeout := time.NewTimer(100 * time.Millisecond)
|
||||
defer timeout.Stop()
|
||||
|
||||
select {
|
||||
case <-tc.batchDone:
|
||||
t.Fatal("batch done early")
|
||||
case <-timeout.C:
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -203,15 +203,6 @@ func (s *SwarmSyncerClient) NeedData(ctx context.Context, key []byte) (wait func
|
|||
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() {}
|
||||
|
||||
// base for parsing and formating sync bin key
|
||||
|
|
|
|||
Loading…
Reference in a new issue