diff --git a/ChangeLog b/ChangeLog index ae4ae85cc..6e71939ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ + * the following functions have been deprecated: + void torrent_handle::filter_piece(int index, bool filter) const; + void torrent_handle::filter_pieces(std::vector const& pieces) const; + bool torrent_handle::is_piece_filtered(int index) const; + std::vector torrent_handle::filtered_pieces() const; + void torrent_handle::filter_files(std::vector const& files) const; + + instead, use the piece_priority functions. + * added support for NAT-PMP * added support for piece priorities. Piece filtering is now set as a priority diff --git a/docs/manual.html b/docs/manual.html index ad1b1836f..caed04a26 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -22,152 +22,153 @@
-

Table of contents

+

Table of contents

-
-

overview

+
+

overview

The interface of libtorrent consists of a few classes. The main class is the session, it contains the main loop that serves all torrents.

The basic usage is as follows:

@@ -193,8 +194,8 @@ the session, it conta

Each class and function is described in this manual.

-
-

primitive network types

+
+

primitive network types

There are a few typedefs in the libtorrent namespace which pulls in network types from the asio namespace. These are:

@@ -213,8 +214,8 @@ udp::endpoint
 

Which are the endpoint types used in libtorrent. An endpoint is an address with an associated port.

-
-

session

+
+

session

The session class has the following synopsis:

 class session: public boost::noncopyable
@@ -294,8 +295,8 @@ class session: public boost::noncopyable
 

Once it's created, the session object will spawn the main thread that will do all the work. The main thread will be idle as long it doesn't have any torrents to participate in.

-
-

session()

+
+

session()

 session(fingerprint const& print
@@ -314,16 +315,16 @@ The other constructor, that takes a port range and an interface as well as the f
 will automatically try to listen on a port on the given interface. For more information about
 the parameters, see listen_on() function.

-
-

~session()

+
+

~session()

The destructor of session will notify all trackers that our torrents have been shut down. If some trackers are down, they will time out. All this before the destructor of session returns. So, it's advised that any kind of interface (such as windows) are closed before destructing the session object. Because it can take a few second for it to finish. The timeout can be set with set_settings().

-
-

abort()

+
+

abort()

 session_proxy abort();
 
@@ -345,8 +346,8 @@ public: };
-
-

add_torrent()

+
+

add_torrent()

 torrent_handle add_torrent(
@@ -396,8 +397,8 @@ optional name argumen
 torrent. In case it's not 0, the name is used for the torrent as long as it doesn't
 have metadata. See torrent_handle::name.

-
-

remove_torrent() find_torrent() get_torrents()

+
+

remove_torrent() find_torrent() get_torrents()

 void remove_torrent(torrent_handle const& h);
@@ -414,8 +415,8 @@ In case the torrent cannot be found, an invalid torrent_handle is returned.

get_torrents() returns a vector of torrent_handles to all the torrents currently in the session.

-
-

set_upload_rate_limit() set_download_rate_limit() upload_rate_limit() download_rate_limit()

+
+

set_upload_rate_limit() set_download_rate_limit() upload_rate_limit() download_rate_limit()

 void set_upload_rate_limit(int bytes_per_second);
@@ -432,8 +433,8 @@ of upload rate.
 download_rate_limit() and upload_rate_limit() returns the previously
 set limits.

-
-

set_max_uploads() set_max_connections()

+
+

set_max_uploads() set_max_connections()

 void set_max_uploads(int limit);
@@ -446,8 +447,8 @@ minimum of at least two connections per torrent, so if you set a too low
 connections limit, and open too many torrents, the limit will not be met. The
 number of uploads is at least one per torrent.

-
-

num_uploads() num_connections()

+
+

num_uploads() num_connections()

 int num_uploads() const;
@@ -457,8 +458,8 @@ int num_connections() const;
 

Returns the number of currently unchoked peers and the number of connections (including half-open ones) respectively.

-
-

set_max_half_open_connections()

+
+

set_max_half_open_connections()

 void set_max_half_open_connections(int limit);
@@ -474,8 +475,8 @@ and passing -1 as the limit, means to have no limit. When limiting the number
 of simultaneous connection attempts, peers will be put in a queue waiting for
 their turn to get connected.

-
-

set_ip_filter()

+
+

set_ip_filter()

 void set_ip_filter(ip_filter const& filter);
@@ -486,8 +487,8 @@ connections based on their originating ip address. The default filter will allow
 connections to any ip address. To build a set of rules for which addresses are
 accepted and not, see ip_filter.

-
-

status()

+
+

status()

 session_status status() const;
@@ -538,8 +539,8 @@ are used to replace the regular nodes in the routing table in case any of them
 becomes unresponsive.

dht_torrents are the number of torrents tracked by the DHT at the moment.

-
-

is_listening() listen_port() listen_on()

+
+

is_listening() listen_port() listen_on()

 bool is_listening() const;
@@ -582,8 +583,8 @@ with a DHT ping packet, and connect to those that responds first. On windows one
 can only connect to a few peers at a time because of a built in limitation (in XP
 Service pack 2).

-
-

pop_alert() set_severity_level()

+
+

pop_alert() set_severity_level()

 std::auto_ptr<alert> pop_alert();
@@ -594,8 +595,8 @@ void set_severity_level(alert::severity_t s);
 set_severity_level() you can filter how serious the event has to be for you to
 receive it through pop_alert(). For information, see alerts.

-
-

add_extension()

+
+

add_extension()

 void add_extension(boost::function<
@@ -624,8 +625,8 @@ ses.add_extension(&libtorrent::create_metadata_plugin);
 ses.add_extension(&libtorrent::create_ut_pex_plugin);
 
-
-

start_dht() stop_dht() set_dht_settings() dht_state()

+
+

start_dht() stop_dht() set_dht_settings() dht_state()

 void start_dht(entry const& startup_state);
@@ -685,8 +686,8 @@ that are ready to replace a failing node, it will be replaced immediately,
 this limit is only used to clear out nodes that don't have any node that can
 replace them.

-
-

add_dht_node() add_dht_router()

+
+

add_dht_node() add_dht_router()

 void add_dht_node(std::pair<std::string, int> const& node);
@@ -705,8 +706,8 @@ for bootstrapping, to keep the load off them.

router.bittorrent.com.

-
-

entry

+
+

entry

The entry class represents one node in a bencoded hierarchy. It works as a variant type, it can be either a list, a dictionary (std::map), an integer or a string. This is its synopsis:

@@ -769,8 +770,8 @@ public: };

TODO: finish documentation of entry.

-
-

integer() string() list() dict() type()

+
+

integer() string() list() dict() type()

 integer_type& integer();
@@ -822,8 +823,8 @@ if (entry* i = torrent_file.find_key("announce"))
 

To make it easier to extract information from a torrent file, the class torrent_info exists.

-
-

operator[]

+
+

operator[]

 entry& operator[](char const* key);
@@ -841,8 +842,8 @@ given key, a reference to a newly inserted element at that key.

existing element at the given key. If the key is not found, it will throw libtorrent::type_error.

-
-

find_key()

+
+

find_key()

 entry* find_key(char const* key);
@@ -856,8 +857,8 @@ element cannot be found, they will return 0. If an element with the given
 key is found, the return a pointer to it.

-
-

torrent_info

+
+

torrent_info

The torrent_info has the following synopsis:

 class torrent_info
@@ -921,8 +922,8 @@ public:
         sha1_hash const& hash_for_piece(unsigned int index) const;
 };
 
