From: Matt Joiner Date: Thu, 3 Jul 2025 06:04:52 +0000 (+1000) Subject: Deprecate WebSeedTorrentMaxRequests X-Git-Tag: v1.59.0~45 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=2fae374f70035c557227e0b78958d43115c4e19e;p=btrtrc.git Deprecate WebSeedTorrentMaxRequests --- diff --git a/deprecated.go b/deprecated.go index 6836c598..6c185fe2 100644 --- a/deprecated.go +++ b/deprecated.go @@ -1,7 +1,20 @@ package torrent +import ( + "github.com/anacrolix/torrent/webseed" +) + // Deprecated: The names doesn't reflect the actual behaviour. You can only add sources. Use // AddSources instead. func (t *Torrent) UseSources(sources []string) { t.AddSources(sources) } + +// Deprecated: Max requests are done Client-wide by host or cost-function applied to the webseed +// URL. Max concurrent requests to a WebSeed for a given torrent. This could easily be reimplemented +// by not assigning requests to a (Torrent, webseed URL) tuple keyed component in the webseed plan. +func WebSeedTorrentMaxRequests(maxRequests int) AddWebSeedsOpt { + return func(c *webseed.Client) { + c.MaxRequests = maxRequests + } +} diff --git a/torrent.go b/torrent.go index d681c868..6ba0858a 100644 --- a/torrent.go +++ b/torrent.go @@ -2999,13 +2999,6 @@ type AddWebSeedsOpt func(*webseed.Client) // TODO: Add a webseed http.Client option. -// Max concurrent requests to a WebSeed for a given torrent. -func WebSeedTorrentMaxRequests(maxRequests int) AddWebSeedsOpt { - return func(c *webseed.Client) { - c.MaxRequests = maxRequests - } -} - // Sets the WebSeed trailing path escaper for a webseed.Client. func WebSeedPathEscaper(custom webseed.PathEscaper) AddWebSeedsOpt { return func(c *webseed.Client) { @@ -3040,7 +3033,8 @@ func (t *Torrent) addWebSeed(url string, opts ...AddWebSeedsOpt) bool { // number is based on keeping at least one connection actively downloading while another request // is fired off, and ensuring race detection works. Downloading Sintel // (08ada5a7a6183aae1e09d831df6748d566095a10) from "https://webtorrent.io/torrents/" is a good - // test. + // test. Note since per-Torrent max requests for webseeds is not active, this doesn't do + // anything. const defaultMaxRequests = 2 ws := webseedPeer{ peer: Peer{