From: Matt Joiner Date: Thu, 31 Jul 2025 01:50:52 +0000 (+1000) Subject: Tidy X-Git-Tag: v1.59.0~2^2~82 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=3d194508c9aa052ade0e4b380b0e690b7dfb2102;p=btrtrc.git Tidy --- diff --git a/internal/request-strategy/order.go b/internal/request-strategy/order.go index d3ede920..387b4db7 100644 --- a/internal/request-strategy/order.go +++ b/internal/request-strategy/order.go @@ -68,8 +68,8 @@ func GetRequestablePieces( ) pro.tree.Scan(func(item PieceRequestOrderItem) bool { ih := item.Key.InfoHash - var t = input.Torrent(ih) - var piece = t.Piece(item.Key.Index) + t := input.Torrent(ih) + piece := t.Piece(item.Key.Index) pieceLength := t.PieceLength() // Storage limits will always apply against requestable pieces, since we need to keep the // highest priority pieces, even if they're complete or in an undesirable state. diff --git a/torrent.go b/torrent.go index 3960d7d4..e684360b 100644 --- a/torrent.go +++ b/torrent.go @@ -2406,20 +2406,14 @@ func (t *Torrent) newConnsAllowed() bool { if t.closed.IsSet() { return false } - if !t.needData() && (!t.seeding() || !t.haveAnyPieces()) { - return false + if t.needData() { + return true } - return true + return t.seeding() && t.haveAnyPieces() } func (t *Torrent) wantAnyConns() bool { - if !t.networkingEnabled.Bool() { - return false - } - if t.closed.IsSet() { - return false - } - if !t.needData() && (!t.seeding() || !t.haveAnyPieces()) { + if !t.newConnsAllowed() { return false } return len(t.conns) < t.maxEstablishedConns @@ -2430,6 +2424,7 @@ func (t *Torrent) wantOutgoingConns() bool { return false } if len(t.conns) < t.maxEstablishedConns { + // Shortcut: We can take any connection direction right now. return true } numIncomingConns := len(t.conns) - t.numOutgoingConns() @@ -2444,6 +2439,7 @@ func (t *Torrent) wantIncomingConns() bool { return false } if len(t.conns) < t.maxEstablishedConns { + // Shortcut: We can take any connection direction right now. return true } numIncomingConns := len(t.conns) - t.numOutgoingConns()