From e9ef2b56a569566ee48a4d8c903785bb990236c4 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 17 Oct 2004 22:23:08 +0000 Subject: [PATCH] *** empty log message *** --- docs/manual.html | 2 ++ docs/manual.rst | 3 +++ include/libtorrent/peer_info.hpp | 1 + src/entry.cpp | 4 ++++ src/peer_connection.cpp | 4 +++- src/torrent.cpp | 6 +++--- src/torrent_handle.cpp | 1 + 7 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/manual.html b/docs/manual.html index 41249a7f4..863c3c5a9 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -1267,6 +1267,7 @@ struct peer_info size_type total_upload; peer_id id; std::vector<bool> pieces; + bool seed; int upload_limit; int upload_ceiling; @@ -1326,6 +1327,7 @@ is using. See identify_client()_

pieces is a vector of booleans that has as many entries as there are pieces in the torrent. Each boolean tells you if the peer has that piece (if it's set to true) or if the peer miss that piece (set to false).

+

seed is true if this peer is a seed.

upload_limit is the number of bytes per second we are allowed to send to this 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.

diff --git a/docs/manual.rst b/docs/manual.rst index ffd989846..ad1fc1220 100755 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -1238,6 +1238,7 @@ It contains the following fields:: size_type total_upload; peer_id id; std::vector pieces; + bool seed; int upload_limit; int upload_ceiling; @@ -1293,6 +1294,8 @@ is using. See identify_client()_ in the torrent. Each boolean tells you if the peer has that piece (if it's set to true) or if the peer miss that piece (set to false). +``seed`` is true if this peer is a seed. + ``upload_limit`` is the number of bytes per second we are allowed to send to this 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``. diff --git a/include/libtorrent/peer_info.hpp b/include/libtorrent/peer_info.hpp index fa340a866..cb2496509 100755 --- a/include/libtorrent/peer_info.hpp +++ b/include/libtorrent/peer_info.hpp @@ -60,6 +60,7 @@ namespace libtorrent size_type total_upload; peer_id id; std::vector pieces; + bool seed; // true if this is a seed int upload_limit; // from peer_connection int upload_ceiling; // from the global upload limiter diff --git a/src/entry.cpp b/src/entry.cpp index 0ed5c1e87..33e1f512e 100755 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -246,6 +246,9 @@ namespace libtorrent void entry::sort() { +#if (defined(_MSC_VER) && _MSC_VER < 1300) + assert(false); +#else using boost::bind; if (type() == dictionary_t) { @@ -254,6 +257,7 @@ namespace libtorrent , bind(&entry::dictionary_type::value_type::first, _1) , bind(&entry::dictionary_type::value_type::first, _2))); } +#endif } void entry::print(std::ostream& os, int indent) const diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index db09d1ef9..262b4ebd4 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2370,7 +2370,9 @@ namespace libtorrent bool peer_connection::is_seed() const { - return m_num_pieces == (int)m_have_piece.size(); + // if m_num_pieces == 0, we probably doesn't have the + // metadata yet. + return m_num_pieces == (int)m_have_piece.size() && m_num_pieces > 0; } void peer_connection::send_buffer_updated() diff --git a/src/torrent.cpp b/src/torrent.cpp index 7a8a9789c..0446ad0e4 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -232,9 +232,9 @@ namespace libtorrent assert(m_torrent_file.is_valid()); m_have_pieces.resize(m_torrent_file.num_pieces(), false); - m_storage.reset(new piece_manager(m_torrent_file, m_save_path)); + m_storage = std::auto_ptr(new piece_manager(m_torrent_file, m_save_path)); m_block_size = calculate_block_size(m_torrent_file); - m_picker.reset(new piece_picker( + m_picker = std::auto_ptr(new piece_picker( static_cast(m_torrent_file.piece_length() / m_block_size) , static_cast((m_torrent_file.total_size()+m_block_size-1)/m_block_size))); } @@ -1000,7 +1000,7 @@ namespace libtorrent int torrent::num_seeds() const { - return (int)count_if(m_connections.begin(), m_connections.end(), + return (int)std::count_if(m_connections.begin(), m_connections.end(), boost::bind(&peer_connection::is_seed, boost::bind(&std::map::value_type::second, _1))); } diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index f5eb0a815..a7ad358d2 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -607,6 +607,7 @@ namespace libtorrent if (peer->is_local()) p.flags |= peer_info::local_connection; p.pieces = peer->get_bitfield(); + p.seed = peer->is_seed(); } }