renamed peer_from_tracker to add_peer

This commit is contained in:
Arvid Norberg 2009-05-15 22:07:19 +00:00
parent 437cb94fd0
commit a51dfa50f5
6 changed files with 15 additions and 15 deletions

View File

@ -75,7 +75,7 @@ namespace libtorrent
struct peer; struct peer;
// this is called once for every peer we get from // this is called once for every peer we get from
// the tracker, pex, lsd or dht. // the tracker, pex, lsd or dht.
policy::peer* peer_from_tracker(const tcp::endpoint& remote, const peer_id& pid policy::peer* add_peer(const tcp::endpoint& remote, const peer_id& pid
, int source, char flags); , int source, char flags);
// false means duplicate connection // false means duplicate connection

View File

@ -869,7 +869,7 @@ namespace libtorrent
return false; return false;
} }
policy::peer* policy::peer_from_tracker(tcp::endpoint const& remote, peer_id const& pid policy::peer* policy::add_peer(tcp::endpoint const& remote, peer_id const& pid
, int src, char flags) , int src, char flags)
{ {
INVARIANT_CHECK; INVARIANT_CHECK;

View File

@ -2291,7 +2291,7 @@ namespace aux {
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
<< ": added peer from local discovery: " << peer << "\n"; << ": added peer from local discovery: " << peer << "\n";
#endif #endif
t->get_policy().peer_from_tracker(peer, peer_id(0), peer_info::lsd, 0); t->get_policy().add_peer(peer, peer_id(0), peer_info::lsd, 0);
} }
void session_impl::on_port_mapping(int mapping, int port void session_impl::on_port_mapping(int mapping, int port

View File

@ -652,7 +652,7 @@ namespace libtorrent
char const* ptr = peers_entry->string_ptr(); char const* ptr = peers_entry->string_ptr();
for (int i = 0; i < num_peers; ++i) for (int i = 0; i < num_peers; ++i)
{ {
m_policy.peer_from_tracker(read_v4_endpoint<tcp::endpoint>(ptr) m_policy.add_peer(read_v4_endpoint<tcp::endpoint>(ptr)
, id, peer_info::resume_data, 0); , id, peer_info::resume_data, 0);
} }
} }
@ -663,7 +663,7 @@ namespace libtorrent
char const* ptr = banned_peers_entry->string_ptr(); char const* ptr = banned_peers_entry->string_ptr();
for (int i = 0; i < num_peers; ++i) for (int i = 0; i < num_peers; ++i)
{ {
policy::peer* p = m_policy.peer_from_tracker(read_v4_endpoint<tcp::endpoint>(ptr) policy::peer* p = m_policy.add_peer(read_v4_endpoint<tcp::endpoint>(ptr)
, id, peer_info::resume_data, 0); , id, peer_info::resume_data, 0);
if (p) p->banned = true; if (p) p->banned = true;
} }
@ -676,7 +676,7 @@ namespace libtorrent
char const* ptr = peers6_entry->string_ptr(); char const* ptr = peers6_entry->string_ptr();
for (int i = 0; i < num_peers; ++i) for (int i = 0; i < num_peers; ++i)
{ {
m_policy.peer_from_tracker(read_v6_endpoint<tcp::endpoint>(ptr) m_policy.add_peer(read_v6_endpoint<tcp::endpoint>(ptr)
, id, peer_info::resume_data, 0); , id, peer_info::resume_data, 0);
} }
} }
@ -687,7 +687,7 @@ namespace libtorrent
char const* ptr = banned_peers6_entry->string_ptr(); char const* ptr = banned_peers6_entry->string_ptr();
for (int i = 0; i < num_peers; ++i) for (int i = 0; i < num_peers; ++i)
{ {
policy::peer* p = m_policy.peer_from_tracker(read_v6_endpoint<tcp::endpoint>(ptr) policy::peer* p = m_policy.add_peer(read_v6_endpoint<tcp::endpoint>(ptr)
, id, peer_info::resume_data, 0); , id, peer_info::resume_data, 0);
if (p) p->banned = true; if (p) p->banned = true;
} }
@ -707,7 +707,7 @@ namespace libtorrent
error_code ec; error_code ec;
tcp::endpoint a(address::from_string(ip, ec), (unsigned short)port); tcp::endpoint a(address::from_string(ip, ec), (unsigned short)port);
if (ec) continue; if (ec) continue;
m_policy.peer_from_tracker(a, id, peer_info::resume_data, 0); m_policy.add_peer(a, id, peer_info::resume_data, 0);
} }
} }
@ -724,7 +724,7 @@ namespace libtorrent
error_code ec; error_code ec;
tcp::endpoint a(address::from_string(ip, ec), (unsigned short)port); tcp::endpoint a(address::from_string(ip, ec), (unsigned short)port);
if (ec) continue; if (ec) continue;
policy::peer* p = m_policy.peer_from_tracker(a, id, peer_info::resume_data, 0); policy::peer* p = m_policy.add_peer(a, id, peer_info::resume_data, 0);
if (p) p->banned = true; if (p) p->banned = true;
} }
} }
@ -1048,7 +1048,7 @@ namespace libtorrent
get_handle(), peers.size())); get_handle(), peers.size()));
} }
std::for_each(peers.begin(), peers.end(), bind( std::for_each(peers.begin(), peers.end(), bind(
&policy::peer_from_tracker, boost::ref(m_policy), _1, peer_id(0) &policy::add_peer, boost::ref(m_policy), _1, peer_id(0)
, peer_info::dht, 0)); , peer_info::dht, 0));
} }
@ -1272,7 +1272,7 @@ namespace libtorrent
{ {
// ignore local addresses from the tracker (unless the tracker is local too) // ignore local addresses from the tracker (unless the tracker is local too)
if (is_local(a.address()) && !is_local(tracker_ip)) continue; if (is_local(a.address()) && !is_local(tracker_ip)) continue;
m_policy.peer_from_tracker(a, i->pid, peer_info::tracker, 0); m_policy.add_peer(a, i->pid, peer_info::tracker, 0);
} }
} }
@ -1343,7 +1343,7 @@ namespace libtorrent
return; return;
} }
m_policy.peer_from_tracker(*host, pid, peer_info::tracker, 0); m_policy.add_peer(*host, pid, peer_info::tracker, 0);
} }
size_type torrent::bytes_left() const size_type torrent::bytes_left() const

