forked from premiere/premiere-libtorrent
make torrent priority stricly prefer unchoking peers on high priority torrents
This commit is contained in:
parent
e07e8b2f98
commit
eaea22be71
|
@ -2934,8 +2934,9 @@ consume, even if there's is more quota. Other peers will still be weighed in whe
|
||||||
bandwidth is being distributed. With other words, bandwidth is not distributed strictly
|
bandwidth is being distributed. With other words, bandwidth is not distributed strictly
|
||||||
in order of priority, but the priority is used as a weight.
|
in order of priority, but the priority is used as a weight.
|
||||||
|
|
||||||
Torrents with higher priority are also more likely to have its peers unchoked, to
|
Peers whose Torrent has a higher priority will take precedence when distributing unchoke slots.
|
||||||
distribute more upload capacity to them.
|
This is a strict prioritization where every interested peer on a high priority torrent will
|
||||||
|
be unchoked before any other, lower priority, torrents have any peers unchoked.
|
||||||
|
|
||||||
use_interface()
|
use_interface()
|
||||||
---------------
|
---------------
|
||||||
|
|
|
@ -422,24 +422,23 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(p);
|
TORRENT_ASSERT(p);
|
||||||
peer_connection const& rhs = *p;
|
peer_connection const& rhs = *p;
|
||||||
|
|
||||||
size_type c1;
|
// if one peer belongs to a higher priority torrent than the other one
|
||||||
size_type c2;
|
// that one should be unchoked.
|
||||||
|
|
||||||
// first compare how many bytes they've sent us
|
|
||||||
c1 = m_statistics.total_payload_download() - m_downloaded_at_last_unchoke;
|
|
||||||
c2 = rhs.m_statistics.total_payload_download() - rhs.m_downloaded_at_last_unchoke;
|
|
||||||
|
|
||||||
boost::shared_ptr<torrent> t1 = m_torrent.lock();
|
boost::shared_ptr<torrent> t1 = m_torrent.lock();
|
||||||
TORRENT_ASSERT(t1);
|
TORRENT_ASSERT(t1);
|
||||||
boost::shared_ptr<torrent> t2 = rhs.associated_torrent().lock();
|
boost::shared_ptr<torrent> t2 = rhs.associated_torrent().lock();
|
||||||
TORRENT_ASSERT(t2);
|
TORRENT_ASSERT(t2);
|
||||||
|
|
||||||
// take torrent priority into account
|
if (t1->priority() != t2->priority())
|
||||||
c1 *= 1 + t1->priority();
|
return t1->priority() > t2->priority();
|
||||||
c2 *= 1 + t2->priority();
|
|
||||||
|
|
||||||
if (c1 > c2) return true;
|
// compare how many bytes they've sent us
|
||||||
if (c1 < c2) return false;
|
size_type c1;
|
||||||
|
size_type c2;
|
||||||
|
c1 = m_statistics.total_payload_download() - m_downloaded_at_last_unchoke;
|
||||||
|
c2 = rhs.m_statistics.total_payload_download() - rhs.m_downloaded_at_last_unchoke;
|
||||||
|
|
||||||
|
if (c1 != c2) return c1 > c2;
|
||||||
|
|
||||||
if (m_ses.settings().seed_choking_algorithm == session_settings::round_robin)
|
if (m_ses.settings().seed_choking_algorithm == session_settings::round_robin)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3662,7 +3662,7 @@ namespace aux {
|
||||||
m_last_choke = now;
|
m_last_choke = now;
|
||||||
|
|
||||||
// build list of all peers that are
|
// build list of all peers that are
|
||||||
// unchoke:able.
|
// unchokable.
|
||||||
std::vector<peer_connection*> peers;
|
std::vector<peer_connection*> peers;
|
||||||
for (connection_map::iterator i = m_connections.begin();
|
for (connection_map::iterator i = m_connections.begin();
|
||||||
i != m_connections.end();)
|
i != m_connections.end();)
|
||||||
|
|
Loading…
Reference in New Issue