added functions to query an individual peer's upload and download limit
This commit is contained in:
parent
9239eed31e
commit
a7c87e14dd
|
@ -1,3 +1,4 @@
|
|||
* added functions to query an individual peer's upload and download limit
|
||||
* full support for BEP 21 (event=paused)
|
||||
* added share-mode feature for improving share ratios
|
||||
* merged all proxy settings into a single one
|
||||
|
|
|
@ -2055,6 +2055,8 @@ Its declaration looks like this::
|
|||
void set_sequential_download(bool sd) const;
|
||||
bool is_sequential_download() const;
|
||||
|
||||
int get_peer_upload_limit(tcp::endpoint ip);
|
||||
int get_peer_download_limit(tcp::endpoint ip);
|
||||
void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
||||
void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
||||
|
||||
|
@ -2487,16 +2489,19 @@ used sparingly.
|
|||
otherwise.
|
||||
|
||||
|
||||
set_peer_upload_limit() set_peer_download_limit()
|
||||
-------------------------------------------------
|
||||
get_peer_download_limit() get_peer_upload_limit() set_peer_upload_limit() set_peer_download_limit()
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
::
|
||||
|
||||
int get_peer_upload_limit(tcp::endpoint ip);
|
||||
int get_peer_download_limit(tcp::endpoint ip);
|
||||
void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
||||
void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
||||
|
||||
Works like ``set_upload_limit`` and ``set_download_limit`` respectively, but controls individual
|
||||
peer instead of the whole torrent.
|
||||
Works like ``get_upload_limit``, ``get_download_limit``, ``set_upload_limit`` and
|
||||
``set_download_limit`` respectively, but controls individual peer instead of the
|
||||
whole torrent.
|
||||
|
||||
pause() resume() is_paused()
|
||||
----------------------------
|
||||
|
|
|
@ -216,6 +216,8 @@ namespace libtorrent
|
|||
|
||||
void on_metadata_impl();
|
||||
|
||||
int get_upload_limit() const;
|
||||
int get_download_limit() const;
|
||||
void set_upload_limit(int limit);
|
||||
void set_download_limit(int limit);
|
||||
|
||||
|
|
|
@ -728,6 +728,8 @@ namespace libtorrent
|
|||
|
||||
void add_free_upload(int diff) { m_available_free_upload += diff; }
|
||||
|
||||
int get_peer_upload_limit(tcp::endpoint ip) const;
|
||||
int get_peer_download_limit(tcp::endpoint ip) const;
|
||||
void set_peer_upload_limit(tcp::endpoint ip, int limit);
|
||||
void set_peer_download_limit(tcp::endpoint ip, int limit);
|
||||
|
||||
|
|
|
@ -582,6 +582,8 @@ namespace libtorrent
|
|||
void set_sequential_download(bool sd) const;
|
||||
bool is_sequential_download() const;
|
||||
|
||||
int get_peer_upload_limit(tcp::endpoint ip) const;
|
||||
int get_peer_download_limit(tcp::endpoint ip) const;
|
||||
void set_peer_upload_limit(tcp::endpoint ip, int limit) const;
|
||||
void set_peer_download_limit(tcp::endpoint ip, int limit) const;
|
||||
|
||||
|
|
|
@ -3300,6 +3300,16 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(refcount() > 0);
|
||||
}
|
||||
|
||||
int peer_connection::get_upload_limit() const
|
||||
{
|
||||
return m_upload_limit;
|
||||
}
|
||||
|
||||
int peer_connection::get_download_limit() const
|
||||
{
|
||||
return m_download_limit;
|
||||
}
|
||||
|
||||
void peer_connection::set_upload_limit(int limit)
|
||||
{
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
|
|
|
@ -5212,6 +5212,24 @@ namespace libtorrent
|
|||
m_max_connections = limit;
|
||||
}
|
||||
|
||||
int torrent::get_peer_upload_limit(tcp::endpoint ip) const
|
||||
{
|
||||
TORRENT_ASSERT(m_ses.is_network_thread());
|
||||
peer_iterator i = std::find_if(m_connections.begin(), m_connections.end()
|
||||
, boost::bind(&peer_connection::remote, _1) == ip);
|
||||
if (i == m_connections.end()) return -1;
|
||||
return (*i)->get_upload_limit();
|
||||
}
|
||||
|
||||
int torrent::get_peer_download_limit(tcp::endpoint ip) const
|
||||
{
|
||||
TORRENT_ASSERT(m_ses.is_network_thread());
|
||||
peer_iterator i = std::find_if(m_connections.begin(), m_connections.end()
|
||||
, boost::bind(&peer_connection::remote, _1) == ip);
|
||||
if (i == m_connections.end()) return -1;
|
||||
return (*i)->get_download_limit();
|
||||
}
|
||||
|
||||
void torrent::set_peer_upload_limit(tcp::endpoint ip, int limit)
|
||||
{
|
||||
TORRENT_ASSERT(m_ses.is_network_thread());
|
||||
|
|
|
@ -240,6 +240,20 @@ namespace libtorrent
|
|||
TORRENT_ASYNC_CALL1(set_max_connections, max_connections);
|
||||
}
|
||||
|
||||
int torrent_handle::get_peer_upload_limit(tcp::endpoint ip) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_SYNC_CALL_RET1(int, -1, get_peer_upload_limit, ip);
|
||||
return r;
|
||||
}
|
||||
|
||||
int torrent_handle::get_peer_download_limit(tcp::endpoint ip) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_SYNC_CALL_RET1(int, -1, get_peer_download_limit, ip);
|
||||
return r;
|
||||
}
|
||||
|
||||
void torrent_handle::set_peer_upload_limit(tcp::endpoint ip, int limit) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
|
Loading…
Reference in New Issue