*** empty log message ***

This commit is contained in:
Arvid Norberg 2005-06-22 23:04:37 +00:00
parent 45e764fee4
commit 0d6a4de5aa
8 changed files with 44 additions and 6 deletions

View File

@ -884,6 +884,7 @@ struct torrent_handle
bool is_seed() const;
void filter_piece(int index, bool filter);
void filter_pieces(std::vector<bool> const& bitmask);
bool is_piece_filtered(int index) const;
std::vector<bool> filtered_pieces() const;
@ -904,7 +905,7 @@ perform any operation on it, unless you first assign it a valid handle. If you t
any operation on an uninitialized handle, it will throw <tt class="docutils literal"><span class="pre">invalid_handle</span></tt>.</p>
<p><strong>TODO: document trackers() and replace_trackers()</strong></p>
<p><strong>TODO: document how to create a .torrent</strong></p>
<p><strong>TODO: document filter_piece(), is_piece_filtered() and filtered_pieces()</strong></p>
<p><strong>TODO: document filter_piece(), filter_pieces(), is_piece_filtered() and filtered_pieces()</strong></p>
<div class="section" id="save-path">
<h2><a name="save-path">save_path()</a></h2>
<blockquote>

View File

@ -813,6 +813,7 @@ Its declaration looks like this::
bool is_seed() const;
void filter_piece(int index, bool filter);
void filter_pieces(std::vector<bool> const& bitmask);
bool is_piece_filtered(int index) const;
std::vector<bool> filtered_pieces() const;
@ -836,7 +837,7 @@ any operation on an uninitialized handle, it will throw ``invalid_handle``.
**TODO: document how to create a .torrent**
**TODO: document filter_piece(), is_piece_filtered() and filtered_pieces()**
**TODO: document filter_piece(), filter_pieces(), is_piece_filtered() and filtered_pieces()**
save_path()
-----------

View File

@ -146,7 +146,8 @@ namespace libtorrent
void resume();
bool is_paused() const { return m_paused; }
void filter_piece(int index, bool download);
void filter_piece(int index, bool filter);
void filter_pieces(std::vector<bool> const& bitmask);
bool is_piece_filtered(int index) const;
void filtered_pieces(std::vector<bool>& bitmask) const;

View File

@ -227,6 +227,7 @@ namespace libtorrent
// marks the piece with the given index as filtered
// it will not be downloaded
void filter_piece(int index, bool filter);
void filter_pieces(std::vector<bool> const& pieces);
bool is_piece_filtered(int index) const;
std::vector<bool> filtered_pieces() const;

View File

@ -100,9 +100,9 @@ namespace
if (!std::isalnum(id[0]))
return boost::optional<fingerprint>();
if (std::equal(id.begin()+4, id.begin()+8, "----"))
if (std::equal(id.begin()+4, id.begin()+6, "--"))
{
if (!std::isalnum(id[1]) || (id[2] < '0')
if ((id[1] < '0') || (id[2] < '0')
|| (id[3] < '0'))
return boost::optional<fingerprint>();
ret.major_version = decode_digit(id[1]);

View File

@ -572,7 +572,7 @@ namespace libtorrent
// is downloading them.
// partial is pieces that are partially being downloaded, and
// parts of them may be free for download as well, the
// partially donloaded pieces will be prioritized
// partially downloaded pieces will be prioritized
assert(m_piece_info.begin() != m_piece_info.end());
// +1 is to ignore pieces that no peer has. The bucket with index 0 contains
// pieces that 0 other peers has.

View File

@ -588,6 +588,33 @@ namespace libtorrent
else m_picker->mark_as_unfiltered(index);
}
void torrent::filter_pieces(std::vector<bool> const& bitmask)
{
// this call is only valid on torrents with metadata
assert(m_picker.get());
assert(index >= 0);
assert(index < m_torrent_file.num_pieces());
// TODO: update peer's interesting-bit
std::vector<std::pair<int, bool> > state;
state.reserve(100);
int index = 0;
for (std::vector<bool>::const_iterator i = bitmask.begin()
, end(bitmask.end()); i != end; ++i, ++index)
{
if (m_picker->is_filtered(index) == *i) continue;
state.push_back(std::make_pair(index, *i));
}
std::random_shuffle(state.begin(), state.end());
for (std::vector<std::pair<int, bool> >::iterator i = state.begin();
i != state.end(); ++i)
{
if (i->second) m_picker->mark_as_filtered(i->first);
else m_picker->mark_as_unfiltered(i->first);
}
}
// TODO: add a function to set the filter with one call
bool torrent::is_piece_filtered(int index) const

View File

@ -263,6 +263,13 @@ namespace libtorrent
, bind(&torrent::filter_piece, _1, index, filter));
}
void torrent_handle::filter_pieces(std::vector<bool> const& pieces)
{
INVARIANT_CHECK;
call_member<void>(m_ses, m_chk, m_info_hash
, bind(&torrent::filter_pieces, _1, pieces));
}
bool torrent_handle::is_piece_filtered(int index) const
{
INVARIANT_CHECK;