added functions to query an individual peer's upload and download limit

This commit is contained in:
Arvid Norberg
2010-10-01 16:09:22 +00:00
parent 9239eed31e
commit a7c87e14dd
8 changed files with 58 additions and 4 deletions

View File

@@ -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());