back ported feature to expose which pieces have been verified in seed_mode and exposes it in client_test (initially implemented in the libtorrent_aio branch)

This commit is contained in:
Arvid Norberg 2011-08-07 07:19:18 +00:00
parent 9564636fd2
commit f6554bad08
5 changed files with 36 additions and 5 deletions

View File

@ -2193,7 +2193,9 @@ Its declaration looks like this::
{
query_distributed_copies = 1,
query_accurate_download_counters = 2,
query_last_seen_complete = 4
query_last_seen_complete = 4,
query_pieces = 8,
query_verified_pieces = 16
};
torrent_status status(boost::uint32_t flags = 0xffffffff);
@ -3177,6 +3179,12 @@ By default everything is included. The flags you can use to decide what to *incl
* ``query_last_seen_complete``
includes ``last_seen_complete``.
* ``query_pieces``
includes ``pieces``.
* ``query_verified_pieces``
includes ``verified_pieces`` (only applies to torrents in *seed mode*).
get_download_queue()
--------------------
@ -3350,6 +3358,8 @@ It contains the following fields::
int connect_candidates;
bitfield pieces;
bitfield verified_pieces;
int num_pieces;
size_type total_done;
@ -3520,6 +3530,10 @@ order block). This is supposed to be as low as possible.
the pieces we don't have. It's a pointer and may be set to 0 if the torrent isn't
downloading or seeding.
``verified_pieces`` is a bitmask representing which pieces has had their hash
checked. This only applies to torrents in *seed mode*. If the torrent is not
in seed mode, this bitmask may be empty.
``num_pieces`` is the number of pieces that has been downloaded. It is equivalent
to: ``std::accumulate(pieces->begin(), pieces->end())``. So you don't have to
count yourself. This can be used to see if anything has updated since last time

View File

@ -1414,7 +1414,9 @@ int main(int argc, char* argv[])
// is a somewhat expensive operation, don't do it by default for
// all torrents
handles[active_torrent] = handles[active_torrent].handle.status(
torrent_handle::query_distributed_copies);
torrent_handle::query_distributed_copies
| torrent_handle::query_pieces
| torrent_handle::query_verified_pieces);
}
std::vector<feed_handle> feeds;
@ -1853,12 +1855,19 @@ int main(int argc, char* argv[])
out += str;
++lines_printed;
if (print_piece_bar && s.state != torrent_status::seeding)
if (print_piece_bar && (s.state != torrent_status::seeding || s.seed_mode))
{
out += " ";
out += piece_bar(s.pieces, terminal_width - 7);
out += "\n";
++lines_printed;
if (s.seed_mode)
{
out += " ";
out += piece_bar(s.verified_pieces, terminal_width - 7);
out += "\n";
++lines_printed;
}
}
if (s.state != torrent_status::queued_for_checking && s.state != torrent_status::checking_files)

View File

@ -214,7 +214,7 @@ namespace libtorrent
, dht_announce_interval(15 * 60)
, udp_tracker_token_expiry(60)
, volatile_read_cache(false)
, guided_read_cache(true)
, guided_read_cache(false)
, default_cache_min_age(1)
, num_optimistic_unchoke_slots(0)
, no_atime_storage(true)

View File

@ -169,7 +169,9 @@ namespace libtorrent
{
query_distributed_copies = 1,
query_accurate_download_counters = 2,
query_last_seen_complete = 4
query_last_seen_complete = 4,
query_pieces = 8,
query_verified_pieces = 16
};
// the flags specify which fields are calculated. By default everything
@ -574,6 +576,7 @@ namespace libtorrent
int connect_candidates;
bitfield pieces;
bitfield verified_pieces;
// this is the number of pieces the client has
// downloaded. it is equal to:

View File

@ -7567,6 +7567,11 @@ namespace libtorrent
}
}
if ((flags & torrent_handle::query_verified_pieces))
{
st->verified_pieces = m_verified;
}
st->num_uploads = m_num_uploads;
st->uploads_limit = m_max_uploads;
st->num_connections = int(m_connections.size());