added get_full_peer_list to retrieve all the peers known for a swarm

This commit is contained in:
Arvid Norberg 2008-04-13 06:32:48 +00:00
parent 643deb699f
commit 17c4257cce
5 changed files with 36 additions and 0 deletions

View File

@ -189,6 +189,18 @@ namespace libtorrent
int upload_rate_peak;
};
struct TORRENT_EXPORT peer_list_entry
{
enum flags_t
{
banned = 1,
};
tcp::endpoint ip;
int flags;
boost::uint8_t failcount;
boost::uint8_t source;
};
}
#endif // TORRENT_PEER_INFO_HPP_INCLUDED

View File

@ -298,6 +298,7 @@ namespace libtorrent
void resolve_peer_country(boost::intrusive_ptr<peer_connection> const& p) const;
void get_full_peer_list(std::vector<peer_list_entry>& v) const;
void get_peer_info(std::vector<peer_info>& v);
void get_download_queue(std::vector<partial_piece_info>& queue);

View File

@ -284,6 +284,7 @@ namespace libtorrent
torrent_handle() {}
void get_full_peer_list(std::vector<peer_list_entry>& v) const;
void get_peer_info(std::vector<peer_info>& v) const;
torrent_status status() const;
void get_download_queue(std::vector<partial_piece_info>& queue) const;

View File

@ -2227,6 +2227,22 @@ namespace libtorrent
}
#endif
void torrent::get_full_peer_list(std::vector<peer_list_entry>& v) const
{
v.clear();
v.reserve(m_policy.num_peers());
for (policy::const_iterator i = m_policy.begin_peer();
i != m_policy.end_peer(); ++i)
{
peer_list_entry e;
e.ip = i->second.ip;
e.flags = i->second.banned ? peer_list_entry::banned : 0;
e.failcount = i->second.failcount;
e.source = i->second.source;
v.push_back(e);
}
}
void torrent::get_peer_info(std::vector<peer_info>& v)
{
v.clear();

View File

@ -628,6 +628,12 @@ namespace libtorrent
}
#endif
void torrent_handle::get_full_peer_list(std::vector<peer_list_entry>& v) const
{
INVARIANT_CHECK;
TORRENT_FORWARD(get_full_peer_list(v));
}
void torrent_handle::get_peer_info(std::vector<peer_info>& v) const
{
INVARIANT_CHECK;