remove dead code from piece picker
This commit is contained in:
parent
b7adf89f55
commit
f1d2105afb
|
@ -363,10 +363,6 @@ namespace libtorrent {
|
||||||
// returns the number of blocks there is in the given piece
|
// returns the number of blocks there is in the given piece
|
||||||
int blocks_in_piece(piece_index_t index) const;
|
int blocks_in_piece(piece_index_t index) const;
|
||||||
|
|
||||||
// the number of downloaded blocks that hasn't passed
|
|
||||||
// the hash-check yet
|
|
||||||
int unverified_blocks() const;
|
|
||||||
|
|
||||||
// return the peer pointers to all peers that participated in
|
// return the peer pointers to all peers that participated in
|
||||||
// this piece
|
// this piece
|
||||||
void get_downloaders(std::vector<torrent_peer*>& d, piece_index_t index) const;
|
void get_downloaders(std::vector<torrent_peer*>& d, piece_index_t index) const;
|
||||||
|
@ -429,8 +425,6 @@ namespace libtorrent {
|
||||||
|
|
||||||
std::pair<int, int> distributed_copies() const;
|
std::pair<int, int> distributed_copies() const;
|
||||||
|
|
||||||
void set_num_pad_files(int n) { m_num_pad_files = n; }
|
|
||||||
|
|
||||||
// return the array of block_info objects for a given downloading_piece.
|
// return the array of block_info objects for a given downloading_piece.
|
||||||
// this array has m_blocks_per_piece elements in it
|
// this array has m_blocks_per_piece elements in it
|
||||||
aux::typed_span<block_info const> blocks_for_piece(downloading_piece const& dp) const;
|
aux::typed_span<block_info const> blocks_for_piece(downloading_piece const& dp) const;
|
||||||
|
@ -766,13 +760,6 @@ namespace libtorrent {
|
||||||
// This includes pieces that we have filtered but still have
|
// This includes pieces that we have filtered but still have
|
||||||
int m_num_have = 0;
|
int m_num_have = 0;
|
||||||
|
|
||||||
// this is the number of partial download pieces
|
|
||||||
// that may be caused by pad files. We raise the limit
|
|
||||||
// of number of partial pieces by this amount, to not
|
|
||||||
// prioritize pieces that intersect pad files for no
|
|
||||||
// apparent reason
|
|
||||||
int m_num_pad_files = 0;
|
|
||||||
|
|
||||||
// if this is set to true, it means update_pieces()
|
// if this is set to true, it means update_pieces()
|
||||||
// has to be called before accessing m_pieces.
|
// has to be called before accessing m_pieces.
|
||||||
mutable bool m_dirty = false;
|
mutable bool m_dirty = false;
|
||||||
|
|
|
@ -1882,13 +1882,11 @@ namespace {
|
||||||
// make this scale by the number of peers we have. For large
|
// make this scale by the number of peers we have. For large
|
||||||
// scale clients, we would have more peers, and allow a higher
|
// scale clients, we would have more peers, and allow a higher
|
||||||
// threshold for the number of partials
|
// threshold for the number of partials
|
||||||
// deduct pad files because they case partial pieces which are OK
|
|
||||||
// the second condition is to make sure we cap the number of partial
|
// the second condition is to make sure we cap the number of partial
|
||||||
// _bytes_. The larger the pieces are, the fewer partial pieces we want.
|
// _bytes_. The larger the pieces are, the fewer partial pieces we want.
|
||||||
// 2048 corresponds to 32 MiB
|
// 2048 corresponds to 32 MiB
|
||||||
// TODO: 2 make the 2048 limit configurable
|
// TODO: 2 make the 2048 limit configurable
|
||||||
const int num_partials = int(m_downloads[piece_pos::piece_downloading].size())
|
const int num_partials = int(m_downloads[piece_pos::piece_downloading].size());
|
||||||
- m_num_pad_files;
|
|
||||||
if (num_partials > num_peers * 3 / 2
|
if (num_partials > num_peers * 3 / 2
|
||||||
|| num_partials * m_blocks_per_piece > 2048)
|
|| num_partials * m_blocks_per_piece > 2048)
|
||||||
{
|
{
|
||||||
|
@ -3593,17 +3591,4 @@ get_out:
|
||||||
i = update_piece_state(i);
|
i = update_piece_state(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
int piece_picker::unverified_blocks() const
|
|
||||||
{
|
|
||||||
int counter = 0;
|
|
||||||
for (auto const& c : m_downloads)
|
|
||||||
{
|
|
||||||
for (auto const& dp : c)
|
|
||||||
{
|
|
||||||
counter += int(dp.finished);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return counter;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1802,13 +1802,10 @@ bool is_downloading_state(int const st)
|
||||||
{
|
{
|
||||||
need_picker();
|
need_picker();
|
||||||
|
|
||||||
int num_pad_files = 0;
|
|
||||||
TORRENT_ASSERT(block_size() > 0);
|
TORRENT_ASSERT(block_size() > 0);
|
||||||
|
|
||||||
for (auto const i : fs.file_range())
|
for (auto const i : fs.file_range())
|
||||||
{
|
{
|
||||||
if (fs.pad_file_at(i)) ++num_pad_files;
|
|
||||||
|
|
||||||
if (!fs.pad_file_at(i) || fs.file_size(i) == 0) continue;
|
if (!fs.pad_file_at(i) || fs.file_size(i) == 0) continue;
|
||||||
m_padding += std::uint32_t(fs.file_size(i));
|
m_padding += std::uint32_t(fs.file_size(i));
|
||||||
|
|
||||||
|
@ -1859,9 +1856,6 @@ bool is_downloading_state(int const st)
|
||||||
we_have(i);
|
we_have(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_pad_files > 0)
|
|
||||||
m_picker->set_num_pad_files(num_pad_files);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_state(torrent_status::checking_resume_data);
|
set_state(torrent_status::checking_resume_data);
|
||||||
|
|
|
@ -1287,47 +1287,6 @@ TORRENT_TEST(inc_ref_dec_ref)
|
||||||
TEST_EQUAL(test_pick(p), piece_index_t(0));
|
TEST_EQUAL(test_pick(p), piece_index_t(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
TORRENT_TEST(unverified_blocks)
|
|
||||||
{
|
|
||||||
// test unverified_blocks, marking blocks and get_downloader
|
|
||||||
auto p = setup_picker("1111111", " ", "", "0300700");
|
|
||||||
TEST_CHECK(p->unverified_blocks() == 2 + 3);
|
|
||||||
TEST_CHECK(p->get_downloader({piece_index_t(4), 0}) == tmp_peer);
|
|
||||||
TEST_CHECK(p->get_downloader({piece_index_t(4), 1}) == tmp_peer);
|
|
||||||
TEST_CHECK(p->get_downloader({piece_index_t(4), 2}) == tmp_peer);
|
|
||||||
TEST_CHECK(p->get_downloader({piece_index_t(4), 3}) == nullptr);
|
|
||||||
p->mark_as_downloading({piece_index_t(4), 3}, &peer_struct);
|
|
||||||
TEST_CHECK(p->get_downloader({piece_index_t(4), 3}) == &peer_struct);
|
|
||||||
|
|
||||||
piece_picker::downloading_piece st;
|
|
||||||
p->piece_info(piece_index_t(4), st);
|
|
||||||
TEST_CHECK(st.requested == 1);
|
|
||||||
TEST_CHECK(st.writing == 0);
|
|
||||||
TEST_CHECK(st.finished == 3);
|
|
||||||
TEST_CHECK(p->unverified_blocks() == 2 + 3);
|
|
||||||
p->mark_as_writing({piece_index_t(4), 3}, &peer_struct);
|
|
||||||
TEST_CHECK(p->get_downloader({piece_index_t(4), 3}) == &peer_struct);
|
|
||||||
p->piece_info(piece_index_t(4), st);
|
|
||||||
TEST_CHECK(st.requested == 0);
|
|
||||||
TEST_CHECK(st.writing == 1);
|
|
||||||
TEST_CHECK(st.finished == 3);
|
|
||||||
TEST_CHECK(p->unverified_blocks() == 2 + 3);
|
|
||||||
p->mark_as_finished({piece_index_t(4), 3}, &peer_struct);
|
|
||||||
TEST_CHECK(p->get_downloader({piece_index_t(4), 3}) == &peer_struct);
|
|
||||||
p->piece_info(piece_index_t(4), st);
|
|
||||||
TEST_CHECK(st.requested == 0);
|
|
||||||
TEST_CHECK(st.writing == 0);
|
|
||||||
TEST_CHECK(st.finished == 4);
|
|
||||||
TEST_CHECK(p->unverified_blocks() == 2 + 4);
|
|
||||||
p->we_have(piece_index_t(4));
|
|
||||||
p->piece_info(piece_index_t(4), st);
|
|
||||||
TEST_CHECK(st.requested == 0);
|
|
||||||
TEST_CHECK(st.writing == 0);
|
|
||||||
TEST_CHECK(st.finished == 4);
|
|
||||||
TEST_CHECK(p->get_downloader({piece_index_t(4), 3}) == nullptr);
|
|
||||||
TEST_CHECK(p->unverified_blocks() == 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
TORRENT_TEST(prefer_cnotiguous_blocks)
|
TORRENT_TEST(prefer_cnotiguous_blocks)
|
||||||
{
|
{
|
||||||
// test prefer_contiguous_blocks
|
// test prefer_contiguous_blocks
|
||||||
|
|
Loading…
Reference in New Issue