-
-

torrent_info()

+
+

torrent_info()

 torrent_info();
@@ -945,8 +946,8 @@ object from the information found in the given torrent_file. The entry, use bdecode(),
 see bdecode() bencode().

-
-

set_comment() set_piece_size() set_creator() set_hash() add_tracker() add_file()

+
+

set_comment() set_piece_size() set_creator() set_hash() add_tracker() add_file()

 void set_comment(char const* str);
@@ -978,8 +979,8 @@ of the torrent. The sizecreate_torrent().

For a complete example of how to create a torrent from a file structure, see make_torrent.

-
-

create_torrent()

+
+

create_torrent()

 entry create_torrent();
@@ -993,8 +994,8 @@ object.

Note that a torrent file must include at least one file, and it must have at least one tracker url or at least one DHT node.

-
-

begin_files() end_files() rbegin_files() rend_files()

+
+

begin_files() end_files() rbegin_files() rend_files()

 file_iterator begin_files() const;
@@ -1029,8 +1030,8 @@ struct file_entry
 };
 
-
-

num_files() file_at()

+
+

num_files() file_at()

 int num_files() const;
@@ -1040,8 +1041,8 @@ file_entry const& file_at(int index) const;
 

If you need index-access to files you can use the num_files() and file_at() to access files using indices.

-
-

map_block()

+
+

map_block()

 std::vector<file_slice> map_block(int piece, size_type offset
@@ -1066,8 +1067,8 @@ as argument. The offsetsize is the number of bytes this range is. The size + offset
 will never be greater than the file size.

-
-

map_file()

+
+

map_file()

 peer_request map_file(int file_index, size_type file_offset
@@ -1094,8 +1095,8 @@ struct peer_request
 + size is not allowed to be greater than the file size. file_index
 must refer to a valid file, i.e. it cannot be >= num_files().

-
-

url_seeds()

+
+

url_seeds()

 std::vector<std::string> const& url_seeds() const;
@@ -1108,8 +1109,8 @@ adds one url to the list of url-seeds. Currently, the only transport protocol
 supported for the url is http.

See HTTP seeding for more information.

-
-

print()

+
+

print()

 void print(std::ostream& os) const;
@@ -1118,8 +1119,8 @@ void print(std::ostream& os) const;
 

The print() function is there for debug purposes only. It will print the info from the torrent file to the given outstream.

-
-

trackers()

+
+

trackers()

 std::vector<announce_entry> const& trackers() const;
@@ -1138,8 +1139,8 @@ struct announce_entry
 };
 
-
-

total_size() piece_length() piece_size() num_pieces()

+
+

total_size() piece_length() piece_size() num_pieces()

 size_type total_size() const;
@@ -1156,8 +1157,8 @@ the piece index as argument and gives you the exact size of that piece. It will
 be the same as piece_length() except in the case of the last piece, which may
 be smaller.

-
-

hash_for_piece() info_hash()

+
+

hash_for_piece() info_hash()

 size_type piece_size(unsigned int index) const;
@@ -1170,8 +1171,8 @@ torrent file. For more information on the info_hash() will only return a valid hash if the torrent_info was read from a
 .torrent file or if an entry was created from it (through create_torrent).

-
-

name() comment() creation_date() creator()

+
+

name() comment() creation_date() creator()

 std::string const& name() const;
@@ -1188,8 +1189,8 @@ in the torrent file, this will return a date of January 1:st 1970.

creator() returns the creator string in the torrent. If there is no creator string it will return an empty string.

-
-

priv() set_priv()

+
+

priv() set_priv()

 bool priv() const;
@@ -1200,8 +1201,8 @@ void set_priv(bool v);
 distributed on the trackerless network (the kademlia DHT).

set_priv() sets or clears the private flag on this torrent.

-
-

nodes()

+
+

nodes()

 std::vector<std::pair<std::string, int> > const& nodes() const;
@@ -1210,8 +1211,8 @@ std::vector<std::pair<std::string, int> > const& nodes() const;
 

If this torrent contains any DHT nodes, they are put in this vector in their original form (host name and port number).

-
-

add_node()

+
+

add_node()

 void add_node(std::pair<std::string, int> const& node);
@@ -1221,8 +1222,8 @@ void add_node(std::pair<std::string, int> const& node);
 be used, by the client, to bootstrap into the DHT network.

-
-

torrent_handle

+
+

torrent_handle

You will usually have to store your torrent handles somewhere, since it's the object through which you retrieve information about the torrent and aborts the torrent. Its declaration looks like this:

@@ -1272,11 +1273,19 @@ struct torrent_handle void resolve_countries(bool r); bool resolve_countries() const; + void piece_priority(int index, int priority) const; + int piece_priority(int index) const; + + void prioritize_pieces(std::vector<int> const& pieces) const; + std::vector<int> piece_priorities() const; + + void prioritize_files(std::vector<int> const& files) const; + + // these functions are deprecated void filter_piece(int index, bool filter) const; void filter_pieces(std::vector<bool> const& bitmask) const; bool is_piece_filtered(int index) const; std::vector<bool> filtered_pieces() const; - void filter_files(std::vector<bool> const& files) const; bool has_metadata() const; @@ -1291,9 +1300,10 @@ struct torrent_handle bool operator<(torrent_handle const&) const; }; -

The default constructor will initialize the handle to an invalid state. Which means you cannot -perform any operation on it, unless you first assign it a valid handle. If you try to perform -any operation on an uninitialized handle, it will throw invalid_handle.

+

The default constructor will initialize the handle to an invalid state. Which +means you cannot perform any operation on it, unless you first assign it a +valid handle. If you try to perform any operation on an uninitialized handle, +it will throw invalid_handle.

Warning

All operations on a torrent_handle may throw invalid_handle @@ -1302,9 +1312,51 @@ two exceptions, info_hash()

-

TODO: document filter_piece(), filter_pieces(), is_piece_filtered(), filtered_pieces() and filter_files()

-
-

file_progress()

+
+

piece_priority() prioritize_pieces() piece_priorities() prioritize_files()

+
+
+void piece_priority(int index, int priority) const;
+int piece_priority(int index) const;
+void prioritize_pieces(std::vector<int> const& pieces) const;
+std::vector<int> piece_priorities() const;
+void prioritize_files(std::vector<int> const& files) const;
+
+
+

These functions are used to set and get the prioritiy of individual pieces. +By default all pieces have priority 1. That means that the random rarest +first algorithm is effectively active for all pieces. You may however +change the priority of individual pieces. There are 8 different priority +levels:

+
    +
  1. piece is not downloaded at all
  2. +
  3. normal priority. Download order is dependent on availability
  4. +
  5. higher than normal priority. Pieces are preferred over pieces with +the same availability, but not over pieces with lower availability
  6. +
  7. pieces are as likely to be picked as partial pieces.
  8. +
  9. pieces are preferred over partial pieces, but not over pieces with +lower availability
  10. +
  11. currently the same as 4
  12. +
  13. piece is as likely to be picked as any piece with availability 1
  14. +
  15. maximum priority, availability is disregarded, the piece is preferred +over any other piece with lower priority
  16. +
+

The exact definitions of these priorities are implementation details, and +subject to change. The interface guarantees that higher number means higher +priority, and that 0 means do not download.

+

piece_priority sets or gets the priority for an individual piece, +specified by index.

+

prioritize_pieces takes a vector of integers, one integer per piece in +the torrent. All the piece priorities will be updated with the priorities +in the vector.

+

piece_priorities returns a vector with one element for each piece in the +torrent. Each element is the current priority of that piece.

+

prioritize_files takes a vector that has at as many elements as there are +files in the torrent. Each entry is the priority of that file. The function +sets the priorities of all the pieces in the torrent based on the vector.

+
+
+

file_progress()

 void file_progress(std::vector<float>& fp);
@@ -1315,8 +1367,8 @@ range [0, 1]) describing the download progress of each file in this torrent.
 The progress values are ordered the same as the files in the torrent_info.
 This operation is not very cheap.

