torrent_handle::add_tracker()

This commit is contained in:
Arvid Norberg 2008-11-26 01:42:14 +00:00
parent 294e62a4c3
commit 3fd5405fa9
6 changed files with 30 additions and 2 deletions

View File

@ -1,4 +1,5 @@
* add_tracker() function added to torrent_handle
* if there is no working tracker, current_tracker is the
tracker that is currently being tried
* torrents that are checking can now be paused, which will

View File

@ -1619,6 +1619,7 @@ Its declaration looks like this::
std::vector<announce_entry> const& trackers() const;
void replace_trackers(std::vector<announce_entry> const&);
void add_tracker(announc_entry const& url);
void add_url_seed(std::string const& url);
void remove_url_seed(std::string const& url);
@ -2047,13 +2048,14 @@ set_tracker_login()
of the tracker announce. Set this if the tracker requires authorization.
trackers() replace_trackers()
-----------------------------
trackers() replace_trackers() add_tracker()
-------------------------------------------
::
std::vector<announce_entry> const& trackers() const;
void replace_trackers(std::vector<announce_entry> const&) const;
void add_tracker(announc_entry const& url);
``trackers()`` will return the list of trackers for this torrent. The
announce entry contains both a string ``url`` which specify the announce url
@ -2064,6 +2066,10 @@ a list of the same form as the one returned from ``trackers()`` and will
replace it. If you want an immediate effect, you have to call
`force_reannounce()`_.
``add_tracker()`` will look if the specified tracker is already in the set.
If it is, it doesn't do anything. If it's not in the current set of trackers,
it will insert it in the tier specified in the announce_entry.
add_url_seed() remove_url_seed() url_seeds()
--------------------------------------------

View File

@ -586,6 +586,7 @@ namespace libtorrent
{ return m_trackers; }
void replace_trackers(std::vector<announce_entry> const& urls);
void add_tracker(announce_entry const& urls);
torrent_handle get_handle();

View File

@ -331,6 +331,7 @@ namespace libtorrent
std::vector<announce_entry> const& trackers() const;
void replace_trackers(std::vector<announce_entry> const&) const;
void add_tracker(announce_entry const&) const;
void add_url_seed(std::string const& url) const;
void remove_url_seed(std::string const& url) const;

View File

@ -2063,6 +2063,19 @@ namespace libtorrent
else stop_announcing();
}
void torrent::add_tracker(announce_entry const& url)
{
std::vector<announce_entry>::iterator k = std::find_if(m_trackers.begin()
, m_trackers.end(), boost::bind(&announce_entry::url, _1) == url.url);
if (k != m_trackers.end()) return;
k = std::upper_bound(m_trackers.begin(), m_trackers.end(), url
, boost::bind(&announce_entry::tier, _1) < boost::bind(&announce_entry::tier, _2));
if (k - m_trackers.begin() < m_currently_trying_tracker) ++m_currently_trying_tracker;
if (k - m_trackers.begin() < m_last_working_tracker) ++m_last_working_tracker;
m_trackers.insert(k, url);
if (!m_trackers.empty()) start_announcing();
}
void torrent::choke_peer(peer_connection& c)
{
INVARIANT_CHECK;

View File

@ -511,6 +511,12 @@ namespace libtorrent
TORRENT_FORWARD(replace_trackers(urls));
}
void torrent_handle::add_tracker(announce_entry const& url) const
{
INVARIANT_CHECK;
TORRENT_FORWARD(add_tracker(url));
}
storage_interface* torrent_handle::get_storage_impl() const
{
INVARIANT_CHECK;