From 6ff2d8accf588a4db01768fb6df45254ea58d393 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 11 Jun 2007 03:28:07 +0000 Subject: [PATCH] udpated docs and fixed python binding issues --- bindings/python/client.py | 13 ++-- bindings/python/src/session_settings.cpp | 30 +++++---- bindings/python/src/torrent_handle.cpp | 16 ++--- docs/manual.html | 83 ++++++++++++++++++------ docs/manual.rst | 44 +++++++------ 5 files changed, 123 insertions(+), 63 deletions(-) diff --git a/bindings/python/client.py b/bindings/python/client.py index 368507973..1e04a9a08 100755 --- a/bindings/python/client.py +++ b/bindings/python/client.py @@ -153,13 +153,16 @@ def print_download_queue(console, download_queue): for e in download_queue: out += '%4d: [' % e['piece_index']; - for fin, req in zip(e['finished_blocks'], e['requested_blocks']): - if fin: + for b in e['blocks']: + s = b['state'] + if s == 3: out += '#' - elif req: - out += '+' - else: + elif s == 2: + out += '=' + elif s == 1: out += '-' + else: + out += ' ' out += ']\n' write_line(console, out) diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index abbbf7a0e..2c7474c21 100755 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -37,8 +37,16 @@ void bind_session_settings() #ifndef TORRENT_DISABLE_DHT .def_readwrite("use_dht_as_fallback", &session_settings::use_dht_as_fallback) #endif - ; + ; + enum_("proxy_type") + .value("none", proxy_settings::none) + .value("socks4", proxy_settings::socks4) + .value("socks5", proxy_settings::socks5) + .value("socks5_pw", proxy_settings::socks5_pw) + .value("http", proxy_settings::http) + .value("http_pw", proxy_settings::http_pw) + ; scope ps = class_("proxy_settings") .def_readwrite("hostname", &proxy_settings::hostname) .def_readwrite("port", &proxy_settings::port) @@ -47,11 +55,16 @@ void bind_session_settings() .def_readwrite("type", &proxy_settings::type) ; - ps.attr("none") = (int)proxy_settings::none; - ps.attr("socks5") = (int)proxy_settings::socks5; - ps.attr("socks5_pw") = (int)proxy_settings::socks5_pw; - ps.attr("http") = (int)proxy_settings::http; - ps.attr("http_pw") = (int)proxy_settings::http_pw; + enum_("enc_policy") + .value("forced", pe_settings::forced) + .value("enabled", pe_settings::enabled) + .value("disabled", pe_settings::disabled) + ; + + enum_("enc_level") + .value("rc4", pe_settings::rc4) + .value("plaintext", pe_settings::plaintext) + ; scope pes = class_("pe_settings") .def_readwrite("out_enc_policy", &pe_settings::out_enc_policy) @@ -60,10 +73,5 @@ void bind_session_settings() .def_readwrite("prefer_rc4", &pe_settings::prefer_rc4) ; - pes.attr("forced") = pe_settings::forced; - pes.attr("enabled") = pe_settings::enabled; - pes.attr("disabled") = pe_settings::disabled; - pes.attr("plaintext") = pe_settings::plaintext; - pes.attr("rc4") = pe_settings::rc4; } diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index 6a557b879..6e0bc5034 100755 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -101,18 +101,16 @@ list get_download_queue(torrent_handle& handle) dict partial_piece; partial_piece["piece_index"] = i->piece_index; partial_piece["blocks_in_piece"] = i->blocks_in_piece; - list requested; - list finished; -// list peer; + list block_list; for (int k = 0; k < i->blocks_in_piece; ++k) { - requested.append(bool(i->requested_blocks[k])); - finished.append(bool(i->finished_blocks[k])); -// peer.append(i->peer[k]); + dict block_info; + block_info["state"] = i->blocks[k].state; + block_info["num_downloads"] = i->blocks[k].num_downloads; +// block_info["peer"] = i->info[k].peer; + block_list.append(block_info); } - partial_piece["requested_blocks"] = requested; - partial_piece["finished_blocks"] = finished; -// partial_piece["peer"] = peer; + partial_piece["blocks"] = block_list; ret.append(partial_piece); } diff --git a/docs/manual.html b/docs/manual.html index a1e5962b4..438b8ac5c 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -535,6 +535,7 @@ struct session_status int dht_nodes; int dht_cache_nodes; int dht_torrents; + int dht_global_nodes; };

has_incoming_connections is false as long as no incoming connections have been @@ -555,6 +556,8 @@ table. This number only includes active nodes, not cache nodes. The 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.