-
-

save_path()

+
+

save_path()

 boost::filesystem::path save_path() const;
@@ -1325,8 +1377,8 @@ boost::filesystem::path save_path() const;
 

save_path() returns the path that was given to add_torrent() when this torrent was started.

-
-

move_storage()

+
+

move_storage()

 bool move_storage(boost::filesystem::path const& save_path) const;
@@ -1338,8 +1390,8 @@ the same drive as the original save path. If the move operation fails, this func
 returns false, otherwise true. Post condition for successful operation is:
 save_path() == save_path.

-
-

force_reannounce()

+
+

force_reannounce()

 void force_reannounce() const;
@@ -1349,8 +1401,8 @@ void force_reannounce() const;
 peers. If the torrent is invalid, queued or in checking mode, this functions will throw
 invalid_handle.

-
-

connect_peer()

+
+

connect_peer()

 void connect_peer(asio::ip::tcp::endpoint const& adr) const;
@@ -1362,8 +1414,8 @@ be disconnected. No harm can be done by using this other than an unnecessary con
 attempt is made. If the torrent is uninitialized or in queued or checking mode, this
 will throw invalid_handle.

-
-

name()

+
+

name()

 std::string name() const;
@@ -1373,8 +1425,8 @@ std::string name() const;
 case the torrent was started without metadata, and hasn't completely received it yet,
 it returns the name given to it when added to the session. See session::add_torrent.

-
-

set_ratio()

+
+

set_ratio()

 void set_ratio(float ratio) const;
@@ -1388,8 +1440,8 @@ attempt to upload in return for each download. e.g. if set to 2, the client will
 2 bytes for every byte received. The default setting for this is 0, which will make it work
 as a standard client.

-
-

set_upload_limit() set_download_limit()

+
+

set_upload_limit() set_download_limit()

 void set_upload_limit(int limit) const;
@@ -1403,8 +1455,8 @@ Note that setting a higher limit on a torrent then the global limit (
-

set_sequenced_download_threshold()

+
+

set_sequenced_download_threshold()

 void set_sequenced_download_threshold(int threshold);
@@ -1421,8 +1473,8 @@ in practice.

negatively in the swarm. It should basically only be used in situations where the random seeks on the disk is the download bottleneck.

-
-

set_peer_upload_limit() set_peer_download_limit()

+
+

set_peer_upload_limit() set_peer_download_limit()

 void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
@@ -1432,8 +1484,8 @@ void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
 

Works like set_upload_limit and set_download_limit respectively, but controls individual peer instead of the whole torrent.

-
-

pause() resume() is_paused()

+
+

pause() resume() is_paused()

 void pause() const;
@@ -1447,8 +1499,8 @@ all potential (not connected) peers. You can use file_error_alert.

-
-

resolve_countries()

+
+

resolve_countries()

 void resolve_countries(bool r);
@@ -1460,8 +1512,8 @@ torrent. It defaults to false. If it is set to true, the country member set. See peer_info for more information
 on how to interpret this field.

-
-

is_seed()

+
+

is_seed()

 bool is_seed() const;
@@ -1469,8 +1521,8 @@ bool is_seed() const;
 

Returns true if the torrent is in seed mode (i.e. if it has finished downloading).

-
-

has_metadata()

+
+

has_metadata()

 bool has_metadata() const;
@@ -1481,8 +1533,8 @@ metadata has been downloaded). The only scenario where this can return false is
 was started torrent-less (i.e. with just an info-hash and tracker ip). Note that if the torrent
 doesn't have metadata, the member get_torrent_info() will throw.

-
-

set_tracker_login()

+
+

