fixed connect candidate logic, to prefer peers with less failures

This commit is contained in:
Arvid Norberg 2007-12-24 08:17:32 +00:00
parent e0d1951fac
commit 4b7eaf8cbe
1 changed files with 6 additions and 0 deletions

View File

@ -533,6 +533,12 @@ namespace libtorrent
if (i->second.type == peer::not_connectable) continue;
if (i->second.seed && finished) continue;
if (i->second.failcount >= max_failcount) continue;
// prefer peers with lower failcount
if (candidate != m_peers.end()
&& candidate->second.failcount < i->second.failcount)
continue;
if (now - i->second.connected < seconds(i->second.failcount * min_reconnect_time))
continue;
if (ses.m_port_filter.access(i->second.ip.port()) & port_filter::blocked)