]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Remove deadcode
authorMatt Joiner <anacrolix@gmail.com>
Mon, 4 Apr 2016 05:18:51 +0000 (15:18 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 4 Apr 2016 05:18:51 +0000 (15:18 +1000)
client.go
client_test.go
misc.go
torrent.go

index 21446ff6f8e578fac364c7a51023be7633969619..5444cea25fcc469e84f547e740190893f40b8f7d 100644 (file)
--- a/client.go
+++ b/client.go
@@ -99,8 +99,7 @@ const (
        // Limit how long handshake can take. This is to reduce the lingering
        // impact of a few bad apples. 4s loses 1% of successful handshakes that
        // are obtained with 60s timeout, and 5% of unsuccessful handshakes.
-       btHandshakeTimeout = 4 * time.Second
-       handshakesTimeout  = 20 * time.Second
+       handshakesTimeout = 20 * time.Second
 
        // These are our extended message IDs.
        metadataExtendedId = iota + 1 // 0 is reserved for deleting keys
@@ -256,20 +255,6 @@ func (cl *Client) WriteStatus(_w io.Writer) {
        }
 }
 
-// Calculates the number of pieces to set to Readahead priority, after the
-// Now, and Next pieces.
-func readaheadPieces(readahead, pieceLength int64) (ret int) {
-       // Expand the readahead to fit any partial pieces. Subtract 1 for the
-       // "next" piece that is assigned.
-       ret = int((readahead+pieceLength-1)/pieceLength - 1)
-       // Lengthen the "readahead tail" to smooth blockiness that occurs when the
-       // piece length is much larger than the readahead.
-       if ret < 2 {
-               ret++
-       }
-       return
-}
-
 func (cl *Client) configDir() string {
        if cl.config.ConfigDir == "" {
                return filepath.Join(os.Getenv("HOME"), ".config/torrent")
index 14b0ffd0bca92dabb4a14c34c2e1e8a007e28b5d..17901d992f55fb3c48efb4d6d6a2c076e95345be 100644 (file)
@@ -423,23 +423,6 @@ func TestSeedAfterDownloading(t *testing.T) {
        wg.Wait()
 }
 
-func TestReadaheadPieces(t *testing.T) {
-       for _, case_ := range []struct {
-               readaheadBytes, pieceLength int64
-               readaheadPieces             int
-       }{
-               {5 * 1024 * 1024, 256 * 1024, 19},
-               {5 * 1024 * 1024, 5 * 1024 * 1024, 1},
-               {5*1024*1024 - 1, 5 * 1024 * 1024, 1},
-               {5 * 1024 * 1024, 5*1024*1024 - 1, 2},
-               {0, 5 * 1024 * 1024, 0},
-               {5 * 1024 * 1024, 1048576, 4},
-       } {
-               pieces := readaheadPieces(case_.readaheadBytes, case_.pieceLength)
-               assert.Equal(t, case_.readaheadPieces, pieces, "%v", case_)
-       }
-}
-
 func TestMergingTrackersByAddingSpecs(t *testing.T) {
        cl, err := NewClient(&TestingConfig)
        require.NoError(t, err)
diff --git a/misc.go b/misc.go
index 147b657cc67e3e3257b9d46b651d4ebe9fe5d304..c276455050459e99397451b5503749173c5a372d 100644 (file)
--- a/misc.go
+++ b/misc.go
@@ -21,12 +21,6 @@ const (
        minDialTimeout     = 5 * time.Second
 )
 
-func lastChunkSpec(pieceLength, chunkSize pp.Integer) (cs chunkSpec) {
-       cs.Begin = (pieceLength - 1) / chunkSize * chunkSize
-       cs.Length = pieceLength - cs.Begin
-       return
-}
-
 type chunkSpec struct {
        Begin, Length pp.Integer
 }
@@ -40,11 +34,6 @@ func newRequest(index, begin, length pp.Integer) request {
        return request{index, chunkSpec{begin, length}}
 }
 
-var (
-       // Requested data not yet available.
-       errDataNotReady = errors.New("data not ready")
-)
-
 // The size in bytes of a metadata extension piece.
 func metadataPieceSize(totalSize int, piece int) int {
        ret := totalSize - piece*(1<<14)
@@ -58,17 +47,6 @@ type superer interface {
        Super() interface{}
 }
 
-// Returns ok if there's a parent, and it's not nil.
-func super(child interface{}) (parent interface{}, ok bool) {
-       s, ok := child.(superer)
-       if !ok {
-               return
-       }
-       parent = s.Super()
-       ok = parent != nil
-       return
-}
-
 // Return the request that would include the given offset into the torrent data.
 func torrentOffsetRequest(torrentLength, pieceSize, chunkSize, offset int64) (
        r request, ok bool) {
index 993a7e32ef33deb13ee163f19655a7ea4f735581..ae1a10d32ddc0a473548029167a0380a6d754990 100644 (file)
@@ -517,10 +517,6 @@ func (t *Torrent) piecePartiallyDownloaded(piece int) bool {
        return t.pieces[piece].hasDirtyChunks()
 }
 
-func numChunksForPiece(chunkSize int, pieceSize int) int {
-       return (pieceSize + chunkSize - 1) / chunkSize
-}
-
 func (t *Torrent) usualPieceSize() int {
        return int(t.info.PieceLength)
 }