set_tracker_login()

 void set_tracker_login(std::string const& username
@@ -1492,8 +1544,8 @@ void set_tracker_login(std::string const& username
 

set_tracker_login() sets a username and password that will be sent along in the HTTP-request of the tracker announce. Set this if the tracker requires authorization.

-
-

trackers() replace_trackers()

+
+

trackers() replace_trackers()

 std::vector<announce_entry> const& trackers() const;
@@ -1509,8 +1561,8 @@ a list of the same form as the one returned from force_reannounce().

-
-

add_url_seed()

+
+

add_url_seed()

 void add_url_seed(std::string const& url);
@@ -1522,8 +1574,8 @@ will connect to the server and try to download pieces from it, unless it's
 paused, queued, checking or seeding.

See HTTP seeding for more information.

-
-

use_interface()

+
+

use_interface()

 void use_interface(char const* net_interface) const;
@@ -1534,8 +1586,8 @@ connections. By default, it uses the same interface as the 
 
-
-

info_hash()

+
+

info_hash()

 sha1_hash info_hash() const;
@@ -1543,8 +1595,8 @@ sha1_hash info_hash() const;
 

info_hash() returns the info-hash for the torrent.

-
-

set_max_uploads() set_max_connections()

+
+

set_max_uploads() set_max_connections()

 void set_max_uploads(int max_uploads) const;
@@ -1558,8 +1610,8 @@ connections are used up, incoming connections may be refused or poor connections
 This must be at least 2. The default is unlimited number of connections. If -1 is given to the
 function, it means unlimited.

-
-

write_resume_data()

+
+

write_resume_data()

 entry write_resume_data() const;
@@ -1581,8 +1633,8 @@ not be ready to write resume data.
 is still downloading! The recommended practice is to first pause the torrent, then generate the
 fast resume data, and then close it down.

-
-

status()

+
+

status()

 torrent_status status() const;
@@ -1592,8 +1644,8 @@ torrent_status status() const;
 torrent. If the torrent_handle is invalid, it will throw invalid_handle exception.
 See torrent_status.

-
-

get_download_queue()

+
+

get_download_queue()

 void get_download_queue(std::vector<partial_piece_info>& queue) const;
@@ -1629,8 +1681,8 @@ or not. And the num_downloads
 
-
-

get_peer_info()

+
+

get_peer_info()

 void get_peer_info(std::vector<peer_info>&) const;
@@ -1641,8 +1693,8 @@ with one entry for each peer connected to this torrent, given the handle is vali
 torrent_handle is invalid, it will throw invalid_handle exception. Each entry in
 the vector contains information about that particular peer. See peer_info.

-
-

get_torrent_info()

+
+

get_torrent_info()

 torrent_info const& get_torrent_info() const;
@@ -1655,8 +1707,8 @@ exception will be thrown. The torrent may be in a state without metadata only if
 it was started without a .torrent file, i.e. by using the libtorrent extension of
 just supplying a tracker and info-hash.

-
-

is_valid()

+
+

is_valid()

 bool is_valid() const;
@@ -1671,8 +1723,8 @@ that refers to that torrent will become invalid.

TODO: document storage

-
-

torrent_status

+
+

torrent_status

It contains the following fields:

 struct torrent_status
@@ -1844,8 +1896,8 @@ bytes that each bit in the partia
 (see get_download_queue()). This is typically 16 kB, but it may be
 larger if the pieces are larger.

-
-

peer_info

+
+

peer_info

It contains the following fields:

 struct peer_info
@@ -1997,8 +2049,8 @@ string.

connection_type can currently be one of standard_bittorrent or web_seed. These are currently the only implemented protocols.

-
-

session_settings

+
+

session_settings

You have some control over tracker requests through the session_settings object. You create it and fill it with your settings and then use session::set_settings() to apply them. You have control over proxy and authorization settings and also the user-agent @@ -2106,8 +2158,8 @@ swarm has the same IP address.

all trackers in its tracker list has failed. Either by an explicit error message or a time out.

-
-

ip_filter

+
+

ip_filter

The ip_filter class is a set of rules that uniquely categorizes all ip addresses as allowed or disallowed. The default constructor creates a single rule that allows all addresses (0.0.0.0 - 255.255.255.255 for @@ -2139,8 +2191,8 @@ public: };

-
-

ip_filter()

+
+

ip_filter()

 ip_filter()
@@ -2150,8 +2202,8 @@ ip_filter()
 

postcondition: access(x) == 0 for every x

-
-

add_rule()

+
+

add_rule()

 void add_rule(address first, address last, int flags);
@@ -2168,8 +2220,8 @@ means disallowed.

This means that in a case of overlapping ranges, the last one applied takes precedence.

-
-

access()

+
+

access()

 int access(address const& addr) const;
@@ -2180,8 +2232,8 @@ can currently be 0 or ip_filter::
 is O(log n), where n is the minimum number of non-overlapping ranges to describe
 the current filter.

-
-

export_filter()

+
+

export_filter()

 boost::tuple<std::vector<ip_range<address_v4> >
@@ -2196,8 +2248,8 @@ entry in the returned vector is a range with the access control specified in its
 and one for IPv6 addresses.

-
-

big_number

+
+

big_number

Both the peer_id and sha1_hash types are typedefs of the class big_number. It represents 20 bytes of data. Its synopsis follows:

@@ -2217,8 +2269,8 @@ public:
 

The iterators gives you access to individual bytes.

-
-

hasher

+
+

hasher

This class creates sha1-hashes. Its declaration looks like this:

 class hasher
@@ -2244,8 +2296,8 @@ call reset() to reini
 

The sha1-algorithm used was implemented by Steve Reid and released as public domain. For more info, see src/sha1.cpp.

-
-

fingerprint

+
+

fingerprint

The fingerprint class represents information about a client and its version. It is used to encode this information into the client's peer id.

This is the class declaration:

@@ -2307,10 +2359,10 @@ sure not to clash with anybody else. Here are some taken id's:

version of your client. All these numbers must be within the range [0, 9].

to_string() will generate the actual string put in the peer-id, and return it.

-
-

free functions

-
-

identify_client()

+
+

free functions

+
+

identify_client()

 std::string identify_client(peer_id const& id);
@@ -2320,8 +2372,8 @@ std::string identify_client(peer_id const& id);
 to extract a string describing a client version from its peer-id. It will recognize most clients
 that have this kind of identification in the peer-id.

-
-

client_fingerprint()

+
+

client_fingerprint()

 boost::optional<fingerprint> client_fingerprint(peer_id const& p);
@@ -2332,8 +2384,8 @@ to automate the identification of clients. It will not be able to identify peers
 standard encodings. Only Azureus style, Shadow's style and Mainline style. This function is
 declared in the header <libtorrent/identify_client.hpp>.

-
-

bdecode() bencode()

+
+

bdecode() bencode()

 template<class InIt> entry bdecode(InIt start, InIt end);
@@ -2373,8 +2425,8 @@ entry e = bdecode(buf, buf + data_size);
 it will throw invalid_encoding.

-
-

alerts

+
+

alerts

The pop_alert() function on session is the interface for retrieving alerts, warnings, messages and errors from libtorrent. If there hasn't occurred any errors (matching your severity level) pop_alert() will @@ -2465,8 +2517,8 @@ struct torrent_alert: alert };

The specific alerts, that all derives from alert, are:

-
-

listen_failed_alert

+
+

listen_failed_alert

This alert is generated when none of the ports, given in the port range, to session can be opened for listening. This alert is generated as severity level fatal.

@@ -2478,8 +2530,8 @@ struct listen_failed_alert: alert };
-
-

portmap_error_alert

+
+

portmap_error_alert

This alert is generated when a NAT router was successfully found but some part of the port mapping request failed. It contains a text message that may help the user figure out what is wrong. This alert is not generated in @@ -2496,8 +2548,8 @@ struct portmap_error_alert: alert };

