]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Remove unused code
authorMatt Joiner <anacrolix@gmail.com>
Tue, 27 Nov 2018 12:57:17 +0000 (23:57 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 27 Nov 2018 12:57:17 +0000 (23:57 +1100)
client.go
file.go
global.go
listen.go
multiless.go
socket.go
torrent.go

index d348a1d81623f0682e21ab4cda075d618da42176..219198853683c42063a03229c4a9a9d81779ec64 100644 (file)
--- a/client.go
+++ b/client.go
@@ -308,15 +308,6 @@ func (cl *Client) newDhtServer(conn net.PacketConn) (s *dht.Server, err error) {
        return
 }
 
-func firstNonEmptyString(ss ...string) string {
-       for _, s := range ss {
-               if s != "" {
-                       return s
-               }
-       }
-       return ""
-}
-
 func (cl *Client) Closed() <-chan struct{} {
        cl.lock()
        defer cl.unlock()
@@ -490,23 +481,6 @@ func (cl *Client) dopplegangerAddr(addr string) bool {
        return ok
 }
 
-func ipNetworkSuffix(allowIpv4, allowIpv6 bool) string {
-       switch {
-       case allowIpv4 && allowIpv6:
-               return ""
-       case allowIpv4 && !allowIpv6:
-               return "4"
-       case !allowIpv4 && allowIpv6:
-               return "6"
-       default:
-               panic("unhandled ip network combination")
-       }
-}
-
-func dialUTP(ctx context.Context, addr string, sock utpSocket) (c net.Conn, err error) {
-       return sock.DialContext(ctx, "", addr)
-}
-
 var allPeerNetworks = []string{"tcp4", "tcp6", "udp4", "udp6"}
 
 func peerNetworkEnabled(network string, cfg *ClientConfig) bool {
diff --git a/file.go b/file.go
index 4074700a53d31ca6afc88c008c808c408c559464..15f5e2395b51a97fe06092ca85059c1ff454a0f9 100644 (file)
--- a/file.go
+++ b/file.go
@@ -91,10 +91,6 @@ func byteRegionExclusivePieces(off, size, pieceSize int64) (begin, end int) {
        return
 }
 
-func (f *File) exclusivePieces() (begin, end int) {
-       return byteRegionExclusivePieces(f.offset, f.length, int64(f.t.usualPieceSize()))
-}
-
 // Deprecated: Use File.SetPriority.
 func (f *File) Cancel() {
        f.SetPriority(PiecePriorityNone)
index 7418cd900a5860005a527b39d2a3873ab83e73a3..b66dd9dd816dd76cd27ceb522894190f1694da71 100644 (file)
--- a/global.go
+++ b/global.go
@@ -34,7 +34,6 @@ var (
        pieceHashedCorrect    = expvar.NewInt("pieceHashedCorrect")
        pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
 
-       peerExtensions                    = expvar.NewMap("peerExtensions")
        completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
        // Count of connections to peer with same client ID.
        connsToSelf        = expvar.NewInt("connsToSelf")
index 0e1b5c0d309b88e30498007673f2590f68f77614..29015c100aa2e20d812a47b5a81e68cc910526b6 100644 (file)
--- a/listen.go
+++ b/listen.go
@@ -2,22 +2,6 @@ package torrent
 
 import "strings"
 
-type peerNetworks struct {
-       tcp4, tcp6 bool
-       utp4, utp6 bool
-}
-
-func handleErr(h func(), fs ...func() error) error {
-       for _, f := range fs {
-               err := f()
-               if err != nil {
-                       h()
-                       return err
-               }
-       }
-       return nil
-}
-
 func LoopbackListenHost(network string) string {
        if strings.Contains(network, "4") {
                return "127.0.0.1"
index 20ba2bd7255323cf09d2125587fd20d03b7be70f..bdc851d8e8089ca66a2749b8e7ba881dc0aa33cd 100644 (file)
@@ -1,9 +1,5 @@
 package torrent
 
-func strictCmp(same, less bool) cmper {
-       return func() (bool, bool) { return same, less }
-}
-
 type (
        cmper     func() (same, less bool)
        multiLess struct {
index e7a200febadffc31ecaaf0c62bdc6d541c5d06d3..4d343eef25be8b5f672ccf353b95ee7f3c29950e 100644 (file)
--- a/socket.go
+++ b/socket.go
@@ -90,14 +90,6 @@ func (me tcpSocket) dial(ctx context.Context, addr string) (net.Conn, error) {
        return me.d(ctx, addr)
 }
 
-func setPort(addr string, port int) string {
-       host, _, err := net.SplitHostPort(addr)
-       if err != nil {
-               panic(err)
-       }
-       return net.JoinHostPort(host, strconv.FormatInt(int64(port), 10))
-}
-
 func listenAll(networks []string, getHost func(string) string, port int, proxyURL string, f firewallCallback) ([]socket, error) {
        if len(networks) == 0 {
                return nil, nil
index 6a455e1ff4987e61923d4706433626b4dd943dde..b376ba599431c0cb41064fbe42e7767099e40a9d 100644 (file)
@@ -35,11 +35,6 @@ func (t *Torrent) chunkIndexSpec(chunkIndex pp.Integer, piece pieceIndex) chunkS
        return chunkIndexSpec(chunkIndex, t.pieceLength(piece), t.chunkSize)
 }
 
-type peersKey struct {
-       IPBytes string
-       Port    int
-}
-
 // Maintains state of torrent within a Client.
 type Torrent struct {
        // Torrent-level aggregate statistics. First in struct to ensure 64-bit
@@ -292,10 +287,6 @@ func (t *Torrent) haveMetadataPiece(piece int) bool {
        }
 }
 
-func (t *Torrent) metadataSizeKnown() bool {
-       return t.metadataBytes != nil
-}
-
 func (t *Torrent) metadataSize() int {
        return len(t.metadataBytes)
 }
@@ -791,18 +782,6 @@ func chunkIndex(cs chunkSpec, chunkSize pp.Integer) int {
        return int(cs.Begin / chunkSize)
 }
 
-func (t *Torrent) wantPiece(r request) bool {
-       if !t.wantPieceIndex(pieceIndex(r.Index)) {
-               return false
-       }
-       if t.pieces[r.Index].pendingChunk(r.chunkSpec, t.chunkSize) {
-               return true
-       }
-       // TODO: What about pieces that were wanted, but aren't now, and aren't
-       // completed either? That used to be done here.
-       return false
-}
-
 func (t *Torrent) wantPieceIndex(index pieceIndex) bool {
        if !t.haveInfo() {
                return false
@@ -1125,14 +1104,6 @@ func (t *Torrent) maybeCompleteMetadata() error {
        return nil
 }
 
-func (t *Torrent) readerPieces() (ret bitmap.Bitmap) {
-       t.forReaderOffsetPieces(func(begin, end pieceIndex) bool {
-               ret.AddRange(bitmap.BitIndex(begin), bitmap.BitIndex(end))
-               return true
-       })
-       return
-}
-
 func (t *Torrent) readerPiecePriorities() (now, readahead bitmap.Bitmap) {
        t.forReaderOffsetPieces(func(begin, end pieceIndex) bool {
                if end > begin {