]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Remove unused funcs and idents
authorMatt Joiner <anacrolix@gmail.com>
Sun, 1 Jan 2017 00:03:02 +0000 (11:03 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 1 Jan 2017 00:03:02 +0000 (11:03 +1100)
client.go
connection.go
torrent.go

index 4250ef4f43428f11a54cf4133254037e7f83a04f..53188a582458eda353ca5b411f769d7c2d0df82d 100644 (file)
--- a/client.go
+++ b/client.go
@@ -96,7 +96,7 @@ func (cl *Client) PeerID() string {
 
 type torrentAddr string
 
-func (me torrentAddr) Network() string { return "" }
+func (torrentAddr) Network() string { return "" }
 
 func (me torrentAddr) String() string { return string(me) }
 
@@ -107,12 +107,6 @@ func (cl *Client) ListenAddr() net.Addr {
        return torrentAddr(cl.listenAddr)
 }
 
-func (cl *Client) sortedTorrents() (ret []*Torrent) {
-       return slices.Sort(slices.FromMapElems(cl.torrents), func(l, r metainfo.Hash) bool {
-               return l.AsString() < r.AsString()
-       }).([]*Torrent)
-}
-
 // Writes out a human readable status of the client, such as for writing to a
 // HTTP status page.
 func (cl *Client) WriteStatus(_w io.Writer) {
@@ -452,7 +446,7 @@ type dialResult struct {
        UTP  bool
 }
 
-func doDial(dial func(addr string, t *Torrent) (net.Conn, error), ch chan dialResult, utp bool, addr string, t *Torrent) {
+func doDial(dial func(string, *Torrent) (net.Conn, error), ch chan dialResult, utp bool, addr string, t *Torrent) {
        conn, err := dial(addr, t)
        if err != nil {
                if conn != nil {
@@ -515,7 +509,7 @@ func (cl *Client) dialTCP(addr string, t *Torrent) (c net.Conn, err error) {
        return
 }
 
-func (cl *Client) dialUTP(addr string, t *Torrent) (c net.Conn, err error) {
+func (cl *Client) dialUTP(addr string, t *Torrent) (net.Conn, error) {
        return cl.utpSock.DialTimeout(addr, cl.dialTimeout(t))
 }
 
index 945fc879958c80235658a1a32e8f99fa42e1ab94..01f75dd09910245b76231608cc90ad404ba0bed7 100644 (file)
@@ -1064,10 +1064,6 @@ func (cn *connection) Drop() {
        cn.t.dropConnection(cn)
 }
 
-func (cn *connection) sentHave(piece int) bool {
-       return piece < len(cn.sentHaves) && cn.sentHaves[piece]
-}
-
 func (cn *connection) netGoodPiecesDirtied() int {
        return cn.goodPiecesDirtied - cn.badPiecesDirtied
 }
index 6702be8510e9ba5576a8f318ce53becc13c2f8df..ac4d1c065c9d0b5c4998b559ba77224d5f120465 100644 (file)
@@ -144,15 +144,6 @@ func (t *Torrent) pieceCompleteUncached(piece int) bool {
        return t.pieces[piece].Storage().GetIsComplete()
 }
 
-func (t *Torrent) numConnsUnchoked() (num int) {
-       for c := range t.conns {
-               if !c.PeerChoked {
-                       num++
-               }
-       }
-       return
-}
-
 // There's a connection to that address already.
 func (t *Torrent) addrActive(addr string) bool {
        if _, ok := t.halfOpen[addr]; ok {
@@ -551,10 +542,6 @@ func (t *Torrent) usualPieceSize() int {
        return int(t.info.PieceLength)
 }
 
-func (t *Torrent) lastPieceSize() int {
-       return int(t.pieceLength(t.numPieces() - 1))
-}
-
 func (t *Torrent) numPieces() int {
        return t.info.NumPieces()
 }
@@ -608,37 +595,6 @@ func (t *Torrent) bitfield() (bf []bool) {
        return
 }
 
-func (t *Torrent) validOutgoingRequest(r request) bool {
-       if r.Index >= pp.Integer(t.info.NumPieces()) {
-               return false
-       }
-       if r.Begin%t.chunkSize != 0 {
-               return false
-       }
-       if r.Length > t.chunkSize {
-               return false
-       }
-       pieceLength := t.pieceLength(int(r.Index))
-       if r.Begin+r.Length > pieceLength {
-               return false
-       }
-       return r.Length == t.chunkSize || r.Begin+r.Length == pieceLength
-}
-
-func (t *Torrent) pieceChunks(piece int) (css []chunkSpec) {
-       css = make([]chunkSpec, 0, (t.pieceLength(piece)+t.chunkSize-1)/t.chunkSize)
-       var cs chunkSpec
-       for left := t.pieceLength(piece); left != 0; left -= cs.Length {
-               cs.Length = left
-               if cs.Length > t.chunkSize {
-                       cs.Length = t.chunkSize
-               }
-               css = append(css, cs)
-               cs.Begin += cs.Length
-       }
-       return
-}
-
 func (t *Torrent) pieceNumChunks(piece int) int {
        return int((t.pieceLength(piece) + t.chunkSize - 1) / t.chunkSize)
 }
@@ -761,28 +717,10 @@ func (t *Torrent) wantPieceIndex(index int) bool {
        })
 }
 
-func (t *Torrent) forNeededPieces(f func(piece int) (more bool)) (all bool) {
-       return t.forReaderOffsetPieces(func(begin, end int) (more bool) {
-               for i := begin; begin < end; i++ {
-                       if !f(i) {
-                               return false
-                       }
-               }
-               return true
-       })
-}
-
 func (t *Torrent) connHasWantedPieces(c *connection) bool {
        return !c.pieceRequestOrder.IsEmpty()
 }
 
-func (t *Torrent) extentPieces(off, _len int64) (pieces []int) {
-       for i := off / int64(t.usualPieceSize()); i*int64(t.usualPieceSize()) < off+_len; i++ {
-               pieces = append(pieces, int(i))
-       }
-       return
-}
-
 // The worst connection is one that hasn't been sent, or sent anything useful
 // for the longest. A bad connection is one that usually sends us unwanted
 // pieces, or has been in worser half of the established connections for more
@@ -832,17 +770,6 @@ func (t *Torrent) pieceAllDirty(piece int) bool {
        return t.pieces[piece].DirtyChunks.Len() == t.pieceNumChunks(piece)
 }
 
-func (t *Torrent) forUrgentPieces(f func(piece int) (again bool)) (all bool) {
-       return t.forReaderOffsetPieces(func(begin, end int) (again bool) {
-               if begin < end {
-                       if !f(begin) {
-                               return false
-                       }
-               }
-               return true
-       })
-}
-
 func (t *Torrent) readersChanged() {
        t.updateReaderPieces()
        t.updateAllPiecePriorities()
@@ -985,10 +912,6 @@ func (t *Torrent) pendPiece(piece int) {
        t.updatePiecePriority(piece)
 }
 
-func (t *Torrent) getCompletedPieces() (ret bitmap.Bitmap) {
-       return t.completedPieces.Copy()
-}
-
 func (t *Torrent) unpendPieces(unpend *bitmap.Bitmap) {
        t.pendingPieces.Sub(unpend)
        unpend.IterTyped(func(piece int) (again bool) {