-
-

portmap_alert

+
+

portmap_alert

This alert is generated when a NAT router was successfully found and a port was successfully mapped on it. On a NAT:ed network with a NAT-PMP capable router, this is typically generated once when mapping the TCP @@ -2511,8 +2563,8 @@ struct portmap_alert: alert };

-
-

file_error_alert

+
+

file_error_alert

If the storage fails to read or write files that it needs access to, this alert is generated and the torrent is paused. It is generated as severity level fatal.

@@ -2526,8 +2578,8 @@ struct file_error_alert: torrent_alert
 };
 
-
-

tracker_announce_alert

+
+

tracker_announce_alert

This alert is generated each time a tracker announce is sent (or attempted to be sent). It is generated at severity level info.

@@ -2541,8 +2593,8 @@ struct tracker_announce_alert: torrent_alert
 };
 
-
-

tracker_alert

+
+

tracker_alert

This alert is generated on tracker time outs, premature disconnects, invalid response or a HTTP response other than "200 OK". From the alert you can get the handle to the torrent the tracker belongs to. This alert is generated as severity level warning.

@@ -2562,8 +2614,8 @@ struct tracker_alert: torrent_alert };
-
-

tracker_reply_alert

+
+

tracker_reply_alert

This alert is only for informational purpose. It is generated when a tracker announce succeeds. It is generated regardless what kind of tracker was used, be it UDP, HTTP or the DHT. It is generated with severity level info.

@@ -2582,8 +2634,8 @@ struct tracker_reply_alert: torrent_alert

The num_peers tells how many peers were returned from the tracker. This is not necessarily all new peers, some of them may already be connected.

-
-

tracker_warning_alert

+
+

tracker_warning_alert

This alert is triggered if the tracker reply contains a warning field. Usually this means that the tracker announce was successful, but the tracker has a message to the client. The message string in the alert will contain the warning message from @@ -2598,8 +2650,8 @@ struct tracker_warning_alert: torrent_alert };

-
-

url_seed_alert

+
+

url_seed_alert

This alert is generated when a HTTP seed name lookup fails. This alert is generated as severity level warning.

It contains url to the HTTP seed that failed along with an error message.

@@ -2614,8 +2666,8 @@ struct url_seed_alert: torrent_alert };
-
-

hash_failed_alert

+
+

hash_failed_alert

This alert is generated when a finished piece fails its hash check. You can get the handle to the torrent which got the failed piece and the index of the piece itself from the alert. This alert is generated as severity level info.

@@ -2633,8 +2685,8 @@ struct hash_failed_alert: torrent_alert };
-
-

peer_ban_alert

+
+

peer_ban_alert

This alert is generated when a peer is banned because it has sent too many corrupt pieces to us. It is generated at severity level info. The handle member is a torrent_handle to the torrent that this peer was a member of.

@@ -2652,8 +2704,8 @@ struct peer_ban_alert: torrent_alert };
-
-

peer_error_alert

+
+

peer_error_alert

This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer will be disconnected, but you get its ip address from the alert, to identify it. This alert is generated as severity level debug.

@@ -2671,8 +2723,8 @@ struct peer_error_alert: alert };
-
-

invalid_request_alert

+
+

invalid_request_alert

This is a debug alert that is generated by an incoming invalid piece request. The handle is a handle to the torrent the peer is a member of. Ïp is the address of the peer and the request is the actual incoming request from the peer. The alert is generated as severity level @@ -2707,8 +2759,8 @@ struct peer_request the index of the piece it want data from, start is the offset within the piece where the data should be read, and length is the amount of data it wants.

-
-

torrent_finished_alert

+
+

torrent_finished_alert

This alert is generated when a torrent switches from being a downloader to a seed. It will only be generated once per torrent. It contains a torrent_handle to the torrent in question. This alert is generated as severity level info.

@@ -2723,8 +2775,8 @@ struct torrent_finished_alert: torrent_alert };
-
-

metadata_failed_alert

+
+

metadata_failed_alert

This alert is generated when the metadata has been completely received and the info-hash failed to match it. i.e. the metadata that was received was corrupt. libtorrent will automatically retry to fetch it in this case. This is only relevant when running a @@ -2741,8 +2793,8 @@ struct metadata_failed_alert: torrent_alert };

-
-

metadata_received_alert

+
+

metadata_received_alert

This alert is generated when the metadata has been completely received and the torrent can start downloading. It is not generated on torrents that are started with metadata, but only those that needs to download it from peers (when utilizing the libtorrent extension). @@ -2758,8 +2810,8 @@ struct metadata_received_alert: torrent_alert };

-
-

fastresume_rejected_alert

+
+

fastresume_rejected_alert

This alert is generated when a fastresume file has been passed to add_torrent but the files on disk did not match the fastresume file. The string explains the reason why the resume file was rejected. It is generated at severity level warning.

@@ -2773,17 +2825,17 @@ struct fastresume_rejected_alert: torrent_alert };
-
-

dispatcher

+
+

dispatcher

TODO: describe the dispatcher mechanism

-
-

exceptions

+
+

exceptions

There are a number of exceptions that can be thrown from different places in libtorrent, here's a complete list with description.

-
-

invalid_handle

+
+

invalid_handle

This exception is thrown when querying information from a torrent_handle that hasn't been initialized or that has become invalid.

@@ -2793,8 +2845,8 @@ struct invalid_handle: std::exception
 };
 
-
-

duplicate_torrent

+
+

duplicate_torrent

This is thrown by add_torrent() if the torrent already has been added to the session.

@@ -2804,8 +2856,8 @@ struct duplicate_torrent: std::exception
 };
 
-
-

invalid_encoding

+
+

invalid_encoding