+

dht_global_nodes is an estimation of the total number of nodes in the DHT +network.

is_listening() listen_port() listen_on()

@@ -1735,37 +1738,43 @@ requested. The entry in the vector ( struct partial_piece_info { - enum { max_blocks_per_piece }; int piece_index; int blocks_in_piece; - std::bitset<max_blocks_per_piece> requested_blocks; - std::bitset<max_blocks_per_piece> finished_blocks; - address peer[max_blocks_per_piece]; - int num_downloads[max_blocks_per_piece]; - enum state_t { none, slow. medium, fast }; + block_info blocks[256]; + enum state_t { none, slow, medium, fast }; state_t piece_state; };

piece_index is the index of the piece in question. blocks_in_piece is the number of blocks in this particular piece. This number will be the same for most pieces, but the last piece may have fewer blocks than the standard pieces.

-

requested_blocks is a bitset with one bit per block in the piece. If a bit is set, it -means that that block has been requested, but not necessarily fully downloaded yet. To know -from whom the block has been requested, have a look in the peer array. The bit-index -in the requested_blocks and finished_blocks corresponds to the array-index into -peers and num_downloads. The array of peers is contains the address of the -peer the piece was requested from. If a piece hasn't been requested (the bit in -requested_blocks is not set) the peer array entry will be undefined.

-

The finished_blocks is a bitset where each bit says if the block is fully downloaded -or not. And the num_downloads array says how many times that block has been downloaded. -When a piece fails a hash verification, single blocks may be re-downloaded to -see if the hash test may pass then.

piece_state is set to either fast, medium, slow or none. It tells which download rate category the peers downloading this piece falls into. none means that no peer is currently downloading any part of the piece. Peers prefer picking pieces from the same category as themselves. The reason for this is to keep the number of partially downloaded pieces down. Pieces set to none can be converted into any of fast, medium or slow as soon as a peer want to download from it.

+
+struct block_info
+{
+        enum block_state_t
+        { none, requested, writing, finished };
+
+        tcp::endpoint peer;
+        unsigned state:2;
+        unsigned num_downloads:14;
+};
+
+

The block_info array contains data for each individual block in the piece. Each block has +a state (state) which is any of:

+
    +
  • none - This block has not been downloaded or requested form any peer.
  • +
  • requested - The block has been requested, but not completely downloaded yet.
  • +
  • writing - The block has been downloaded and is currently queued for being written to disk.
  • +
  • finished - The block has been written to disk.
  • +
+

The peer field is the ip address of the peer this block was downloaded from. +num_downloads is the number of times this block has been downloaded.

get_peer_info()

@@ -1999,7 +2008,11 @@ struct peer_info local_connection = 0x20, handshake = 0x40, connecting = 0x80, - queued = 0x100 + queued = 0x100, + on_parole = 0x200, + seed = 0x400, + rc4_encrypted = 0x800, + plaintext_encrypted = 0x1000 }; unsigned int flags; @@ -2023,7 +2036,6 @@ struct peer_info size_type total_upload; peer_id pid; std::vector<bool> pieces; - bool seed; int upload_limit; int download_limit; @@ -2188,6 +2200,7 @@ struct session_settings std::string user_agent; int tracker_completion_timeout; int tracker_receive_timeout; + int stop_tracker_timeout; int tracker_maximum_response_length; int piece_timeout; @@ -2202,6 +2215,12 @@ struct session_settings bool allow_multiple_connections_per_ip; int max_failcount; int min_reconnect_time; + int peer_connect_timeout; + bool ignore_limits_on_local_network; + int connection_speed; + int send_redundant_have; + bool lazy_bitfields; + int inactivity_timeout; bool use_dht_as_fallback; }; @@ -2218,6 +2237,9 @@ any data from the tracker. If no data is received for this number of seconds, the tracker will be considered as having timed out. If a tracker is down, this is the kind of timeout that will occur. The default value is 20 seconds.

+

stop_tracker_timeout is the time to wait for tracker responses when +shutting down the session object. This is given in seconds. Default is +10 seconds.

tracker_maximum_response_length is the maximum number of bytes in a tracker response. If a response size passes this number it will be rejected and the connection will be closed. On gzipped responses this size is measured @@ -2276,6 +2298,26 @@ a peer is retrieved from a peer source (other than DHT) the failcount is decremented by one, allowing another try.

min_reconnect_time is the time to wait between connection attempts. If the peer fails, the time is multiplied by fail counter.

