Version: | 2.0.11 |
---|
Table of contents
Declared in "libtorrent/client_data.hpp"
A thin wrapper around a void pointer used as "user data". i.e. an opaque cookie passed in to libtorrent and returned on demand. It adds type-safety by requiring the same type be requested out of it as was assigned to it.
struct client_data_t { client_data_t () = default; explicit client_data_t (T* v); client_data_t& operator= (T* v); explicit operator T () const; T* get () const; client_data_t& operator= (void const*) = delete; operator void* () const = delete; client_data_t& operator= (void*) = delete; operator void const* () const = delete; template <typename T, typename U = typename std::enable_if<std::is_pointer<T>::value>::type> };[report issue]
client_data_t& operator= (void const*) = delete; operator void* () const = delete; client_data_t& operator= (void*) = delete; operator void const* () const = delete;
we don't allow type-unsafe operations
[report issue]Declared in "libtorrent/add_torrent_params.hpp"
The add_torrent_params contains all the information in a .torrent file along with all information necessary to add that torrent to a session. The key fields when adding a torrent are:
In order to add a torrent to a session, one of those fields must be set in addition to save_path. The add_torrent_params object can then be passed into one of the session::add_torrent() overloads or session::async_add_torrent().
If you only specify the info-hash, the torrent file will be downloaded from peers, which requires them to support the metadata extension. For the metadata extension to work, libtorrent must be built with extensions enabled (TORRENT_DISABLE_EXTENSIONS must not be defined). It also takes an optional name argument. This may be left empty in case no name should be assigned to the torrent. In case it's not, the name is used for the torrent as long as it doesn't have metadata. See torrent_handle::name.
The add_torrent_params is also used when requesting resume data for a torrent. It can be saved to and restored from a file and added back to a new session. For serialization and de-serialization of add_torrent_params objects, see read_resume_data() and write_resume_data().
The add_torrent_params is also used to represent a parsed .torrent file. It can be loaded via load_torrent_file(), load_torrent_buffer() and load_torrent_parsed(). It can be saved via write_torrent_file().
struct add_torrent_params { int version = LIBTORRENT_VERSION_NUM; std::shared_ptr<torrent_info> ti; aux::noexcept_movable<std::vector<std::string>> trackers; aux::noexcept_movable<std::vector<int>> tracker_tiers; aux::noexcept_movable<std::vector<std::pair<std::string, int>>> dht_nodes; std::string name; std::string save_path; storage_mode_t storage_mode = storage_mode_sparse; client_data_t userdata; aux::noexcept_movable<std::vector<download_priority_t>> file_priorities; std::string trackerid; torrent_flags_t flags = torrent_flags::default_flags; info_hash_t info_hashes; int max_uploads = -1; int max_connections = -1; int upload_limit = -1; int download_limit = -1; std::int64_t total_uploaded = 0; std::int64_t total_downloaded = 0; int active_time = 0; int finished_time = 0; int seeding_time = 0; std::time_t added_time = 0; std::time_t completed_time = 0; std::time_t last_seen_complete = 0; int num_complete = -1; int num_incomplete = -1; int num_downloaded = -1; aux::noexcept_movable<std::vector<std::string>> http_seeds; aux::noexcept_movable<std::vector<std::string>> url_seeds; aux::noexcept_movable<std::vector<tcp::endpoint>> peers; aux::noexcept_movable<std::vector<tcp::endpoint>> banned_peers; aux::noexcept_movable<std::map<piece_index_t, bitfield>> unfinished_pieces; typed_bitfield<piece_index_t> have_pieces; typed_bitfield<piece_index_t> verified_pieces; aux::noexcept_movable<std::vector<download_priority_t>> piece_priorities; aux::vector<std::vector<sha256_hash>, file_index_t> merkle_trees; aux::vector<std::vector<bool>, file_index_t> merkle_tree_mask; aux::vector<std::vector<bool>, file_index_t> verified_leaf_hashes; aux::noexcept_movable<std::map<file_index_t, std::string>> renamed_files; std::time_t last_download = 0; std::time_t last_upload = 0; };[report issue]
the path where the torrent is or will be stored.
Note
On windows this path (and other paths) are interpreted as UNC paths. This means they must use backslashes as directory separators and may not contain the special directories "." or "..".
Setting this to an absolute path performs slightly better than a relative path.
flags controlling aspects of this torrent and how it's added. See torrent_flags_t for details.
Note
The flags field is initialized with default flags by the constructor. In order to preserve default behavior when clearing or setting other flags, make sure to bitwise OR or in a flag or bitwise AND the inverse of a flag to clear it.
max_uploads, max_connections, upload_limit, download_limit correspond to the set_max_uploads(), set_max_connections(), set_upload_limit() and set_download_limit() functions on torrent_handle. These values let you initialize these settings when the torrent is added, instead of calling these functions immediately following adding it.
-1 means unlimited on these settings just like their counterpart functions on torrent_handle
For fine grained control over rate limits, including making them apply to local peers, see peer classes.
these field can be used to initialize the torrent's cached scrape data. The scrape data is high level metadata about the current state of the swarm, as returned by the tracker (either when announcing to it or by sending a specific scrape request). num_complete is the number of peers in the swarm that are seeds, or have every piece in the torrent. num_incomplete is the number of peers in the swarm that do not have every piece. num_downloaded is the number of times the torrent has been downloaded (not initiated, but the number of times a download has completed).
Leaving any of these values set to -1 indicates we don't know, or we have not received any scrape data.
URLs can be added to these two lists to specify additional web seeds to be used by the torrent. If the flag_override_web_seeds is set, these will be the _only_ ones to be used. i.e. any web seeds found in the .torrent file will be overridden.
http_seeds expects URLs to web servers implementing the original HTTP seed specification BEP 17.
url_seeds expects URLs to regular web servers, aka "get right" style, specified in BEP 19.