Version: | 2.0.11

home

Table of contents

- peer_class_info
- peer_class_type_filter
  - remove() add()
  - allow() disallow()
  - apply()
  - enum socket_type_t

[report issue]

# peer_class_info

Declared in "libtorrent/peer_class.hpp"

holds settings for a peer class. Used in set_peer_class() and get_peer_class() calls.

    struct peer_class_info
    {
       bool ignore_unchoke_slots;
       int connection_limit_factor;
       std::string label;
       int upload_limit;
       int download_limit;
       int upload_priority;
       int download_priority;
    };

[report issue]

ignore_unchoke_slots
  `ignore_unchoke_slots` determines whether peers should always unchoke a peer, regardless of the choking algorithm, or if it should honor the unchoke slot limits. It's used for local peers by default. If any of the peer classes a peer belongs to has this set to true, that peer will be unchoked at all times.

[report issue]

connection_limit_factor
  adjusts the connection limit (global and per torrent) that applies to this peer class. By default, local peers are allowed to exceed the normal connection limit for instance. This is specified as a percent factor. 100 makes the peer class apply normally to the limit. 200 means as long as there are fewer connections than twice the limit, we accept this peer. This factor applies both to the global connection limit and the per-torrent limit. Note that if not used carefully one peer class can potentially completely starve out all other over time.

[report issue]

label
  not used by libtorrent. It's intended as a potentially user-facing identifier of this peer class.

[report issue]

upload_limit download_limit
  transfer rates limits for the whole peer class. They are specified in bytes per second and apply to the sum of all peers that are members of this class.

[report issue]

upload_priority download_priority
  relative priorities used by the bandwidth allocator in the rate limiter. If no rate limits are in use, the priority is not used either. Priorities start at 1 (0 is not a valid priority) and may not exceed 255.

[report issue]

# peer_class_type_filter

Declared in "libtorrent/peer_class_type_filter.hpp"

`peer_class_type_filter` is a simple container for rules for adding and subtracting peer-classes from peers. It is applied after the peer class filter is applied (which is based on the peer's IP address).

    struct peer_class_type_filter
    {
       void remove (socket_type_t const st, peer_class_t const peer_class);
       void add (socket_type_t const st, peer_class_t const peer_class);
       void allow (socket_type_t const st, peer_class_t const peer_class);
       void disallow (socket_type_t const st, peer_class_t const peer_class);
       std::uint32_t apply (socket_type_t const st, std::uint32_t peer_class_mask);
       friend bool operator== (peer_class_type_filter const& lhs
          , peer_class_type_filter const& rhs);

       enum socket_type_t
       {
          tcp_socket,
          utp_socket,
          ssl_tcp_socket,
          ssl_utp_socket,
          i2p_socket,
          num_socket_types,
       };
    };

[report issue]

## remove() add()

    void remove (socket_type_t const st, peer_class_t const peer_class);
    void add (socket_type_t const st, peer_class_t const peer_class);

`add()` and `remove()` adds and removes a peer class to be added to new peers based on socket type.

[report issue]

## allow() disallow()

    void allow (socket_type_t const st, peer_class_t const peer_class);
    void disallow (socket_type_t const st, peer_class_t const peer_class);

`disallow()` and `allow()` adds and removes a peer class to be removed from new peers based on socket type.

The `peer_class` argument cannot be greater than 31. The bitmasks representing peer classes in the `peer_class_type_filter` are 32 bits.

[report issue]

## apply()

    std::uint32_t apply (socket_type_t const st, std::uint32_t peer_class_mask);

takes a bitmask of peer classes and returns a new bitmask of peer classes after the rules have been applied, based on the socket type argument (`st`).

[report issue]

## enum socket_type_t

Declared in "libtorrent/peer_class_type_filter.hpp"

name | value | description
--- | --- | ---
tcp_socket | 0 | these match the socket types from socket_type.hpp shifted one down
utp_socket | 1 |
ssl_tcp_socket | 2 |
ssl_utp_socket | 3 |
i2p_socket | 4 |
num_socket_types | 5 |