replaced the bandwidth throttling code with a leaky bucket for better accuracy
This commit is contained in:
@@ -62,6 +62,9 @@ namespace libtorrent
|
||||
{
|
||||
assert(blocks_per_piece > 0);
|
||||
assert(total_num_blocks >= 0);
|
||||
#ifndef NDEBUG
|
||||
m_files_checked_called = false;
|
||||
#endif
|
||||
|
||||
// the piece index is stored in 20 bits, which limits the allowed
|
||||
// number of pieces somewhat
|
||||
@@ -87,6 +90,9 @@ namespace libtorrent
|
||||
const std::vector<bool>& pieces
|
||||
, const std::vector<downloading_piece>& unfinished)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
m_files_checked_called = true;
|
||||
#endif
|
||||
// build a vector of all the pieces we don't have
|
||||
std::vector<int> piece_list;
|
||||
piece_list.reserve(std::count(pieces.begin(), pieces.end(), false));
|
||||
@@ -423,6 +429,7 @@ namespace libtorrent
|
||||
assert(elem_index != piece_pos::we_have_index);
|
||||
std::vector<std::vector<int> >& src_vec(pick_piece_info_vector(
|
||||
downloading, filtered));
|
||||
assert(m_files_checked_called);
|
||||
|
||||
assert((int)src_vec.size() > priority);
|
||||
assert((int)src_vec[priority].size() > elem_index);
|
||||
@@ -537,6 +544,7 @@ namespace libtorrent
|
||||
assert(!filtered);
|
||||
assert(priority >= 0);
|
||||
assert(elem_index >= 0);
|
||||
assert(m_files_checked_called);
|
||||
|
||||
std::vector<std::vector<int> >& src_vec(pick_piece_info_vector(downloading, filtered));
|
||||
|
||||
@@ -588,6 +596,7 @@ namespace libtorrent
|
||||
|
||||
assert(index >= 0);
|
||||
assert(index < (int)m_piece_map.size());
|
||||
assert(m_files_checked_called);
|
||||
|
||||
assert(m_piece_map[index].downloading == 1);
|
||||
|
||||
@@ -609,6 +618,7 @@ namespace libtorrent
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
assert(i >= 0);
|
||||
assert(i < (int)m_piece_map.size());
|
||||
assert(m_files_checked_called);
|
||||
|
||||
int index = m_piece_map[i].index;
|
||||
int prev_priority = m_piece_map[i].priority(m_sequenced_download_threshold);
|
||||
@@ -636,6 +646,7 @@ namespace libtorrent
|
||||
{
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
|
||||
assert(m_files_checked_called);
|
||||
assert(i >= 0);
|
||||
assert(i < (int)m_piece_map.size());
|
||||
|
||||
@@ -758,6 +769,7 @@ namespace libtorrent
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
assert(num_blocks > 0);
|
||||
assert(pieces.size() == m_piece_map.size());
|
||||
assert(m_files_checked_called);
|
||||
|
||||
// free refers to pieces that are free to download, no one else
|
||||
// is downloading them.
|
||||
|
Reference in New Issue
Block a user