Remove unused code
This commit is contained in:
parent
33006eeb20
commit
3ba991e38a
26
client.go
26
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 {
|
||||
|
|
4
file.go
4
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)
|
||||
|
|
|
@ -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")
|
||||
|
|
16
listen.go
16
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"
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
29
torrent.go
29
torrent.go
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue