added asserts to piece_picker
This commit is contained in:
@@ -1193,12 +1193,12 @@ namespace libtorrent
|
||||
if (piece == start_piece) return;
|
||||
}
|
||||
|
||||
assert(m_piece_map[piece].downloading == false);
|
||||
|
||||
int start, end;
|
||||
boost::tie(start, end) = expand_piece(piece, prefer_whole_pieces, pieces);
|
||||
for (int k = start; k < end; ++k)
|
||||
{
|
||||
assert(m_piece_map[piece].downloading == false);
|
||||
assert(m_piece_map[k].priority(m_sequenced_download_threshold) > 0);
|
||||
int num_blocks_in_piece = blocks_in_piece(k);
|
||||
if (prefer_whole_pieces == 0 && num_blocks_in_piece > num_blocks)
|
||||
num_blocks_in_piece = num_blocks;
|
||||
@@ -1286,6 +1286,7 @@ namespace libtorrent
|
||||
int num_blocks_in_piece = blocks_in_piece(*i);
|
||||
|
||||
assert(m_piece_map[*i].downloading == 0);
|
||||
assert(m_piece_map[*i].priority(m_sequenced_download_threshold) > 0);
|
||||
|
||||
// pick a new piece
|
||||
if (prefer_whole_pieces == 0)
|
||||
@@ -1302,6 +1303,7 @@ namespace libtorrent
|
||||
boost::tie(start, end) = expand_piece(*i, prefer_whole_pieces, pieces);
|
||||
for (int k = start; k < end; ++k)
|
||||
{
|
||||
assert(m_piece_map[k].priority(m_sequenced_download_threshold) > 0);
|
||||
num_blocks_in_piece = blocks_in_piece(k);
|
||||
for (int j = 0; j < num_blocks_in_piece; ++j)
|
||||
{
|
||||
@@ -1310,7 +1312,7 @@ namespace libtorrent
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num_blocks <= 0) return num_blocks < 0 ? 0 : num_blocks;
|
||||
if (num_blocks <= 0) return 0;
|
||||
}
|
||||
return num_blocks;
|
||||
}
|
||||
@@ -1338,6 +1340,8 @@ namespace libtorrent
|
||||
// pieces that only they have downloaded/requested from
|
||||
if (on_parole && !exclusive) continue;
|
||||
|
||||
if (prefer_whole_pieces > 0 && !exclusive_active) continue;
|
||||
|
||||
for (int j = 0; j < num_blocks_in_piece; ++j)
|
||||
{
|
||||
// ignore completed blocks and already requested blocks
|
||||
|
Reference in New Issue
Block a user