.. include:: header.rst

`home`__

__ reference.html

.. contents:: Table of contents
  :depth: 2
  :backlinks: none

.. raw:: html

	<a name="peer_class_type_filter"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:class+peer_class_type_filter&labels=documentation&body=Documentation+under+heading+%22class+peer_class_type_filter%22+could+be+improved">report issue</a>]</span>



peer_class_type_filter
----------------------

Declared in "`libtorrent/peer_class_type_filter.hpp`__"


__ include/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).




.. parsed-literal::
	

	struct peer_class_type_filter
	{
	   void **add** (socket\_type\_t const st, peer\_class\_t const peer\_class);
	   void **remove** (socket\_type\_t const st, peer\_class\_t const peer\_class);
	   void **disallow** (socket\_type\_t const st, peer\_class\_t const peer\_class);
	   void **allow** (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,
	   };
	};

.. raw:: html

	<a name="remove()"></a>
	<a name="add()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:peer_class_type_filter%3A%3A%5Bremove%28%29+add%28%29%5D&labels=documentation&body=Documentation+under+heading+%22peer_class_type_filter%3A%3A%5Bremove%28%29+add%28%29%5D%22+could+be+improved">report issue</a>]</span>



remove() add()
..............

.. parsed-literal::
	
	void **add** (socket\_type\_t const st, peer\_class\_t const peer\_class);
	void **remove** (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.



.. raw:: html

	<a name="disallow()"></a>
	<a name="allow()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:peer_class_type_filter%3A%3A%5Bdisallow%28%29+allow%28%29%5D&labels=documentation&body=Documentation+under+heading+%22peer_class_type_filter%3A%3A%5Bdisallow%28%29+allow%28%29%5D%22+could+be+improved">report issue</a>]</span>



disallow() allow()
..................

.. parsed-literal::
	
	void **disallow** (socket\_type\_t const st, peer\_class\_t const peer\_class);
	void **allow** (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.



.. raw:: html

	<a name="apply()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:peer_class_type_filter%3A%3A%5Bapply%28%29%5D&labels=documentation&body=Documentation+under+heading+%22peer_class_type_filter%3A%3A%5Bapply%28%29%5D%22+could+be+improved">report issue</a>]</span>



apply()
.......

.. parsed-literal::
	
	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``).



.. raw:: html

	<a name="socket_type_t"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:enum+socket_type_t&labels=documentation&body=Documentation+under+heading+%22enum+socket_type_t%22+could+be+improved">report issue</a>]</span>



enum socket_type_t
..................

Declared in "`libtorrent/peer_class_type_filter.hpp`__"


__ include/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     |                                                   |
+------------------+-------+---------------------------------------------------+



.. raw:: html

	<a name="peer_class_info"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:class+peer_class_info&labels=documentation&body=Documentation+under+heading+%22class+peer_class_info%22+could+be+improved">report issue</a>]</span>



peer_class_info
---------------

Declared in "`libtorrent/peer_class.hpp`__"


__ include/libtorrent/peer_class.hpp

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


__ reference-Session.html#set_peer_class()
__ reference-Session.html#get_peer_class()


.. parsed-literal::
	

	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;
	};

.. raw:: html

	<a name="ignore_unchoke_slots"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:peer_class_info%3A%3A%5Bignore_unchoke_slots%5D&labels=documentation&body=Documentation+under+heading+%22peer_class_info%3A%3A%5Bignore_unchoke_slots%5D%22+could+be+improved">report issue</a>]</span>


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.
	


.. raw:: html

	<a name="connection_limit_factor"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:peer_class_info%3A%3A%5Bconnection_limit_factor%5D&labels=documentation&body=Documentation+under+heading+%22peer_class_info%3A%3A%5Bconnection_limit_factor%5D%22+could+be+improved">report issue</a>]</span>


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.
	


.. raw:: html

	<a name="label"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:peer_class_info%3A%3A%5Blabel%5D&labels=documentation&body=Documentation+under+heading+%22peer_class_info%3A%3A%5Blabel%5D%22+could+be+improved">report issue</a>]</span>


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


.. raw:: html

	<a name="upload_limit"></a>
	<a name="download_limit"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:peer_class_info%3A%3A%5Bupload_limit+download_limit%5D&labels=documentation&body=Documentation+under+heading+%22peer_class_info%3A%3A%5Bupload_limit+download_limit%5D%22+could+be+improved">report issue</a>]</span>


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.
	


.. raw:: html

	<a name="upload_priority"></a>
	<a name="download_priority"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:peer_class_info%3A%3A%5Bupload_priority+download_priority%5D&labels=documentation&body=Documentation+under+heading+%22peer_class_info%3A%3A%5Bupload_priority+download_priority%5D%22+could+be+improved">report issue</a>]</span>


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.
	




.. _`BEP 3`: https://www.bittorrent.org/beps/bep_0003.html
.. _`BEP 17`: https://www.bittorrent.org/beps/bep_0017.html
.. _extensions: manual-ref.html#extensions
.. _`BEP 52`: https://www.bittorrent.org/beps/bep_0052.html
.. _`BEP 19`: https://www.bittorrent.org/beps/bep_0019.html
.. _`BEP 38`: https://www.bittorrent.org/beps/bep_0038.html
.. _`rate based choking`: manual-ref.html#rate-based-choking
.. _`BEP 42`: https://www.bittorrent.org/beps/bep_0042.html