+

peer_connect_timeout the number of seconds to wait after a connection +attempt is initiated to a peer until it is considered as having timed out. +The default is 10 seconds. This setting is especially important in case +the number of half-open connections are limited, since stale half-open +connection may delay the connection of other peers considerably.

+

ignore_limits_on_local_network, if set to true, upload, download and +unchoke limits are ignored for peers on the local network.

+

connection_speed is the number of connection attempts that +are made per second.

+

send_redundant_have controls if have messages will be sent +to peers that already have the piece. This is typically not necessary, +but it might be necessary for collecting statistics in some cases. +Default is false.

+

lazy_bitfields prevents outgoing bitfields from being full. If the +client is seed, a few bits will be set to 0, and later filled in with +have-messages. This is to prevent certain ISPs from stopping people +from seeding.

+

inactivity_timeout, if a peer is uninteresting and uninterested +for longer than this number of seconds, it will be disconnected. +Default is 10 minutes

use_dht_as_fallback determines how the DHT is used. If this is true (which it is by default), the DHT will only be used for torrents where all trackers in its tracker list has failed. Either by an explicit error @@ -2357,6 +2399,7 @@ struct proxy_settings enum proxy_type { none, + socks4, socks5, socks5_pw, http, @@ -2376,6 +2419,8 @@ options are available:

  • none - This is the default, no proxy server is used, all other fields are ignored.
  • +
  • socks4 - The server is assumed to be a SOCKS4 server that +requires a username.
  • socks5 - The server is assumed to be a SOCKS5 server (RFC 1928) that does not require any authentication. The username and password are ignored.
  • socks5_pw - The server is assumed to be a SOCKS5 server that supports diff --git a/docs/manual.rst b/docs/manual.rst index 0f4581788..e6f788ad9 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -1709,14 +1709,10 @@ requested. The entry in the vector (``partial_piece_info``) looks like this:: struct partial_piece_info { - enum { max_blocks_per_piece }; int piece_index; int blocks_in_piece; - std::bitset requested_blocks; - std::bitset finished_blocks; - address peer[max_blocks_per_piece]; - int num_downloads[max_blocks_per_piece]; - enum state_t { none, slow. medium, fast }; + block_info blocks[256]; + enum state_t { none, slow, medium, fast }; state_t piece_state; }; @@ -1724,19 +1720,6 @@ requested. The entry in the vector (``partial_piece_info``) looks like this:: number of blocks in this particular piece. This number will be the same for most pieces, but the last piece may have fewer blocks than the standard pieces. -``requested_blocks`` is a bitset with one bit per block in the piece. If a bit is set, it -means that that block has been requested, but not necessarily fully downloaded yet. To know -from whom the block has been requested, have a look in the ``peer`` array. The bit-index -in the ``requested_blocks`` and ``finished_blocks`` corresponds to the array-index into -``peers`` and ``num_downloads``. The array of peers is contains the address of the -peer the piece was requested from. If a piece hasn't been requested (the bit in -``requested_blocks`` is not set) the peer array entry will be undefined. - -The ``finished_blocks`` is a bitset where each bit says if the block is fully downloaded -or not. And the ``num_downloads`` array says how many times that block has been downloaded. -When a piece fails a hash verification, single blocks may be re-downloaded to -see if the hash test may pass then. - ``piece_state`` is set to either ``fast``, ``medium``, ``slow`` or ``none``. It tells which download rate category the peers downloading this piece falls into. ``none`` means that no peer is currently downloading any part of the piece. Peers prefer picking pieces from @@ -1744,6 +1727,29 @@ the same category as themselves. The reason for this is to keep the number of pa downloaded pieces down. Pieces set to ``none`` can be converted into any of ``fast``, ``medium`` or ``slow`` as soon as a peer want to download from it. +:: + + struct block_info + { + enum block_state_t + { none, requested, writing, finished }; + + tcp::endpoint peer; + unsigned state:2; + unsigned num_downloads:14; + }; + + +The ``block_info`` array contains data for each individual block in the piece. Each block has +a state (``state``) which is any of: + +* ``none`` - This block has not been downloaded or requested form any peer. +* ``requested`` - The block has been requested, but not completely downloaded yet. +* ``writing`` - The block has been downloaded and is currently queued for being written to disk. +* ``finished`` - The block has been written to disk. + +The ``peer`` field is the ip address of the peer this block was downloaded from. +``num_downloads`` is the number of times this block has been downloaded. get_peer_info() ---------------