From 73942de97a51dbf234d87ab67b61a18645611add Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 16 Jul 2017 12:25:07 -0700 Subject: [PATCH] carve out peer_list_entry into also being deprecated (it was only used by deprecated functions and some tests) --- include/libtorrent/peer_info.hpp | 2 ++ include/libtorrent/torrent.hpp | 2 ++ include/libtorrent/torrent_handle.hpp | 2 ++ src/torrent.cpp | 2 ++ src/torrent_handle.cpp | 2 +- test/test_torrent.cpp | 10 ++++++--- test/test_tracker.cpp | 29 +++++++++++++++------------ 7 files changed, 32 insertions(+), 17 deletions(-) diff --git a/include/libtorrent/peer_info.hpp b/include/libtorrent/peer_info.hpp index 0132cd5c1..2a1d77220 100644 --- a/include/libtorrent/peer_info.hpp +++ b/include/libtorrent/peer_info.hpp @@ -421,6 +421,7 @@ namespace libtorrent { }; +#ifndef TORRENT_NO_DEPRECATE // internal struct TORRENT_EXTRA_EXPORT peer_list_entry { @@ -439,6 +440,7 @@ namespace libtorrent { // internal std::uint8_t source; }; +#endif } diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 57091fb54..9b35ffd5e 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -679,7 +679,9 @@ namespace libtorrent { peer_iterator begin() { return m_connections.begin(); } peer_iterator end() { return m_connections.end(); } +#ifndef TORRENT_NO_DEPRECATE void get_full_peer_list(std::vector* v) const; +#endif void get_peer_info(std::vector* v); void get_download_queue(std::vector* queue) const; diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index d3f4944d1..889d8a476 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -66,7 +66,9 @@ namespace libtorrent { namespace aux { class torrent_info; struct torrent_plugin; struct peer_info; +#ifndef TORRENT_NO_DEPRECATE struct peer_list_entry; +#endif struct torrent_status; struct torrent_handle; struct storage_interface; diff --git a/src/torrent.cpp b/src/torrent.cpp index dce620ad9..b2d73b78d 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6237,6 +6237,7 @@ namespace libtorrent { } } +#ifndef TORRENT_NO_DEPRECATE void torrent::get_full_peer_list(std::vector* v) const { v->clear(); @@ -6253,6 +6254,7 @@ namespace libtorrent { v->push_back(e); } } +#endif void torrent::get_peer_info(std::vector* v) { diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index a5556cf20..13913291f 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/announce_entry.hpp" #include "libtorrent/write_resume_data.hpp" -#if TORRENT_COMPLETE_TYPES_REQUIRED +#ifndef TORRENT_NO_DEPRECATE #include "libtorrent/peer_info.hpp" // for peer_list_entry #endif diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 6a938c5a3..c987cb4d8 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -244,9 +244,13 @@ TORRENT_TEST(added_peers) torrent_handle h = ses.add_torrent(std::move(p)); - std::vector v; - h.native_handle()->get_full_peer_list(&v); - TEST_EQUAL(v.size(), 2); + h.save_resume_data(); + alert const* a = wait_for_alert(ses, save_resume_data_alert::alert_type); + + TEST_CHECK(a); + save_resume_data_alert const* ra = alert_cast(a); + TEST_CHECK(ra); + if (ra) TEST_EQUAL(ra->params.peers.size(), 2); } TORRENT_TEST(torrent) diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index a7a721128..a1cb665d1 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -467,21 +467,24 @@ TORRENT_TEST(http_peers) // we expect to have certain peers in our peer list now // these peers are hard coded in web_server.py - std::vector peers; - h.native_handle()->get_full_peer_list(&peers); + h.save_resume_data(); + alert const* a = wait_for_alert(*s, save_resume_data_alert::alert_type); - std::set expected_peers; - expected_peers.insert(ep("65.65.65.65", 16962)); - expected_peers.insert(ep("67.67.67.67", 17476)); -#if TORRENT_USE_IPV6 - expected_peers.insert(ep("4545:4545:4545:4545:4545:4545:4545:4545", 17990)); -#endif - - TEST_EQUAL(peers.size(), expected_peers.size()); - for (std::vector::iterator i = peers.begin() - , end(peers.end()); i != end; ++i) + TEST_CHECK(a); + save_resume_data_alert const* ra = alert_cast(a); + TEST_CHECK(ra); + if (ra) { - TEST_EQUAL(expected_peers.count(i->ip), 1); + std::set expected_peers; + expected_peers.insert(ep("65.65.65.65", 16962)); + expected_peers.insert(ep("67.67.67.67", 17476)); +#if TORRENT_USE_IPV6 + expected_peers.insert(ep("4545:4545:4545:4545:4545:4545:4545:4545", 17990)); +#endif + for (auto const& ip : ra->params.peers) + { + TEST_EQUAL(expected_peers.count(ip), 1); + } } std::printf("destructing session\n");