From d99762f0b0b70d329727a78657e58e5c8402241b Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 8 Dec 2003 16:39:05 +0000 Subject: [PATCH] *** empty log message *** --- docs/index.rst | 4 ++++ examples/client_test.cpp | 18 ++++++++++++------ include/libtorrent/peer_info.hpp | 1 + src/policy.cpp | 2 +- src/torrent_handle.cpp | 1 + 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 10dca632f..af02fbde5 100755 --- a/docs/index.rst +++ b/docs/index.rst @@ -569,6 +569,7 @@ fields:: peer_id id; std::vector pieces; int upload_limit; + int upload_ceiling; }; The ``flags`` attribute tells you in which state the peer is. It is set to @@ -600,6 +601,9 @@ or if the peer miss that piece (set to false). peer every second. It may be -1 if there's no limit. The upload limits of all peers should sum up to the upload limit set by ``session::set_upload_limit``. +``upload_ceiling`` is the current maximum allowed upload rate given the cownload +rate and share ratio. If the global upload rate is inlimited, the ``upload_limit`` +for every peer will be the same as their ``upload_ceiling``. get_torrent_info() ~~~~~~~~~~~~~~~~~~ diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 440dfeb43..f39a1abc1 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -75,7 +75,7 @@ void clear() HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); COORD c = {0, 0}; DWORD n; - FillConsoleOutputCharacter(h, ' ', 80 * 50, c, &n); + FillConsoleOutputCharacter(h, ' ', 80 * 80, c, &n); } #else @@ -197,7 +197,7 @@ int main(int argc, char* argv[]) entry e = bdecode(std::istream_iterator(in), std::istream_iterator()); torrent_info t(e); t.print(std::cout); - handles.push_back(s.add_torrent(t, boost::filesystem::path("", boost::filesystem::native))); + handles.push_back(s.add_torrent(t, "")); } catch (std::exception& e) { @@ -256,6 +256,9 @@ int main(int argc, char* argv[]) % add_suffix(total_up) % add_suffix(up); */ + std::cout.precision(4); + std::cout.width(5); + std::cout.fill(' '); std::cout << (s.progress*100) << "% "; for (int i = 0; i < 50; ++i) { @@ -279,10 +282,13 @@ int main(int argc, char* argv[]) i != peers.end(); ++i) { - std::cout << "d: " << add_suffix(i->down_speed) << "/s (" << add_suffix(i->total_download) - << ") u: " << add_suffix(i->up_speed) << "/s (" << add_suffix(i->total_upload) - << ") df: " << add_suffix((int)i->total_download - (int)i->total_upload) - << " f: " + std::cout << "d: " << add_suffix(i->down_speed) << "/s " + << "(" << add_suffix(i->total_download) << ") " + << "u: " << add_suffix(i->up_speed) << "/s " + << "(" << add_suffix(i->total_upload) << ") " + << "df: " << add_suffix((int)i->total_download - (int)i->total_upload) << " " + << "l: " << add_suffix(i->upload_ceiling) << "/s " + << "f: " << static_cast((i->flags & peer_info::interesting)?"I":"_") << static_cast((i->flags & peer_info::choked)?"C":"_") << static_cast((i->flags & peer_info::remote_interested)?"i":"_") diff --git a/include/libtorrent/peer_info.hpp b/include/libtorrent/peer_info.hpp index e5f95b3bc..8d1ff1ad8 100755 --- a/include/libtorrent/peer_info.hpp +++ b/include/libtorrent/peer_info.hpp @@ -57,6 +57,7 @@ namespace libtorrent peer_id id; std::vector pieces; int upload_limit; + int upload_ceiling; }; } diff --git a/src/policy.cpp b/src/policy.cpp index 0270e7f84..a4cd80fda 100755 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -352,7 +352,7 @@ namespace libtorrent { // if we're interested in the peer, we unchoke it // and hopes it will unchoke us too - if (c.is_interesting) c.unchoke(); + if (c.is_interesting()) c.unchoke(); } void policy::not_interested(peer_connection& c) diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 001ba20a9..4559d689f 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -209,6 +209,7 @@ namespace libtorrent p.total_upload = statistics.total_upload(); p.upload_limit = peer->send_quota(); + p.upload_ceiling = peer->send_quota_limit(); p.flags = 0; if (peer->is_interesting()) p.flags |= peer_info::interesting;