From: Matt Joiner Date: Tue, 13 May 2025 01:36:01 +0000 (+1000) Subject: Remove a bunch of unused stuff from linting X-Git-Tag: v1.59.0~146 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=e16d1078fc03aea2818f807345a5228f5f32dfcd;p=btrtrc.git Remove a bunch of unused stuff from linting --- diff --git a/client.go b/client.go index f950c15a..5627a8dc 100644 --- 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( diff --git a/global.go b/global.go index c44dfb37..b0c1ce4a 100644 --- 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 b32bef13..43f9c7f7 100644 --- 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 { diff --git a/peer_protocol/protocol.go b/peer_protocol/protocol.go index ebd0a7a1..7d087029 100644 --- a/peer_protocol/protocol.go +++ b/peer_protocol/protocol.go @@ -8,8 +8,6 @@ const ( Protocol = "\x13BitTorrent protocol" ) -var protocolStr = Protocol - func protocolBytes() []byte { return unsafe.Slice(unsafe.StringData(Protocol), len(Protocol)) } diff --git a/request-strategy/piece-request-order.go b/request-strategy/piece-request-order.go index 5f152466..3e572aed 100644 --- a/request-strategy/piece-request-order.go +++ b/request-strategy/piece-request-order.go @@ -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 { diff --git a/storage/possum/possum-provider.go b/storage/possum/possum-provider.go index 36b3d714..1410f4c3 100644 --- a/storage/possum/possum-provider.go +++ b/storage/possum/possum-provider.go @@ -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) { diff --git a/testing.go b/testing.go index e7854b8b..ac70b1c9 100644 --- a/testing.go +++ b/testing.go @@ -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 -} diff --git a/torrent.go b/torrent.go index eb32e654..aefda213 100644 --- a/torrent.go +++ b/torrent.go @@ -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() diff --git a/ut-holepunching_test.go b/ut-holepunching_test.go index ef7cda6b..591f3760 100644 --- a/ut-holepunching_test.go +++ b/ut-holepunching_test.go @@ -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 {