⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 torrent.hpp

📁 LINUX下
💻 HPP
📖 第 1 页 / 共 2 页
字号:
		int block_size() const { TORRENT_ASSERT(m_block_size > 0); return m_block_size; }		peer_request to_req(piece_block const& p);		// this will tell all peers that we just got his piece		// and also let the piece picker know that we have this piece		// so it wont pick it for download		void announce_piece(int index);		void disconnect_all();		// this is called wheh the torrent has completed		// the download. It will post an event, disconnect		// all seeds and let the tracker know we're finished.		void completed();		// this is the asio callback that is called when a name		// lookup for a PEER is completed.		void on_peer_name_lookup(asio::error_code const& e, tcp::resolver::iterator i			, peer_id pid);		// this is the asio callback that is called when a name		// lookup for a WEB SEED is completed.		void on_name_lookup(asio::error_code const& e, tcp::resolver::iterator i			, std::string url, tcp::endpoint proxy);		// this is the asio callback that is called when a name		// lookup for a proxy for a web seed is completed.		void on_proxy_name_lookup(asio::error_code const& e, tcp::resolver::iterator i			, std::string url);		// this is called when the torrent has finished. i.e.		// all the pieces we have not filtered have been downloaded.		// If no pieces are filtered, this is called first and then		// completed() is called immediately after it.		void finished();		void async_verify_piece(int piece_index, boost::function<void(bool)> const&);		// this is called from the peer_connection		// each time a piece has failed the hash		// test		void piece_finished(int index, bool passed_hash_check);		void piece_failed(int index);		void received_redundant_data(int num_bytes)		{ TORRENT_ASSERT(num_bytes > 0); m_total_redundant_bytes += num_bytes; }		// this is true if we have all the pieces		bool is_seed() const		{			return valid_metadata()				&& m_num_pieces == m_torrent_file->num_pieces();		}		// this is true if we have all the pieces that we want		bool is_finished() const		{			if (is_seed()) return true;			return valid_metadata() && m_torrent_file->num_pieces()				- m_num_pieces - m_picker->num_filtered() == 0;		}		fs::path save_path() const;		alert_manager& alerts() const;		piece_picker& picker()		{			TORRENT_ASSERT(m_picker.get());			return *m_picker;		}		bool has_picker() const		{			return m_picker.get() != 0;		}		policy& get_policy() { return m_policy; }		piece_manager& filesystem();		torrent_info const& torrent_file() const		{ return *m_torrent_file; }		std::vector<announce_entry> const& trackers() const		{ return m_trackers; }		void replace_trackers(std::vector<announce_entry> const& urls);		torrent_handle get_handle() const;		// LOGGING#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)		virtual void debug_log(const std::string& line);#endif		// DEBUG#ifndef NDEBUG		void check_invariant() const;#endif// --------------------------------------------		// RESOURCE MANAGEMENT		void set_peer_upload_limit(tcp::endpoint ip, int limit);		void set_peer_download_limit(tcp::endpoint ip, int limit);		void set_upload_limit(int limit);		int upload_limit() const;		void set_download_limit(int limit);		int download_limit() const;		void set_max_uploads(int limit);		int max_uploads() const { return m_max_uploads; }		void set_max_connections(int limit);		int max_connections() const { return m_max_connections; }		void move_storage(fs::path const& save_path);		// unless this returns true, new connections must wait		// with their initialization.		bool ready_for_connections() const		{ return m_connections_initialized; }		bool valid_metadata() const		{ return m_torrent_file->is_valid(); }		// parses the info section from the given		// bencoded tree and moves the torrent		// to the checker thread for initial checking		// of the storage.		void set_metadata(entry const&);	private:		void on_files_deleted(int ret, disk_io_job const& j);		void on_files_released(int ret, disk_io_job const& j);		void on_torrent_paused(int ret, disk_io_job const& j);		void on_storage_moved(int ret, disk_io_job const& j);		void on_piece_verified(int ret, disk_io_job const& j			, boost::function<void(bool)> f);			void try_next_tracker();		int prioritize_tracker(int tracker_index);		void on_country_lookup(asio::error_code const& error, tcp::resolver::iterator i			, boost::intrusive_ptr<peer_connection> p) const;		bool request_bandwidth_from_session(int channel) const;		void update_peer_interest();		boost::intrusive_ptr<torrent_info> m_torrent_file;		// is set to true when the torrent has		// been aborted.		bool m_abort;		// is true if this torrent has been paused		bool m_paused;		// this is true from the time when the torrent was		// paused to the time should_request() is called		bool m_just_paused;		tracker_request::event_t m_event;		void parse_response(const entry& e, std::vector<peer_entry>& peer_list);		// the size of a request block		// each piece is divided into these		// blocks when requested		int m_block_size;		// if this pointer is 0, the torrent is in		// a state where the metadata hasn't been		// received yet.		// the piece_manager keeps the torrent object		// alive by holding a shared_ptr to it and		// the torrent keeps the piece manager alive		// with this intrusive_ptr. This cycle is		// broken when torrent::abort() is called		// Then the torrent releases the piece_manager		// and when the piece_manager is complete with all		// outstanding disk io jobs (that keeps		// the piece_manager alive) it will destruct		// and release the torrent file. The reason for		// this is that the torrent_info is used by		// the piece_manager, and stored in the		// torrent, so the torrent cannot destruct		// before the piece_manager.		boost::intrusive_ptr<piece_manager> m_owning_storage;		// this is a weak (non owninig) pointer to		// the piece_manager. This is used after the torrent		// has been aborted, and it can no longer own		// the object.		piece_manager* m_storage;		// the time of next tracker request		ptime m_next_request;		// -----------------------------		// DATA FROM TRACKER RESPONSE		// the number number of seconds between requests		// from the tracker		int m_duration;		// the scrape data from the tracker response, this		// is optional and may be -1.		int m_complete;		int m_incomplete;#ifndef NDEBUG	public:#endif		std::set<peer_connection*> m_connections;#ifndef NDEBUG	private:#endif		// The list of web seeds in this torrent. Seeds		// with fatal errors are removed from the set		std::set<std::string> m_web_seeds;		// a list of web seeds that have failed and are		// waiting to be retried		std::map<std::string, ptime> m_web_seeds_next_retry;				// urls of the web seeds that we are currently		// resolving the address for		std::set<std::string> m_resolving_web_seeds;		// used to resolve the names of web seeds		mutable tcp::resolver m_host_resolver;		#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES		// this is true while there is a country		// resolution in progress. To avoid flodding		// the DNS request queue, only one ip is resolved		// at a time.		mutable bool m_resolving_country;				// this is true if the user has enabled		// country resolution in this torrent		bool m_resolve_countries;#endif		// this announce timer is used both		// by Local service discovery and		// by the DHT.		deadline_timer m_announce_timer;		static void on_announce_disp(boost::weak_ptr<torrent> p			, asio::error_code const& e);		// this is called once per announce interval		void on_announce();#ifndef TORRENT_DISABLE_DHT		static void on_dht_announce_response_disp(boost::weak_ptr<torrent> t			, std::vector<tcp::endpoint> const& peers);		void on_dht_announce_response(std::vector<tcp::endpoint> const& peers);		bool should_announce_dht() const;		// the time when the DHT was last announced of our		// presence on this torrent		ptime m_last_dht_announce;#endif		// this is the upload and download statistics for the whole torrent.		// it's updated from all its peers once every second.		libtorrent::stat m_stat;		// -----------------------------		// a back reference to the session		// this torrent belongs to.		aux::session_impl& m_ses;		aux::checker_impl& m_checker;		boost::scoped_ptr<piece_picker> m_picker;		// the queue of peer_connections that want more bandwidth		typedef std::deque<bw_queue_entry<peer_connection, torrent> > queue_t;		queue_t m_bandwidth_queue[2];		std::vector<announce_entry> m_trackers;		// this is an index into m_trackers		int m_last_working_tracker;		int m_currently_trying_tracker;		// the number of connection attempts that has		// failed in a row, this is currently used to		// determine the timeout until next try.		int m_failed_trackers;		// this is a counter that is decreased every		// second, and when it reaches 0, the policy::pulse()		// is called and the time scaler is reset to 10.		int m_time_scaler;		// the bitmask that says which pieces we have		std::vector<bool> m_have_pieces;		// the number of pieces we have. The same as		// std::accumulate(m_have_pieces.begin(),		// m_have_pieces.end(), 0)		int m_num_pieces;		// in case the piece picker hasn't been constructed		// when this settings is set, this variable will keep		// its value until the piece picker is created		int m_sequenced_download_threshold;		// is false by default and set to		// true when the first tracker reponse		// is received		bool m_got_tracker_response;		// the upload/download ratio that each peer		// tries to maintain.		// 0 is infinite		float m_ratio;		// the number of bytes that has been		// downloaded that failed the hash-test		size_type m_total_failed_bytes;		size_type m_total_redundant_bytes;		std::string m_username;		std::string m_password;		// the network interface all outgoing connections		// are opened through		tcp::endpoint m_net_interface;		fs::path m_save_path;		// determines the storage state for this torrent.		storage_mode_t m_storage_mode;		// defaults to 16 kiB, but can be set by the user		// when creating the torrent		const int m_default_block_size;		// this is set to false as long as the connections		// of this torrent hasn't been initialized. If we		// have metadata from the start, connections are		// initialized immediately, if we didn't have metadata,		// they are initialized right after files_checked().		// valid_resume_data() will return false as long as		// the connections aren't initialized, to avoid		// them from altering the piece-picker before it		// has been initialized with files_checked().		bool m_connections_initialized;		// if the torrent is started without metadata, it may		// still be given a name until the metadata is received		// once the metadata is received this field will no		// longer be used and will be reset		boost::scoped_ptr<std::string> m_name;		session_settings const& m_settings;		storage_constructor_type m_storage_constructor;		// the maximum number of uploads for this torrent		int m_max_uploads;		// the number of unchoked peers in this torrent		int m_num_uploads;		// the maximum number of connections for this torrent		int m_max_connections;#ifndef NDEBUG		bool m_files_checked;#endif		#ifndef TORRENT_DISABLE_EXTENSIONS		typedef std::list<boost::shared_ptr<torrent_plugin> > extension_list_t;		extension_list_t m_extensions;#endif#ifndef NDEBUG		// this is the amount downloaded when this torrent		// is started. i.e.		// total_done - m_initial_done <= total_payload_download		size_type m_initial_done;#endif		policy m_policy;	};	inline ptime torrent::next_announce() const	{		return m_next_request;	}	inline void torrent::force_tracker_request()	{		m_next_request = time_now();	}	inline void torrent::force_tracker_request(ptime t)	{		m_next_request = t;	}	inline void torrent::set_tracker_login(		std::string const& name		, std::string const& pw)	{		m_username = name;		m_password = pw;	}}#endif // TORRENT_TORRENT_HPP_INCLUDED

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -