]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Remove a bunch of dead code
authorMatt Joiner <anacrolix@gmail.com>
Sun, 28 Dec 2014 01:51:09 +0000 (12:51 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 28 Dec 2014 01:51:09 +0000 (12:51 +1100)
connection.go
dht/bitcount_test.go [moved from dht/bitcount.go with 100% similarity]
dht/dht.go
misc.go
torrent.go

index eaabaacaa66510a8dcb557a2e931749f8445b14c..3aa0a467ebf04e21ddd742c70833a9a98461bb2d 100644 (file)
@@ -328,11 +328,6 @@ func (c *connection) SetInterested(interested bool) {
        c.Interested = interested
 }
 
-var (
-       // Four consecutive zero bytes that comprise a keep alive on the wire.
-       keepAliveBytes [4]byte
-)
-
 // Writes buffers to the socket from the write channel.
 func (conn *connection) writer() {
        // Reduce write syscalls.
similarity index 100%
rename from dht/bitcount.go
rename to dht/bitcount_test.go
index 352a6f59cc3c4c5e5f1385e38c7aa5e6f67d06ad..afb92b30a7dfd954d997279be2c874c7d9a6fe6e 100644 (file)
@@ -1,16 +1,11 @@
 package dht
 
 import (
-       "bitbucket.org/anacrolix/go.torrent/iplist"
-       "bitbucket.org/anacrolix/go.torrent/logonce"
-       "bitbucket.org/anacrolix/go.torrent/util"
-       "bitbucket.org/anacrolix/sync"
        "crypto"
        _ "crypto/sha1"
        "encoding/binary"
        "errors"
        "fmt"
-       "github.com/anacrolix/libtorgo/bencode"
        "io"
        "log"
        "math/big"
@@ -18,6 +13,12 @@ import (
        "net"
        "os"
        "time"
+
+       "bitbucket.org/anacrolix/go.torrent/iplist"
+       "bitbucket.org/anacrolix/go.torrent/logonce"
+       "bitbucket.org/anacrolix/go.torrent/util"
+       "bitbucket.org/anacrolix/sync"
+       "github.com/anacrolix/libtorgo/bencode"
 )
 
 const maxNodes = 10000
@@ -855,49 +856,6 @@ func (t *transaction) setOnResponse(f func(m Msg)) {
        t.onResponse = f
 }
 
-func unmarshalNodeInfoBinary(b []byte) (ret []NodeInfo, err error) {
-       if len(b)%26 != 0 {
-               err = errors.New("bad buffer length")
-               return
-       }
-       ret = make([]NodeInfo, 0, len(b)/26)
-       for i := 0; i < len(b); i += 26 {
-               var ni NodeInfo
-               err = ni.UnmarshalCompact(b[i : i+26])
-               if err != nil {
-                       return
-               }
-               ret = append(ret, ni)
-       }
-       return
-}
-
-func extractNodes(d Msg) (nodes []NodeInfo, err error) {
-       if d["y"] != "r" {
-               return
-       }
-       r, ok := d["r"]
-       if !ok {
-               err = errors.New("missing r dict")
-               return
-       }
-       rd, ok := r.(map[string]interface{})
-       if !ok {
-               err = errors.New("bad r value type")
-               return
-       }
-       n, ok := rd["nodes"]
-       if !ok {
-               return
-       }
-       ns, ok := n.(string)
-       if !ok {
-               err = errors.New("bad nodes value type")
-               return
-       }
-       return unmarshalNodeInfoBinary([]byte(ns))
-}
-
 func (s *Server) liftNodes(d Msg) {
        if d["y"] != "r" {
                return
diff --git a/misc.go b/misc.go
index 5ac9d53874f2776bd70242c8a64ecb7566c33be7..85b8f588411dfbf95f02196578884865cf00b7c1 100644 (file)
--- a/misc.go
+++ b/misc.go
@@ -99,22 +99,6 @@ func newRequest(index, begin, length peer_protocol.Integer) request {
        return request{index, chunkSpec{begin, length}}
 }
 
-type pieceByBytesPendingSlice struct {
-       Pending, Indices []peer_protocol.Integer
-}
-
-func (pcs pieceByBytesPendingSlice) Len() int {
-       return len(pcs.Indices)
-}
-
-func (me pieceByBytesPendingSlice) Less(i, j int) bool {
-       return me.Pending[me.Indices[i]] < me.Pending[me.Indices[j]]
-}
-
-func (me pieceByBytesPendingSlice) Swap(i, j int) {
-       me.Indices[i], me.Indices[j] = me.Indices[j], me.Indices[i]
-}
-
 var (
        // Requested data not yet available.
        ErrDataNotReady = errors.New("data not ready")
index f6ced0e78ce67e392821e14189add9d20278ab2c..21a3e4130f2d5f6927b98c51e2bafc99fb1c5ecb 100644 (file)
@@ -2,7 +2,6 @@ package torrent
 
 import (
        "container/heap"
-       "container/list"
        "fmt"
        "io"
        "log"
@@ -11,11 +10,10 @@ import (
        "sync"
        "time"
 
-       "bitbucket.org/anacrolix/go.torrent/util"
-
        "bitbucket.org/anacrolix/go.torrent/mmap_span"
        pp "bitbucket.org/anacrolix/go.torrent/peer_protocol"
        "bitbucket.org/anacrolix/go.torrent/tracker"
+       "bitbucket.org/anacrolix/go.torrent/util"
        "github.com/anacrolix/libtorgo/bencode"
        "github.com/anacrolix/libtorgo/metainfo"
 )
@@ -36,15 +34,6 @@ func (t *torrent) PieceNumPendingBytes(index pp.Integer) (count pp.Integer) {
        return
 }
 
-type pieceBytesLeft struct {
-       Piece, BytesLeft int
-}
-
-type torrentPiece struct {
-       piece
-       bytesLeftElement *list.Element
-}
-
 type peersKey struct {
        IPBytes string
        Port    int
@@ -59,7 +48,7 @@ type torrent struct {
        ceasingNetworking chan struct{}
 
        InfoHash InfoHash
-       Pieces   []*torrentPiece
+       Pieces   []*piece
        length   int64
        // Prevent mutations to Data memory maps while in use as they're not safe.
        dataLock sync.RWMutex
@@ -186,7 +175,7 @@ func (t *torrent) setMetadata(md metainfo.Info, dataDir string, infoBytes []byte
        }
        t.length = t.Data.Size()
        for _, hash := range infoPieceHashes(&md) {
-               piece := &torrentPiece{}
+               piece := &piece{}
                piece.Event.L = eventLocker
                util.CopyExact(piece.Hash[:], hash)
                t.Pieces = append(t.Pieces, piece)