Skip to content

Commit

Permalink
merge RC_2_0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Feb 21, 2024
2 parents 7f7b50e + a653481 commit a60c0db
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
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

0 comments on commit a60c0db

Please sign in to comment.