From b28f2ea80700dd71319c1b942fe3453b546693e4 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Sun, 1 Apr 2012 02:22:18 +0900 Subject: [PATCH] Added 'd.chunks_seen', which is limited to 'Download::peers_accounted()' number of peers for optimization reasons. --- configure.ac | 2 +- src/command_download.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6ec09630..19759a9e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_INIT(rtorrent, 0.9.1, jaris@ifi.uio.no) -AC_DEFINE(API_VERSION, 2, api version) +AC_DEFINE(API_VERSION, 3, api version) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(config.h) diff --git a/src/command_download.cc b/src/command_download.cc index f84390d6..14394e6a 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -328,6 +328,16 @@ apply_d_add_peer(core::Download* download, const std::string& arg) { torrent::connection_manager()->resolver()(host, (int)rak::socket_address::pf_inet, SOCK_STREAM, call_add_d_peer_t(download, port)); } +torrent::Object +d_chunks_seen(core::Download* download) { + const uint8_t* seen = download->download()->chunks_seen(); + + if (seen == NULL) + return std::string(); + else + return std::string((const char*)seen, download->download()->file_list()->size_chunks()); +} + torrent::Object f_multicall(core::Download* download, const torrent::Object::list_type& args) { if (args.empty()) @@ -813,6 +823,8 @@ initialize_command_download() { CMD2_DL ("d.size_pex", CMD2_ON_DL(size_pex)); CMD2_DL ("d.max_size_pex", CMD2_ON_DL(max_size_pex)); + CMD2_DL ("d.chunks_seen", tr1::bind(&d_chunks_seen, tr1::placeholders::_1)); + CMD2_DL ("d.completed_bytes", CMD2_ON_FL(completed_bytes)); CMD2_DL ("d.completed_chunks", CMD2_ON_FL(completed_chunks)); CMD2_DL ("d.left_bytes", CMD2_ON_FL(left_bytes));