View File

@ -637,7 +637,7 @@ namespace libtorrent
peer_id id; peer_id id;
std::fill(id.begin(), id.end(), 0); std::fill(id.begin(), id.end(), 0);
t->get_policy().peer_from_tracker(adr, id, source, 0); t->get_policy().add_peer(adr, id, source, 0);
} }
void torrent_handle::force_reannounce( void torrent_handle::force_reannounce(

View File

@ -267,7 +267,7 @@ namespace libtorrent { namespace
char flags = *fin++; char flags = *fin++;
// ignore local addresses unless the peer is local to us // ignore local addresses unless the peer is local to us
if (is_local(adr.address()) && !is_local(m_pc.remote().address())) continue; if (is_local(adr.address()) && !is_local(m_pc.remote().address())) continue;
p.peer_from_tracker(adr, pid, peer_info::pex, flags); p.add_peer(adr, pid, peer_info::pex, flags);
} }
} }
@ -292,7 +292,7 @@ namespace libtorrent { namespace
char flags = *fin++; char flags = *fin++;
// ignore local addresses unless the peer is local to us // ignore local addresses unless the peer is local to us
if (is_local(adr.address()) && !is_local(m_pc.remote().address())) continue; if (is_local(adr.address()) && !is_local(m_pc.remote().address())) continue;
p.peer_from_tracker(adr, pid, peer_info::pex, flags); p.add_peer(adr, pid, peer_info::pex, flags);
} }
} }
#endif #endif