]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Remove a bunch of unused stuff from linting
authorMatt Joiner <anacrolix@gmail.com>
Tue, 13 May 2025 01:36:01 +0000 (11:36 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 13 May 2025 01:36:01 +0000 (11:36 +1000)
client.go
global.go
peer.go
peer_protocol/protocol.go
request-strategy/piece-request-order.go
storage/possum/possum-provider.go
testing.go
torrent.go
ut-holepunching_test.go

index f950c15a1f814f16f1710c1e4e616cf313bb897d..5627a8dc38cebb95f017d112fa34ed4aa1c29f2c 100644 (file)
--- a/client.go
+++ b/client.go
@@ -666,11 +666,6 @@ func (cl *Client) dopplegangerAddr(addr string) bool {
        return ok
 }
 
-// Returns a connection over UTP or TCP, whichever is first to connect.
-func (cl *Client) dialFirst(ctx context.Context, addr string) (res DialResult) {
-       return DialFirst(ctx, addr, cl.dialers)
-}
-
 // Returns a connection over UTP or TCP, whichever is first to connect.
 func DialFirst(ctx context.Context, addr string, dialers []Dialer) (res DialResult) {
        pool := dialPool{
@@ -713,13 +708,6 @@ func (cl *Client) noLongerHalfOpen(t *Torrent, addr string, attemptKey outgoingC
        }
 }
 
-func (cl *Client) countHalfOpenFromTorrents() (count int) {
-       for t := range cl.torrents {
-               count += t.numHalfOpenAttempts()
-       }
-       return
-}
-
 // Performs initiator handshakes and returns a connection. Returns nil *PeerConn if no connection
 // for valid reasons.
 func (cl *Client) initiateProtocolHandshakes(
index c44dfb37c876f8e0d8f8d62bbcdd2a39d6674cf6..b0c1ce4abc3a98653b8c9d1817fdd13891351a0d 100644 (file)
--- a/global.go
+++ b/global.go
@@ -50,10 +50,5 @@ var (
 
        messageTypesReceived = expvar.NewMap("messageTypesReceived")
 
-       // Track the effectiveness of Torrent.connPieceInclinationPool.
-       pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
-       pieceInclinationsNew    = expvar.NewInt("pieceInclinationsNew")
-       pieceInclinationsPut    = expvar.NewInt("pieceInclinationsPut")
-
        concurrentChunkWrites = expvar.NewInt("torrentConcurrentChunkWrites")
 )
diff --git a/peer.go b/peer.go
index b32bef139e59bdb2cc3632e6a7b9c8cad7216ee9..43f9c7f79f93cdfe27616c84148bd08537e8603c 100644 (file)
--- a/peer.go
+++ b/peer.go
@@ -192,10 +192,6 @@ func (cn *Peer) expectingChunks() bool {
        return haveAllowedFastRequests
 }
 
-func (cn *Peer) remoteChokingPiece(piece pieceIndex) bool {
-       return cn.peerChoking && !cn.peerAllowedFast.Contains(piece)
-}
-
 func (cn *Peer) cumInterest() time.Duration {
        ret := cn.priorInterest
        if cn.requestState.Interested {
index ebd0a7a17b7bb5c53dac6217ecf507f33a289184..7d08702925b4a880bf9cc34320e38b1de7775241 100644 (file)
@@ -8,8 +8,6 @@ const (
        Protocol = "\x13BitTorrent protocol"
 )
 
-var protocolStr = Protocol
-
 func protocolBytes() []byte {
        return unsafe.Slice(unsafe.StringData(Protocol), len(Protocol))
 }
index 5f15246643201b14220ac272a8f3d2809642ba54..3e572aedd25ac6fe961b1f3c7bb2819d6ab8e29b 100644 (file)
@@ -73,13 +73,6 @@ func (me *PieceRequestOrder) Update(
        return old.Value != state
 }
 
-func (me *PieceRequestOrder) existingItemForKey(key PieceRequestOrderKey) PieceRequestOrderItem {
-       return PieceRequestOrderItem{
-               Key:   key,
-               State: me.keys[key],
-       }
-}
-
 func (me *PieceRequestOrder) Delete(key PieceRequestOrderKey) (deleted bool) {
        state, ok := me.keys[key]
        if !ok {
index 36b3d714bcde08bffb3c3e029fbbb4a912dfb248..1410f4c39b6161caad27dca129634e3c8adc28e3 100644 (file)
@@ -30,7 +30,6 @@ var _ interface {
 type chunkReader struct {
        r      possum.Reader
        values []consecutiveValue
-       keys   []int64
 }
 
 func (c chunkReader) ReadAt(p []byte, off int64) (n int, err error) {
index e7854b8bb9f4d33e2fdc5fa6e09889a27c0ada50..ac70b1c9e2e19def0eb17124a1ba7749dbfc70a5 100644 (file)
@@ -5,8 +5,6 @@ import (
        "time"
 
        "github.com/anacrolix/log"
-       "github.com/stretchr/testify/require"
-
        pp "github.com/anacrolix/torrent/peer_protocol"
 )
 
@@ -36,13 +34,3 @@ func TestingConfig(t testing.TB) *ClientConfig {
        //})
        return cfg
 }
-
-func readChannelTimeout[T any](t *testing.T, channel chan T, duration time.Duration) interface{} {
-       select {
-       case s := <-channel:
-               return s
-       case <-time.After(duration):
-               require.Fail(t, "Timeout reading observer channel.")
-       }
-       return nil
-}
index eb32e6541157102ea2ab072c19eabc0c29fe6683..aefda213bcbeee599b8e2484310614ba814b11a2 100644 (file)
@@ -311,20 +311,6 @@ func (t *Torrent) pieceCompleteUncached(piece pieceIndex) storage.Completion {
        return t.pieces[piece].Storage().Completion()
 }
 
-// There's a connection to that address already.
-func (t *Torrent) addrActive(addr string) bool {
-       if _, ok := t.halfOpen[addr]; ok {
-               return true
-       }
-       for c := range t.conns {
-               ra := c.RemoteAddr
-               if ra.String() == addr {
-                       return true
-               }
-       }
-       return false
-}
-
 func (t *Torrent) appendUnclosedConns(ret []*PeerConn) []*PeerConn {
        return t.appendConns(ret, func(conn *PeerConn) bool {
                return !conn.closed.IsSet()
@@ -1114,13 +1100,6 @@ func (t *Torrent) chunksPerRegularPiece() chunkIndexType {
        return t._chunksPerRegularPiece
 }
 
-func (t *Torrent) numChunks() RequestIndex {
-       if t.numPieces() == 0 {
-               return 0
-       }
-       return RequestIndex(t.numPieces()-1)*t.chunksPerRegularPiece() + t.pieceNumChunks(t.numPieces()-1)
-}
-
 func (t *Torrent) pendAllChunkSpecs(pieceIndex pieceIndex) {
        t.dirtyChunks.RemoveRange(
                uint64(t.pieceRequestIndexOffset(pieceIndex)),
@@ -2706,13 +2685,6 @@ func (t *Torrent) clearPieceTouchers(pi pieceIndex) {
        }
 }
 
-func (t *Torrent) peersAsSlice() (ret []*Peer) {
-       t.iterPeers(func(p *Peer) {
-               ret = append(ret, p)
-       })
-       return
-}
-
 func (t *Torrent) queueInitialPieceCheck(i pieceIndex) {
        if !t.initialPieceCheckDisabled && !t.piece(i).storageCompletionOk {
                t.queuePieceCheck(i)
@@ -3317,13 +3289,6 @@ func (t *Torrent) trySendHolepunchRendezvous(addrPort netip.AddrPort) error {
        return nil
 }
 
-func (t *Torrent) numHalfOpenAttempts() (num int) {
-       for _, attempts := range t.halfOpen {
-               num += len(attempts)
-       }
-       return
-}
-
 func (t *Torrent) getDialTimeoutUnlocked() time.Duration {
        cl := t.cl
        cl.rLock()
index ef7cda6ba7770455c22576466e0083cc7cf81c6d..591f3760757ac6e93227009a55a3fbc682d8ba3d 100644 (file)
@@ -392,8 +392,8 @@ func TestUtpDirectDialMsg(t *testing.T) {
                        }
                        defer writer.Close()
                        reader, err := second.Accept()
-                       defer reader.Close()
                        c.Assert(err, qt.IsNil)
+                       defer reader.Close()
                        return writeAndReadMsg(reader, writer)
                }()
                if err == nil {