#47. introduced parole mode for peers that fails the hash check.

This commit is contained in:
Arvid Norberg 2007-05-16 04:12:13 +00:00
parent f7d051162e
commit 13ca78e92b
3 changed files with 20 additions and 1 deletions

View File

@ -174,6 +174,9 @@ namespace libtorrent
void set_non_prioritized(bool b)
{ m_non_prioritized = b; }
bool on_parole() const
{ return m_on_parole; }
// this adds an announcement in the announcement queue
// it will let the peer know that we have the given piece
void announce_piece(int index);
@ -633,6 +636,14 @@ namespace libtorrent
// are preferred.
bool m_prefer_whole_pieces;
// if this is true, the peer has previously participated
// in a piece that failed the piece hash check. This will
// put the peer on parole and only request entire pieces.
// if a piece pass that was partially requested from this
// peer it will leave parole mode and continue download
// pieces as normal peers.
bool m_on_parole;
// if this is true, the blocks picked by the piece
// picker will be merged before passed to the
// request function. i.e. subsequent blocks are

View File

@ -119,6 +119,7 @@ namespace libtorrent
, m_writing(false)
, m_reading(false)
, m_prefer_whole_pieces(false)
, m_on_parole(false)
, m_request_large_blocks(false)
, m_non_prioritized(false)
, m_refs(0)
@ -189,6 +190,7 @@ namespace libtorrent
, m_writing(false)
, m_reading(false)
, m_prefer_whole_pieces(false)
, m_on_parole(false)
, m_request_large_blocks(false)
, m_non_prioritized(false)
, m_refs(0)
@ -401,6 +403,8 @@ namespace libtorrent
}
#endif
m_on_parole = false;
m_trust_points++;
// TODO: make this limit user settable
if (m_trust_points > 20) m_trust_points = 20;
@ -418,6 +422,8 @@ namespace libtorrent
}
#endif
m_on_parole = true;
// we decrease more than we increase, to keep the
// allowed failed/passed ratio low.
// TODO: make this limit user settable

View File

@ -186,7 +186,9 @@ namespace libtorrent
std::vector<piece_block> interesting_pieces;
interesting_pieces.reserve(100);
bool prefer_whole_pieces = c.prefer_whole_pieces();
bool prefer_whole_pieces = c.prefer_whole_pieces()
|| c.on_parole();
if (!prefer_whole_pieces)
{
prefer_whole_pieces = c.statistics().download_payload_rate()