made the values sent to the tracker only include complete and hash checked data, to make them increase and decrease monotonically
This commit is contained in:
parent
5e254ffea6
commit
1bde539d67
|
@ -158,6 +158,7 @@ namespace libtorrent
|
|||
stat statistics() const { return m_stat; }
|
||||
size_type bytes_left() const;
|
||||
boost::tuples::tuple<size_type, size_type> bytes_done() const;
|
||||
size_type quantized_bytes_done() const;
|
||||
|
||||
void pause();
|
||||
void resume();
|
||||
|
|
|
@ -578,7 +578,34 @@ namespace libtorrent
|
|||
// cannot tell how big the torrent is.
|
||||
if (!valid_metadata()) return -1;
|
||||
return m_torrent_file.total_size()
|
||||
- boost::tuples::get<0>(bytes_done());
|
||||
- quantized_bytes_done();
|
||||
}
|
||||
|
||||
size_type torrent::quantized_bytes_done() const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (!valid_metadata()) return 0;
|
||||
|
||||
assert(m_picker.get());
|
||||
|
||||
if (m_torrent_file.num_pieces() == 0)
|
||||
return 0;
|
||||
const int last_piece = m_torrent_file.num_pieces() - 1;
|
||||
|
||||
size_type total_done
|
||||
= m_num_pieces * m_torrent_file.piece_length();
|
||||
|
||||
// if we have the last piece, we have to correct
|
||||
// the amount we have, since the first calculation
|
||||
// assumed all pieces were of equal size
|
||||
if (m_have_pieces[last_piece])
|
||||
{
|
||||
int corr = m_torrent_file.piece_size(last_piece)
|
||||
- m_torrent_file.piece_length();
|
||||
total_done += corr;
|
||||
}
|
||||
return total_done;
|
||||
}
|
||||
|
||||
// the first value is the total number of bytes downloaded
|
||||
|
|
Loading…
Reference in New Issue