From 1a00267990f55589f74b7139d964674b69115e48 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 19 Feb 2024 13:43:58 +0100 Subject: [PATCH 1/2] bump version for future release --- ChangeLog | 2 ++ Jamfile | 2 +- Makefile | 2 +- bindings/python/setup.cfg | 2 +- docs/header.rst | 2 +- docs/hunspell/libtorrent.dic | 2 +- include/libtorrent/version.hpp | 12 ++++++------ src/settings_pack.cpp | 2 +- test/test_settings_pack.cpp | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06de8be737c..3672cb24689 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +2.0.11 not released + 2.0.10 released * allow on_unknown_torrent method in the absence of active torrents (new plugin feature added) diff --git a/Jamfile b/Jamfile index 1e35e5a2963..4d66ce837f7 100644 --- a/Jamfile +++ b/Jamfile @@ -12,7 +12,7 @@ import cast ; # we need version numbers in the form X.Y.Z in order to trigger the built-in # support for generating symlinks to the installed library -VERSION = 2.0.10 ; +VERSION = 2.0.11 ; BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ; CXXFLAGS = [ modules.peek : CXXFLAGS ] ; diff --git a/Makefile b/Makefile index cf67552383b..8716322c8c5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=2.0.10 +VERSION=2.0.11 BUILD_CONFIG=release link=shared crypto=openssl warnings=off address-model=64 diff --git a/bindings/python/setup.cfg b/bindings/python/setup.cfg index 3b6e8031ddc..a6bb68d73e5 100644 --- a/bindings/python/setup.cfg +++ b/bindings/python/setup.cfg @@ -1,5 +1,5 @@ [metadata] -version = 2.0.10 +version = 2.0.11 [build_ext] cxxstd = 14 diff --git a/docs/header.rst b/docs/header.rst index fff8a7cffde..db4711f5507 100644 --- a/docs/header.rst +++ b/docs/header.rst @@ -1 +1 @@ -:Version: 2.0.10 +:Version: 2.0.11 diff --git a/docs/hunspell/libtorrent.dic b/docs/hunspell/libtorrent.dic index 1b0993710f3..d1bcb5a7f17 100644 --- a/docs/hunspell/libtorrent.dic +++ b/docs/hunspell/libtorrent.dic @@ -551,7 +551,7 @@ cpp tos BP qB -LT20A0 +LT20B0 iocontrol getname getpeername diff --git a/include/libtorrent/version.hpp b/include/libtorrent/version.hpp index 914af9104d7..38c093cf87f 100644 --- a/include/libtorrent/version.hpp +++ b/include/libtorrent/version.hpp @@ -39,27 +39,27 @@ POSSIBILITY OF SUCH DAMAGE. #define LIBTORRENT_VERSION_MAJOR 2 #define LIBTORRENT_VERSION_MINOR 0 -#define LIBTORRENT_VERSION_TINY 10 +#define LIBTORRENT_VERSION_TINY 11 // the format of this version is: MMmmtt // M = Major version, m = minor version, t = tiny version #define LIBTORRENT_VERSION_NUM ((LIBTORRENT_VERSION_MAJOR * 10000) + (LIBTORRENT_VERSION_MINOR * 100) + LIBTORRENT_VERSION_TINY) -#define LIBTORRENT_VERSION "2.0.10.0" -#define LIBTORRENT_REVISION "dacf64c50" +#define LIBTORRENT_VERSION "2.0.11.0" +#define LIBTORRENT_REVISION "74bc93a37" namespace libtorrent { // the major, minor and tiny versions of libtorrent constexpr int version_major = 2; constexpr int version_minor = 0; - constexpr int version_tiny = 10; + constexpr int version_tiny = 11; // the libtorrent version in string form - constexpr char const* version_str = "2.0.10.0"; + constexpr char const* version_str = "2.0.11.0"; // the git commit of this libtorrent version - constexpr std::uint64_t version_revision = 0xdacf64c50; + constexpr std::uint64_t version_revision = 0x74bc93a37; // returns the libtorrent version as string form in this format: // "..." diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 6d401c8389b..5a2c20f7405 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -148,7 +148,7 @@ constexpr int DISK_WRITE_MODE = settings_pack::enable_os_cache; SET(proxy_username, "", &session_impl::update_proxy), SET(proxy_password, "", &session_impl::update_proxy), SET(i2p_hostname, "", &session_impl::update_i2p_bridge), - SET(peer_fingerprint, "-LT20A0-", nullptr), + SET(peer_fingerprint, "-LT20B0-", nullptr), SET(dht_bootstrap_nodes, "dht.libtorrent.org:25401", &session_impl::update_dht_bootstrap_nodes) }}); diff --git a/test/test_settings_pack.cpp b/test/test_settings_pack.cpp index 9981239fc16..312d404d8b3 100644 --- a/test/test_settings_pack.cpp +++ b/test/test_settings_pack.cpp @@ -194,7 +194,7 @@ TORRENT_TEST(clear_single_string) sp.clear(settings_pack::user_agent); // when cleared, we'll get the default value - TEST_EQUAL(sp.get_str(settings_pack::user_agent), "libtorrent/2.0.10.0"); + TEST_EQUAL(sp.get_str(settings_pack::user_agent), "libtorrent/2.0.11.0"); } TORRENT_TEST(duplicates) From a65348137d75312e75f96110ee012ebd274787f3 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 21 Feb 2024 12:41:57 +0100 Subject: [PATCH 2/2] torrent_status::num_pieces counts pieces passed hash check, as documented --- ChangeLog | 2 ++ include/libtorrent/torrent_status.hpp | 2 ++ src/torrent.cpp | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3672cb24689..4dde420529c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 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) diff --git a/include/libtorrent/torrent_status.hpp b/include/libtorrent/torrent_status.hpp index aebd713231b..de95b24fe7a 100644 --- a/include/libtorrent/torrent_status.hpp +++ b/include/libtorrent/torrent_status.hpp @@ -357,6 +357,8 @@ TORRENT_VERSION_NAMESPACE_3 // ``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 diff --git a/src/torrent.cpp b/src/torrent.cpp index 5bf07c221a1..f81054bc21f 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -12008,7 +12008,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()) {