View Source YaBTT.Query.Peers (YaBTT v0.1.5)
This module is used to query the peers who hold the target torrent.
You can use the environment variable YABTT_QUERY_LIMIT
to
limit the number of peers returned per query. The value default to 50, but we recommend
you to set it smaller, like 30. Because this value is important to performance.
Practice tells us that even 30 peers is plenty.
Implementer's Note
Even 30 peers is plenty, the official client version 3 in fact only actively forms new connections if it has less than 30 peers and will refuse connections if it has 55. This value is important to performance. When a new piece has completed download, HAVE messages (see below) will need to be sent to most active peers. As a result the cost of broadcast traffic grows in direct proportion to the number of peers. Above 25, new peers are highly unlikely to increase download speed. UI designers are strongly advised to make this obscure and hard to change as it is very rare to be useful to do so.
As required by the specification, the queried peers will be random.
Link to this section Summary
Functions
Query the peers who hold the target torrent by YaBTT.Deco.t/0
.
Query the peers who hold the target torrent.
Link to this section Types
@type opts() :: YaBTT.Deco.config()
Link to this section Functions
@spec query(YaBTT.Deco.t()) :: map()
Query the peers who hold the target torrent by YaBTT.Deco.t/0
.
Query the peers who hold the target torrent.
We have implemented the [BitTorrent Tracker Protocol Extensions][protocol_extensions]. That means
that we can use :compact
and :no_peer_id
for option mode
to control the return of peer.
You can see the specific meaning and practical examples of the options below.
mode
Mode
:compact
: return a binary string of peers in compact format.In the mode, the peers with IPv4 list is replaced by a peers string with 6 bytes per peer. For each peer, the first 4 bytes are the IP address and the last 2 bytes are the port number. The length of the whole peers will be a multiple of 6 (6 × the number of peers in peers).
If the peers with Ipv6, the situation is similar, but the each peer is 18 bytes (The first 16 bytes are the IP address and the last 2 bytes are the port number).
:no_peer_id
: return a list of peers withoutpeer id
.This option will be ignored if
:compact
mode is enabled.nil
: return a list of peers with full information (ip
,port
and thepeer id
).
parameters
Parameters
id
: the id of the target torrentopts
: the options to set the return format
examples
Examples
iex> YaBTT.Query.Peers.query("info_hash", %{mode: :compact})
iex> YaBTT.Query.Peers.query("info_hash", %{mode: :no_peer_id})
iex> YaBTT.Query.Peers.query("info_hash", %{})