forked from premiere/premiere-libtorrent
*** empty log message ***
This commit is contained in:
parent
5068562916
commit
bbf58b64e5
|
@ -1143,9 +1143,9 @@ namespace libtorrent
|
||||||
|
|
||||||
int diff = share_diff();
|
int diff = share_diff();
|
||||||
|
|
||||||
enum { blockLimit=2 }; // how many blocks difference is considered unfair
|
enum { block_limit=2 }; // how many blocks difference is considered unfair
|
||||||
|
|
||||||
if (diff > blockLimit*m_torrent->block_size() || m_torrent->is_seed())
|
if (diff > block_limit*m_torrent->block_size() || m_torrent->is_seed())
|
||||||
{
|
{
|
||||||
// if we have downloaded more than one piece more
|
// if we have downloaded more than one piece more
|
||||||
// than we have uploaded OR if we are a seed
|
// than we have uploaded OR if we are a seed
|
||||||
|
@ -1160,7 +1160,7 @@ namespace libtorrent
|
||||||
// if we have uploaded too much, send with a rate of
|
// if we have uploaded too much, send with a rate of
|
||||||
// 10 kB/s less than we receive
|
// 10 kB/s less than we receive
|
||||||
int bias = 0;
|
int bias = 0;
|
||||||
if (diff > -blockLimit*m_torrent->block_size())
|
if (diff > -block_limit*m_torrent->block_size())
|
||||||
{
|
{
|
||||||
bias = static_cast<int>(m_statistics.download_rate() * ratio) / 2;
|
bias = static_cast<int>(m_statistics.download_rate() * ratio) / 2;
|
||||||
if (bias < 10*1024) bias = 10*1024;
|
if (bias < 10*1024) bias = 10*1024;
|
||||||
|
|
|
@ -210,7 +210,7 @@ namespace
|
||||||
// (and we should consider it free). If the share diff is
|
// (and we should consider it free). If the share diff is
|
||||||
// negative, there's no free download to get from this peer.
|
// negative, there's no free download to get from this peer.
|
||||||
int diff = i->second->share_diff();
|
int diff = i->second->share_diff();
|
||||||
if (i->second->is_peer_interested() || diff <= 0)
|
if (i->second->is_peer_interested() || diff <= 0 || diff==std::numeric_limits<int>::max())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
assert(diff > 0);
|
assert(diff > 0);
|
||||||
|
@ -233,10 +233,13 @@ namespace
|
||||||
if (free_upload <= 0) return free_upload;
|
if (free_upload <= 0) return free_upload;
|
||||||
int num_peers = 0;
|
int num_peers = 0;
|
||||||
int total_diff = 0;
|
int total_diff = 0;
|
||||||
|
|
||||||
for (torrent::peer_iterator i = start; i != end; ++i)
|
for (torrent::peer_iterator i = start; i != end; ++i)
|
||||||
{
|
{
|
||||||
total_diff += i->second->share_diff();
|
int diff=i->second->share_diff();
|
||||||
if (!i->second->is_peer_interested() || i->second->share_diff() >= 0) continue;
|
if(diff==std::numeric_limits<int>::max()) continue;
|
||||||
|
total_diff += diff;
|
||||||
|
if (!i->second->is_peer_interested() || diff >= 0) continue;
|
||||||
++num_peers;
|
++num_peers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,6 +308,8 @@ namespace libtorrent
|
||||||
// int diff = i->total_download()
|
// int diff = i->total_download()
|
||||||
// - i->total_upload();
|
// - i->total_upload();
|
||||||
int diff = c->share_diff();
|
int diff = c->share_diff();
|
||||||
|
if(diff==std::numeric_limits<int>::max())
|
||||||
|
diff=0;
|
||||||
|
|
||||||
int weight = static_cast<int>(c->statistics().download_rate() * 10.f)
|
int weight = static_cast<int>(c->statistics().download_rate() * 10.f)
|
||||||
+ diff
|
+ diff
|
||||||
|
@ -450,6 +455,7 @@ namespace libtorrent
|
||||||
if (c == 0) continue;
|
if (c == 0) continue;
|
||||||
|
|
||||||
int diff=c->share_diff();
|
int diff=c->share_diff();
|
||||||
|
// no problem if diff returns std::numeric_limits<int>::max()
|
||||||
|
|
||||||
if (diff <= -free_upload_amount
|
if (diff <= -free_upload_amount
|
||||||
&& !c->is_choked())
|
&& !c->is_choked())
|
||||||
|
|
Loading…
Reference in New Issue