This is thrown by bdecode() if the input data is not a valid bencoding.

 struct invalid_encoding: std::exception
@@ -2814,8 +2866,8 @@ struct invalid_encoding: std::exception
 };
 
-
-

type_error

+
+

type_error

This is thrown from the accessors of entry if the data type of the entry doesn't match the type you want to extract from it.

@@ -2825,8 +2877,8 @@ struct type_error: std::runtime_error
 };
 
-
-

invalid_torrent_file

+
+

invalid_torrent_file

This exception is thrown from the constructor of torrent_info if the given bencoded information doesn't meet the requirements on what information has to be present in a torrent file.

@@ -2837,8 +2889,8 @@ struct invalid_torrent_file: std::exception
 
-
-

fast resume

+
+

fast resume

The fast resume mechanism is a way to remember which pieces are downloaded and where they are put between sessions. You can generate fast resume data by calling torrent_handle::write_resume_data() on torrent_handle. You can @@ -2851,8 +2903,8 @@ start from scratch on the partially downloaded pieces.

will skip the time consuming checks. It may have to do the checking anyway, if the fast-resume data is corrupt or doesn't fit the storage for that torrent, then it will not trust the fast-resume data and just do the checking.

-
-

file format

+
+

file format

The file format is a bencoded dictionary containing the following fields:

@@ -2950,8 +3002,8 @@ re-check is issued.
-
-

threads

+
+

threads

libtorrent starts 2 or 3 threads.

    @@ -2969,8 +3021,8 @@ non-blocking host name resolution to simulate non-blocking behavior.
-
-

storage allocation

+
+

storage allocation

There are two modes in which storage (files on disk) are allocated in libtorrent.

    @@ -2983,8 +3035,8 @@ pieces that have been downloaded. This is the default allocation mode in libtorr

    The allocation mode is selected when a torrent is started. It is passed as a boolean argument to session::add_torrent() (see add_torrent()). These two modes have different drawbacks and benefits.

    -
    -

    full allocation

    +
    +

    full allocation

    When a torrent is started in full allocation mode, the checker thread (see threads) will make sure that the entire storage is allocated, and fill any gaps with zeros. It will of course still check for existing pieces and fast resume data. The main @@ -3008,8 +3060,8 @@ filesystems' file allocation, and reduce fragmentation.

-
-

compact allocation

+
+

compact allocation

The compact allocation will only allocate as much storage as it needs to keep the pieces downloaded so far. This means that pieces will be moved around to be placed at their final position in the files while downloading (to make sure the completed @@ -3055,8 +3107,8 @@ contain any piece), return that slot index.

-
-

extensions

+
+

extensions

These extensions all operates within the extension protocol. The name of the extension is the name used in the extension-list packets, and the payload is the data in the extended message (not counting the @@ -3065,8 +3117,8 @@ length-prefix, message-id nor extension-id).

handshake, it may be incompatible with future versions of the mainline bittorrent client.

These are the extensions that are currently implemented.

-
-

metadata from peers

+
+

metadata from peers

Extension name: "LT_metadata"

The point with this extension is that you don't have to distribute the metadata (.torrent-file) separately. The metadata can be distributed @@ -3184,8 +3236,8 @@ doesn't have any metadata.

-
-

HTTP seeding

+
+

HTTP seeding

The HTTP seed extension implements this specification.

The libtorrent implementation assumes that, if the URL ends with a slash ('/'), the filename should be appended to it in order to request pieces from @@ -3195,8 +3247,8 @@ torrent's name '/' the file name is appended. This is the same directory structure that libtorrent will download torrents into.

-
-

filename checks

+
+

filename checks

Boost.Filesystem will by default check all its paths to make sure they conform to filename requirements on many platforms. If you don't want this check, you can set it to either only check for native filesystem requirements or turn it off @@ -3206,8 +3258,8 @@ boost::filesystem::path::default_name_check(boost::filesystem::native);

for example. For more information, see the Boost.Filesystem docs.

-
-

acknowledgments

+
+

acknowledgments

Written by Arvid Norberg. Copyright © 2003-2006

Contributions by Magnus Jonsson, Daniel Wallin and Cory Nelson

Lots of testing, suggestions and contributions by Massaroddel and Tianhao Qiu.

