move trust point and hashfailure counter logic to where they belong
This commit is contained in:
parent
5897235f51
commit
57eb57ac78
|
@ -1137,25 +1137,6 @@ namespace libtorrent
|
||||||
} TORRENT_CATCH(std::exception&) {}
|
} TORRENT_CATCH(std::exception&) {}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (is_disconnecting()) return;
|
|
||||||
|
|
||||||
if (peer_info_struct())
|
|
||||||
{
|
|
||||||
if (m_ses.settings().use_parole_mode)
|
|
||||||
peer_info_struct()->on_parole = true;
|
|
||||||
|
|
||||||
int hashfails = peer_info_struct()->hashfails;
|
|
||||||
int trust_points = peer_info_struct()->trust_points;
|
|
||||||
|
|
||||||
// we decrease more than we increase, to keep the
|
|
||||||
// allowed failed/passed ratio low.
|
|
||||||
trust_points -= 2;
|
|
||||||
++hashfails;
|
|
||||||
if (trust_points < -7) trust_points = -7;
|
|
||||||
peer_info_struct()->trust_points = trust_points;
|
|
||||||
if (hashfails > 255) hashfails = 255;
|
|
||||||
peer_info_struct()->hashfails = hashfails;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type peer_connection::total_free_upload() const
|
size_type peer_connection::total_free_upload() const
|
||||||
|
@ -3512,6 +3493,13 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// for incoming connections, we get invalid argument errors
|
||||||
|
// when asking for the remote endpoint and the socket already
|
||||||
|
// closed, which is an edge case, but possible to happen when
|
||||||
|
// a peer makes a TCP and uTP connection in parallel.
|
||||||
|
// for outgoing connections however, why would we get this?
|
||||||
|
TORRENT_ASSERT(ec != error::invalid_argument || !m_outgoing);
|
||||||
|
|
||||||
#ifdef TORRENT_STATS
|
#ifdef TORRENT_STATS
|
||||||
++m_ses.m_disconnected_peers;
|
++m_ses.m_disconnected_peers;
|
||||||
if (error == 2) ++m_ses.m_error_peers;
|
if (error == 2) ++m_ses.m_error_peers;
|
||||||
|
|
|
@ -3112,7 +3112,6 @@ namespace libtorrent
|
||||||
, index));
|
, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
state_updated();
|
|
||||||
m_need_save_resume_data = true;
|
m_need_save_resume_data = true;
|
||||||
state_updated();
|
state_updated();
|
||||||
|
|
||||||
|
@ -3285,7 +3284,27 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
policy::peer* p = static_cast<policy::peer*>(*i);
|
policy::peer* p = static_cast<policy::peer*>(*i);
|
||||||
if (p == 0) continue;
|
if (p == 0) continue;
|
||||||
if (p->connection) p->connection->received_invalid_data(index);
|
TORRENT_ASSERT(p->in_use);
|
||||||
|
if (p->connection)
|
||||||
|
{
|
||||||
|
TORRENT_ASSERT(p->connection->m_in_use == 1337);
|
||||||
|
p->connection->received_invalid_data(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ses.settings().use_parole_mode)
|
||||||
|
p->on_parole = true;
|
||||||
|
|
||||||
|
int hashfails = p->hashfails;
|
||||||
|
int trust_points = p->trust_points;
|
||||||
|
|
||||||
|
// we decrease more than we increase, to keep the
|
||||||
|
// allowed failed/passed ratio low.
|
||||||
|
trust_points -= 2;
|
||||||
|
++hashfails;
|
||||||
|
if (trust_points < -7) trust_points = -7;
|
||||||
|
p->trust_points = trust_points;
|
||||||
|
if (hashfails > 255) hashfails = 255;
|
||||||
|
p->hashfails = hashfails;
|
||||||
|
|
||||||
// either, we have received too many failed hashes
|
// either, we have received too many failed hashes
|
||||||
// or this was the only peer that sent us this piece.
|
// or this was the only peer that sent us this piece.
|
||||||
|
|
Loading…
Reference in New Issue