From a8a1ea755dc943cfa88e8ea998672742665752ee Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 26 Aug 2017 13:23:04 +1000 Subject: [PATCH] Remove unused functions --- client.go | 7 ------- client_test.go | 6 ------ connection.go | 20 -------------------- reader.go | 4 ---- torrent.go | 7 ------- 5 files changed, 44 deletions(-) diff --git a/client.go b/client.go index c451aca6..035af50d 100644 --- a/client.go +++ b/client.go @@ -515,13 +515,6 @@ func (cl *Client) initiateConn(peer Peer, t *Torrent) { go cl.outgoingConnection(t, addr, peer.Source) } -func (cl *Client) dialTimeout(t *Torrent) time.Duration { - cl.mu.Lock() - pendingPeers := len(t.peers) - cl.mu.Unlock() - return reducedDialTimeout(nominalDialTimeout, cl.halfOpenLimit, pendingPeers) -} - func (cl *Client) dialTCP(ctx context.Context, addr string) (c net.Conn, err error) { d := net.Dialer{ // LocalAddr: cl.tcpListener.Addr(), diff --git a/client_test.go b/client_test.go index b74a65a7..e786b399 100644 --- a/client_test.go +++ b/client_test.go @@ -1014,12 +1014,6 @@ func addClientPeer(t *Torrent, cl *Client) { }) } -func printConnPeerCounts(t *Torrent) { - t.cl.mu.Lock() - log.Println(len(t.conns), len(t.peers)) - t.cl.mu.Unlock() -} - func totalConns(tts []*Torrent) (ret int) { for _, tt := range tts { tt.cl.mu.Lock() diff --git a/connection.go b/connection.go index a893ccb8..0b1fed81 100644 --- a/connection.go +++ b/connection.go @@ -547,26 +547,6 @@ func (cn *connection) updateRequests() { cn.SetInterested(i) } -func (cn *connection) fillRequests() { - cn.pieceRequestOrder.IterTyped(func(piece int) (more bool) { - if cn.t.cl.config.Debug && cn.t.havePiece(piece) { - panic(piece) - } - return cn.requestPiecePendingChunks(piece) - }) -} - -func (c *connection) requestPiecePendingChunks(piece int) (again bool) { - if !c.PeerHasPiece(piece) { - return true - } - chunkIndices := c.t.pieces[piece].undirtiedChunkIndices().ToSortedSlice() - return iter.ForPerm(len(chunkIndices), func(i int) bool { - req := request{pp.Integer(piece), c.t.chunkIndexSpec(chunkIndices[i], piece)} - return c.Request(req) - }) -} - func undirtiedChunks(piece int, t *Torrent, f func(chunkSpec) bool) bool { chunkIndices := t.pieces[piece].undirtiedChunkIndices().ToSortedSlice() return iter.ForPerm(len(chunkIndices), func(i int) bool { diff --git a/reader.go b/reader.go index ed4da8aa..33ed4017 100644 --- a/reader.go +++ b/reader.go @@ -101,10 +101,6 @@ func (r *Reader) available(off, max int64) (ret int64) { return } -func (r *Reader) tickleClient() { - r.t.readersChanged() -} - func (r *Reader) waitReadable(off int64) { // We may have been sent back here because we were told we could read but // it failed. diff --git a/torrent.go b/torrent.go index d361bd6e..c2be1f06 100644 --- a/torrent.go +++ b/torrent.go @@ -640,13 +640,6 @@ func (t *Torrent) hashPiece(piece int) (ret metainfo.Hash) { return } -func (t *Torrent) haveAllPieces() bool { - if !t.haveInfo() { - return false - } - return t.completedPieces.Len() == t.numPieces() -} - func (t *Torrent) haveAnyPieces() bool { for i := range t.pieces { if t.pieceComplete(i) {