diff --git a/docs/manual.rst b/docs/manual.rst index 844d8da09..c1e8f6063 100755 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -1217,11 +1217,19 @@ Its declaration looks like this:: void resolve_countries(bool r); bool resolve_countries() const; + void piece_priority(int index, int priority) const; + int piece_priority(int index) const; + + void prioritize_pieces(std::vector const& pieces) const; + std::vector piece_priorities() const; + + void prioritize_files(std::vector const& files) const; + + // these functions are deprecated void filter_piece(int index, bool filter) const; void filter_pieces(std::vector const& bitmask) const; bool is_piece_filtered(int index) const; std::vector filtered_pieces() const; - void filter_files(std::vector const& files) const; bool has_metadata() const; @@ -1236,9 +1244,10 @@ Its declaration looks like this:: bool operator<(torrent_handle const&) const; }; -The default constructor will initialize the handle to an invalid state. Which means you cannot -perform any operation on it, unless you first assign it a valid handle. If you try to perform -any operation on an uninitialized handle, it will throw ``invalid_handle``. +The default constructor will initialize the handle to an invalid state. Which +means you cannot perform any operation on it, unless you first assign it a +valid handle. If you try to perform any operation on an uninitialized handle, +it will throw ``invalid_handle``. .. warning:: All operations on a ``torrent_handle`` may throw invalid_handle_ exception, in case the handle is no longer refering to a torrent. There are @@ -1246,7 +1255,54 @@ any operation on an uninitialized handle, it will throw ``invalid_handle``. Since the torrents are processed by a background thread, there is no guarantee that a handle will remain valid between two calls. -*TODO: document filter_piece(), filter_pieces(), is_piece_filtered(), filtered_pieces() and filter_files()* + +piece_priority() prioritize_pieces() piece_priorities() prioritize_files() +-------------------------------------------------------------------------- + + :: + + void piece_priority(int index, int priority) const; + int piece_priority(int index) const; + void prioritize_pieces(std::vector const& pieces) const; + std::vector piece_priorities() const; + void prioritize_files(std::vector const& files) const; + +These functions are used to set and get the prioritiy of individual pieces. +By default all pieces have priority 1. That means that the random rarest +first algorithm is effectively active for all pieces. You may however +change the priority of individual pieces. There are 8 different priority +levels: + +0. piece is not downloaded at all +1. normal priority. Download order is dependent on availability +2. higher than normal priority. Pieces are preferred over pieces with + the same availability, but not over pieces with lower availability +3. pieces are as likely to be picked as partial pieces. +4. pieces are preferred over partial pieces, but not over pieces with + lower availability +5. *currently the same as 4* +6. piece is as likely to be picked as any piece with availability 1 +7. maximum priority, availability is disregarded, the piece is preferred + over any other piece with lower priority + +The exact definitions of these priorities are implementation details, and +subject to change. The interface guarantees that higher number means higher +priority, and that 0 means do not download. + +``piece_priority`` sets or gets the priority for an individual piece, +specified by ``index``. + +``prioritize_pieces`` takes a vector of integers, one integer per piece in +the torrent. All the piece priorities will be updated with the priorities +in the vector. + +``piece_priorities`` returns a vector with one element for each piece in the +torrent. Each element is the current priority of that piece. + +``prioritize_files`` takes a vector that has at as many elements as there are +files in the torrent. Each entry is the priority of that file. The function +sets the priorities of all the pieces in the torrent based on the vector. + file_progress() --------------- diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 9451f1d4b..d1523d589 100755 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -138,18 +138,21 @@ namespace libtorrent void we_have(int index); // sets the priority of a piece. - // 0 is filtered, i.e. do not download - // 1 is normal priority - // 2 is high priority - // 3 is maximum priority (availability is ignored) void set_piece_priority(int index, int prio); // returns the priority for the piece at 'index' int piece_priority(int index) const; + // returns the current piece priorities for all pieces + void piece_priorities(std::vector& pieces) const; + + // ========== start deprecation ============== + // fills the bitmask with 1's for pieces that are filtered void filtered_pieces(std::vector& mask) const; + // ========== end deprecation ============== + // pieces should be the vector that represents the pieces a // client has. It returns a list of all pieces that this client // has and that are interesting to download. It returns them in @@ -245,18 +248,21 @@ namespace libtorrent unsigned downloading : 1; // is 0 if the piece is filtered (not to be downloaded) // 1 is normal priority (default) - // 2 is high priority - // 3 is maximum priority (ignores availability) - unsigned piece_priority : 2; + // 2 is higher priority than pieces at the same availability level + // 3 is same priority as partial pieces + // 4 is higher priority than partial pieces + // 5 and 6 same priority as availability 1 (ignores availability) + // 7 is maximum priority (ignores availability) + unsigned piece_priority : 3; // index in to the piece_info vector - unsigned index : 19; + unsigned index : 18; enum { // index is set to this to indicate that we have the // piece. There is no entry for the piece in the // buckets if this is the case. - we_have_index = 0x7ffff, + we_have_index = 0x3ffff, // the priority value that means the piece is filtered filter_priority = 0, // the max number the peer count can hold @@ -281,7 +287,11 @@ namespace libtorrent switch (piece_priority) { case 2: return prio - 1; - case 3: return 1; + case 3: return (std::max)(prio / 2, 1); + case 4: return (std::max)(prio / 2 - 1, 1); + case 5: + case 6: return (std::min)(prio / 2 - 1, 2); + case 7: return 1; } return prio; } diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 875a8a8bb..963f4adb2 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -171,12 +171,23 @@ namespace libtorrent void resume(); bool is_paused() const { return m_paused; } + // ============ start deprecation ============= void filter_piece(int index, bool filter); void filter_pieces(std::vector const& bitmask); bool is_piece_filtered(int index) const; void filtered_pieces(std::vector& bitmask) const; - void filter_files(std::vector const& files); + // ============ end deprecation ============= + + + void set_piece_priority(int index, int priority); + int piece_priority(int index) const; + + void prioritize_pieces(std::vector const& pieces); + void piece_priorities(std::vector&) const; + + void prioritize_files(std::vector const& files); + torrent_status status() const; void file_progress(std::vector& fp) const; diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 92dbdf34b..337ca7fbd 100755 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -188,7 +188,7 @@ namespace libtorrent // the number of distributed copies of the file. // note that one copy may be spread out among many peers. // - // the whole number part tells how many copies + // the integer part tells how many copies // there are of the rarest piece(s) // // the fractional part tells the fraction of pieces that @@ -247,17 +247,33 @@ namespace libtorrent void resolve_countries(bool r); bool resolve_countries() const; + // all these are deprecated, use piece + // priority functions instead + + // ================ start deprecation ============ + // marks the piece with the given index as filtered // it will not be downloaded void filter_piece(int index, bool filter) const; void filter_pieces(std::vector const& pieces) const; bool is_piece_filtered(int index) const; std::vector filtered_pieces() const; - // marks the file with the given index as filtered // it will not be downloaded void filter_files(std::vector const& files) const; + // ================ end deprecation ============ + + // priority must be within the range [0, 7] + void piece_priority(int index, int priority) const; + int piece_priority(int index) const; + + void prioritize_pieces(std::vector const& pieces) const; + std::vector piece_priorities() const; + + void prioritize_files(std::vector const& files) const; + + // set the interface to bind outgoing connections // to. void use_interface(const char* net_interface) const; diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 4f32453bc..e47949e2e 100755 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -649,7 +649,7 @@ namespace libtorrent { TORRENT_PIECE_PICKER_INVARIANT_CHECK; assert(new_piece_priority >= 0); - assert(new_piece_priority <= 3); + assert(new_piece_priority <= 7); assert(index >= 0); assert(index < (int)m_piece_map.size()); @@ -701,34 +701,7 @@ namespace libtorrent move(prev_priority, p.index); } } -/* - // this function can be used for pieces that we don't - // have, but have marked as filtered (so we didn't - // want to download them) but later want to enable for - // downloading, then we call this function and it will - // be inserted in the available piece list again - void piece_picker::mark_as_unfiltered(int index) - { - TORRENT_PIECE_PICKER_INVARIANT_CHECK; - assert(index >= 0); - assert(index < (int)m_piece_map.size()); - piece_pos& p = m_piece_map[index]; - if (!p.filtered()) return; - p.filtered(false); - if (p.index != piece_pos::we_have_index) - { - --m_num_filtered; - assert(m_num_filtered >= 0); - add(index); - } - else - { - --m_num_have_filtered; - assert(m_num_have_filtered >= 0); - } - } -*/ int piece_picker::piece_priority(int index) const { assert(index >= 0); @@ -737,6 +710,19 @@ namespace libtorrent return m_piece_map[index].piece_priority; } + void piece_picker::piece_priorities(std::vector& pieces) const + { + pieces.resize(m_piece_map.size()); + std::vector::iterator j = pieces.begin(); + for (std::vector::const_iterator i = m_piece_map.begin(), + end(m_piece_map.end()); i != end; ++i, ++j) + { + *j = i->piece_priority; + } + } + + // ============ start deprecation ============== + void piece_picker::filtered_pieces(std::vector& mask) const { mask.resize(m_piece_map.size()); @@ -747,6 +733,8 @@ namespace libtorrent *j = i->filtered(); } } + + // ============ end deprecation ============== void piece_picker::pick_pieces(const std::vector& pieces , std::vector& interesting_blocks diff --git a/src/torrent.cpp b/src/torrent.cpp index 914c2eba3..f0783c0a0 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1022,6 +1022,134 @@ namespace libtorrent return m_username + ":" + m_password; } + + + void torrent::set_piece_priority(int index, int priority) + { + INVARIANT_CHECK; + + assert(valid_metadata()); + if (is_seed()) return; + + // this call is only valid on torrents with metadata + assert(m_picker.get()); + assert(index >= 0); + assert(index < m_torrent_file.num_pieces()); + + // TODO: update peer's interesting-bit + + m_picker->set_piece_priority(index, priority); + } + + int torrent::piece_priority(int index) const + { + INVARIANT_CHECK; + + assert(valid_metadata()); + if (is_seed()) return 1; + + // this call is only valid on torrents with metadata + assert(m_picker.get()); + assert(index >= 0); + assert(index < m_torrent_file.num_pieces()); + + // TODO: update peer's interesting-bit + + return m_picker->piece_priority(index); + } + + void torrent::prioritize_pieces(std::vector const& pieces) + { + INVARIANT_CHECK; + + // this call is only valid on torrents with metadata + assert(valid_metadata()); + if (is_seed()) return; + + assert(m_picker.get()); + + // TODO: update peer's interesting-bit + + int index = 0; + for (std::vector::const_iterator i = pieces.begin() + , end(pieces.end()); i != end; ++i, ++index) + { + assert(*i >= 0); + assert(*i <= 7); + m_picker->set_piece_priority(index, *i); + } + } + + void torrent::piece_priorities(std::vector& pieces) const + { + INVARIANT_CHECK; + + // this call is only valid on torrents with metadata + assert(valid_metadata()); + if (is_seed()) + { + pieces.clear(); + pieces.resize(m_torrent_file.num_pieces(), 1); + return; + } + + assert(m_picker.get()); + m_picker->piece_priorities(pieces); + } + + namespace + { + void set_if_greater(int& piece_prio, int file_prio) + { + if (file_prio > piece_prio) piece_prio = file_prio; + } + } + + void torrent::prioritize_files(std::vector const& files) + { + INVARIANT_CHECK; + + // this call is only valid on torrents with metadata + if (!valid_metadata() || is_seed()) return; + + // the bitmask need to have exactly one bit for every file + // in the torrent + assert(int(files.size()) == m_torrent_file.num_files()); + + size_type position = 0; + + if (m_torrent_file.num_pieces()) + { + int piece_length = m_torrent_file.piece_length(); + // initialize the piece priorities to 0, then only allow + // setting higher priorities + std::vector pieces(m_torrent_file.num_pieces(), 0); + for (int i = 0; i < int(files.size()); ++i) + { + size_type start = position; + position += m_torrent_file.file_at(i).size; + // mark all pieces of the file with this file's priority + // but only if the priority is higher than the pieces + // already set (to avoid problems with overlapping pieces) + int start_piece = int(start / piece_length); + int last_piece = int(position / piece_length); + // if one piece spans several files, we might + // come here several times with the same start_piece, end_piece + std::for_each(pieces.begin() + start_piece + , pieces.begin() + last_piece + 1 + , bind(&set_if_greater, _1, files[i])); + } + prioritize_pieces(pieces); + } + } + + + + + + + + void torrent::filter_piece(int index, bool filter) { INVARIANT_CHECK; diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 75a2c65c6..03034011f 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -330,6 +330,57 @@ namespace libtorrent , bind(&torrent::set_sequenced_download_threshold, _1, threshold)); } + std::string torrent_handle::name() const + { + INVARIANT_CHECK; + return call_member(m_ses, m_chk, m_info_hash + , bind(&torrent::name, _1)); + } + + + void torrent_handle::piece_priority(int index, int priority) const + { + INVARIANT_CHECK; + + call_member(m_ses, m_chk, m_info_hash + , bind(&torrent::set_piece_priority, _1, index, priority)); + } + + int torrent_handle::piece_priority(int index) const + { + INVARIANT_CHECK; + + return call_member(m_ses, m_chk, m_info_hash + , bind(&torrent::piece_priority, _1, index)); + } + + void torrent_handle::prioritize_pieces(std::vector const& pieces) const + { + INVARIANT_CHECK; + + call_member(m_ses, m_chk, m_info_hash + , bind(&torrent::prioritize_pieces, _1, boost::cref(pieces))); + } + + std::vector torrent_handle::piece_priorities() const + { + INVARIANT_CHECK; + std::vector ret; + call_member(m_ses, m_chk, m_info_hash + , bind(&torrent::piece_priorities, _1, boost::ref(ret))); + return ret; + } + + void torrent_handle::prioritize_files(std::vector const& files) const + { + INVARIANT_CHECK; + + call_member(m_ses, m_chk, m_info_hash + , bind(&torrent::prioritize_files, _1, boost::cref(files))); + } + +// ============ start deprecation =============== + void torrent_handle::filter_piece(int index, bool filter) const { INVARIANT_CHECK; @@ -341,7 +392,7 @@ namespace libtorrent { INVARIANT_CHECK; call_member(m_ses, m_chk, m_info_hash - , bind(&torrent::filter_pieces, _1, pieces)); + , bind(&torrent::filter_pieces, _1, boost::cref(pieces))); } bool torrent_handle::is_piece_filtered(int index) const @@ -351,13 +402,6 @@ namespace libtorrent , bind(&torrent::is_piece_filtered, _1, index)); } - std::string torrent_handle::name() const - { - INVARIANT_CHECK; - return call_member(m_ses, m_chk, m_info_hash - , bind(&torrent::name, _1)); - } - std::vector torrent_handle::filtered_pieces() const { INVARIANT_CHECK; @@ -374,6 +418,9 @@ namespace libtorrent , bind(&torrent::filter_files, _1, files)); } +// ============ end deprecation =============== + + std::vector const& torrent_handle::trackers() const { INVARIANT_CHECK;