Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test merge #7633

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.1.0 not released

* try harder to bind TCP and UDP sockets to the same port
* made disk_interface's status_t type a flags type
* optimize resume data format to use less space
Expand All @@ -11,6 +13,10 @@
* libtorrent now requires C++17 to build
* added support for WebTorrent

2.0.11 not released

* torrent_status::num_pieces counts pieces passed hash check, as documented

2.0.10 released

* allow on_unknown_torrent method in the absence of active torrents (new plugin feature added)
Expand Down
2 changes: 2 additions & 0 deletions include/libtorrent/torrent_status.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ TORRENT_VERSION_NAMESPACE_4
// ``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 if you want to keep a graph of the pieces up to date.
// Note that these pieces have not necessarily been written to disk yet,
// and there is a risk the write to disk will fail.
int num_pieces = 0;

// the number of distributed copies of the torrent. Note that one copy
Expand Down
19 changes: 18 additions & 1 deletion src/torrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12064,7 +12064,24 @@ namespace {
st->pieces.resize(num_pieces, false);
}
}
st->num_pieces = num_have();
st->num_pieces = num_passed();
#if TORRENT_USE_INVARIANT_CHECKS
{
// The documentation states that `num_pieces` is the count of number
// of bits set in `pieces`. Ensure that invariant holds.
int num_have_pieces = 0;
if (has_picker())
{
for (auto const i : m_torrent_file->piece_range())
if (m_picker->has_piece_passed(i)) ++num_have_pieces;
}
else if (m_have_all)
{
num_have_pieces = m_torrent_file->num_pieces();
}
TORRENT_ASSERT(num_have_pieces == st->num_pieces);
}
#endif
st->num_seeds = num_seeds();
if ((flags & torrent_handle::query_distributed_copies) && m_picker.get())
{
Expand Down
Loading