rename dht::node_impl -> dht::node, since this hasn't been a pimpl for quite a while

This commit is contained in:
Arvid Norberg 2015-05-09 19:00:22 +00:00
parent 4b91b87ec5
commit ca581f2258
15 changed files with 66 additions and 66 deletions

View File

@ -144,7 +144,7 @@ namespace libtorrent { namespace dht
bdecode_node m_msg;
counters& m_counters;
node_impl m_dht;
node m_dht;
rate_limited_udp_socket& m_sock;
std::vector<char> m_send_buf;

View File

@ -57,7 +57,7 @@ namespace libtorrent { namespace dht
typedef std::vector<char> packet_t;
class rpc_manager;
class node_impl;
class node;
// -------- find data -----------
@ -65,7 +65,7 @@ struct find_data : traversal_algorithm
{
typedef boost::function<void(std::vector<std::pair<node_entry, std::string> > const&)> nodes_callback;
find_data(node_impl& node, node_id target
find_data(node & node, node_id target
, nodes_callback const& ncallback);
void got_write_token(node_id const& n, std::string const& write_token);

View File

@ -51,12 +51,12 @@ public:
char const* sig);
// for immutable itms
get_item(node_impl& node
get_item(node& dht_node
, node_id target
, data_callback const& dcallback);
// for mutable items
get_item(node_impl& node
get_item(node& dht_node
, char const* pk
, std::string const& salt
, data_callback const& dcallback);

View File

@ -44,7 +44,7 @@ struct get_peers : find_data
void got_peers(std::vector<tcp::endpoint> const& peers);
get_peers(node_impl& node, node_id target
get_peers(node& dht_node, node_id target
, data_callback const& dcallback
, nodes_callback const& ncallback
, bool noseeds);
@ -63,7 +63,7 @@ struct obfuscated_get_peers : get_peers
{
typedef get_peers::nodes_callback done_callback;
obfuscated_get_peers(node_impl& node, node_id target
obfuscated_get_peers(node& dht_node, node_id target
, data_callback const& dcallback
, nodes_callback const& ncallback
, bool noseeds);

View File

@ -198,18 +198,18 @@ protected:
};
// TODO: 3 rename this to just node
class TORRENT_EXTRA_EXPORT node_impl : boost::noncopyable
class TORRENT_EXTRA_EXPORT node : boost::noncopyable
{
typedef std::map<node_id, torrent_entry> table_t;
typedef std::map<node_id, dht_immutable_item> dht_immutable_table_t;
typedef std::map<node_id, dht_mutable_item> dht_mutable_table_t;
public:
node_impl(udp_socket_interface* sock
node(udp_socket_interface* sock
, libtorrent::dht_settings const& settings, node_id nid
, dht_observer* observer, counters& cnt);
virtual ~node_impl() {}
virtual ~node() {}
void tick();
void bootstrap(std::vector<udp::endpoint> const& nodes

View File

@ -48,7 +48,7 @@ class bootstrap : public get_peers
public:
typedef get_peers::nodes_callback done_callback;
bootstrap(node_impl& node, node_id target
bootstrap(node& dht_node, node_id target
, done_callback const& callback);
virtual char const* name() const;

View File

@ -55,7 +55,7 @@ TORRENT_DECLARE_LOG(traversal);
#endif
class rpc_manager;
class node_impl;
class node;
// this class may not be instantiated as a stack object
struct traversal_algorithm : boost::noncopyable
@ -80,11 +80,11 @@ struct traversal_algorithm : boost::noncopyable
void resort_results();
void add_entry(node_id const& id, udp::endpoint addr, unsigned char flags);
traversal_algorithm(node_impl& node, node_id target);
traversal_algorithm(node & node, node_id target);
int invoke_count() const { return m_invoke_count; }
int branch_factor() const { return m_branch_factor; }
node_impl& node() const { return m_node; }
node& get_node() const { return m_node; }
protected:
@ -114,7 +114,7 @@ protected:
delete p;
}
node_impl& m_node;
node & m_node;
std::vector<observer_ptr> m_results;
node_id const m_target;
boost::uint16_t m_ref_count;

View File

@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/performance_counters.hpp" // for counters
using boost::ref;
using libtorrent::dht::node_impl;
using libtorrent::dht::node;
using libtorrent::dht::node_id;
using libtorrent::dht::packet_t;
using libtorrent::dht::msg;

View File

@ -91,10 +91,10 @@ void add_entry_fun(void* userdata, node_entry const& e)
} // anonymous namespace
find_data::find_data(
node_impl& node
node& dht_node
, node_id target
, nodes_callback const& ncallback)
: traversal_algorithm(node, target)
: traversal_algorithm(dht_node, target)
, m_nodes_callback(ncallback)
, m_done(false)
{

View File

@ -105,20 +105,20 @@ void get_item::got_data(bdecode_node const& v,
}
get_item::get_item(
node_impl& node
node& dht_node
, node_id target
, data_callback const& dcallback)
: find_data(node, target, nodes_callback())
: find_data(dht_node, target, nodes_callback())
, m_data_callback(dcallback)
{
}
get_item::get_item(
node_impl& node
node& dht_node
, char const* pk
, std::string const& salt
, data_callback const& dcallback)
: find_data(node, item_target_id(
: find_data(dht_node, item_target_id(
std::make_pair(salt.c_str(), int(salt.size())), pk)
, nodes_callback())
, m_data_callback(dcallback)

View File

@ -115,12 +115,12 @@ void get_peers::got_peers(std::vector<tcp::endpoint> const& peers)
}
get_peers::get_peers(
node_impl& node
node& dht_node
, node_id target
, data_callback const& dcallback
, nodes_callback const& ncallback
, bool noseeds)
: find_data(node, target, ncallback)
: find_data(dht_node, target, ncallback)
, m_data_callback(dcallback)
, m_noseeds(noseeds)
{
@ -165,12 +165,12 @@ observer_ptr get_peers::new_observer(void* ptr
}
obfuscated_get_peers::obfuscated_get_peers(
node_impl& node
node& dht_node
, node_id info_hash
, data_callback const& dcallback
, nodes_callback const& ncallback
, bool noseeds)
: get_peers(node, info_hash, dcallback, ncallback, noseeds)
: get_peers(dht_node, info_hash, dcallback, ncallback, noseeds)
, m_obfuscated(true)
{
}

View File

@ -108,7 +108,7 @@ node_id calculate_node_id(node_id const& nid, dht_observer* observer)
} // anonymous namespace
node_impl::node_impl(udp_socket_interface* sock
node::node(udp_socket_interface* sock
, dht_settings const& settings, node_id nid
, dht_observer* observer
, struct counters& cnt)
@ -126,7 +126,7 @@ node_impl::node_impl(udp_socket_interface* sock
m_secret[1] = random();
}
bool node_impl::verify_token(std::string const& token, char const* info_hash
bool node::verify_token(std::string const& token, char const* info_hash
, udp::endpoint const& addr)
{
if (token.length() != 4)
@ -159,7 +159,7 @@ bool node_impl::verify_token(std::string const& token, char const* info_hash
return false;
}
std::string node_impl::generate_token(udp::endpoint const& addr, char const* info_hash)
std::string node::generate_token(udp::endpoint const& addr, char const* info_hash)
{
std::string token;
token.resize(4);
@ -177,7 +177,7 @@ std::string node_impl::generate_token(udp::endpoint const& addr, char const* inf
return token;
}
void node_impl::bootstrap(std::vector<udp::endpoint> const& nodes
void node::bootstrap(std::vector<udp::endpoint> const& nodes
, find_data::nodes_callback const& f)
{
node_id target = m_id;
@ -208,23 +208,23 @@ void node_impl::bootstrap(std::vector<udp::endpoint> const& nodes
r->start();
}
int node_impl::bucket_size(int bucket)
int node::bucket_size(int bucket)
{
return m_table.bucket_size(bucket);
}
void node_impl::new_write_key()
void node::new_write_key()
{
m_secret[1] = m_secret[0];
m_secret[0] = random();
}
void node_impl::unreachable(udp::endpoint const& ep)
void node::unreachable(udp::endpoint const& ep)
{
m_rpc.unreachable(ep);
}
void node_impl::incoming(msg const& m)
void node::incoming(msg const& m)
{
// is this a reply?
bdecode_node y_ent = m.message.dict_find_string("y");
@ -305,7 +305,7 @@ void node_impl::incoming(msg const& m)
namespace
{
void announce_fun(std::vector<std::pair<node_entry, std::string> > const& v
, node_impl& node, int listen_port, sha1_hash const& ih, int flags)
, node& node, int listen_port, sha1_hash const& ih, int flags)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(node) << "sending announce_peer [ ih: " << ih
@ -338,15 +338,15 @@ namespace
a["info_hash"] = ih.to_string();
a["port"] = listen_port;
a["token"] = i->second;
a["seed"] = (flags & node_impl::flag_seed) ? 1 : 0;
if (flags & node_impl::flag_implied_port) a["implied_port"] = 1;
a["seed"] = (flags & node::flag_seed) ? 1 : 0;
if (flags & node::flag_implied_port) a["implied_port"] = 1;
node.stats_counters().inc_stats_counter(counters::dht_announce_peer_out);
node.m_rpc.invoke(e, i->first.ep(), o);
}
}
}
void node_impl::add_router_node(udp::endpoint router)
void node::add_router_node(udp::endpoint router)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(node) << "adding router node: " << router;
@ -354,14 +354,14 @@ void node_impl::add_router_node(udp::endpoint router)
m_table.add_router_node(router);
}
void node_impl::add_node(udp::endpoint node)
void node::add_node(udp::endpoint node)
{
// ping the node, and if we get a reply, it
// will be added to the routing table
send_single_refresh(node, m_table.num_active_buckets());
}
void node_impl::announce(sha1_hash const& info_hash, int listen_port, int flags
void node::announce(sha1_hash const& info_hash, int listen_port, int flags
, boost::function<void(std::vector<tcp::endpoint> const&)> f)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
@ -375,19 +375,19 @@ void node_impl::announce(sha1_hash const& info_hash, int listen_port, int flags
{
ta.reset(new obfuscated_get_peers(*this, info_hash, f
, boost::bind(&announce_fun, _1, boost::ref(*this)
, listen_port, info_hash, flags), flags & node_impl::flag_seed));
, listen_port, info_hash, flags), flags & node::flag_seed));
}
else
{
ta.reset(new get_peers(*this, info_hash, f
, boost::bind(&announce_fun, _1, boost::ref(*this)
, listen_port, info_hash, flags), flags & node_impl::flag_seed));
, listen_port, info_hash, flags), flags & node::flag_seed));
}
ta->start();
}
void node_impl::get_item(sha1_hash const& target
void node::get_item(sha1_hash const& target
, boost::function<bool(item&)> f)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
@ -399,7 +399,7 @@ void node_impl::get_item(sha1_hash const& target
ta->start();
}
void node_impl::get_item(char const* pk, std::string const& salt
void node::get_item(char const* pk, std::string const& salt
, boost::function<bool(item&)> f)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
@ -447,7 +447,7 @@ struct ping_observer : observer
node_id id;
std::copy(nodes, nodes + 20, id.begin());
nodes += 20;
m_algorithm.get()->node().m_table.heard_about(id
m_algorithm.get()->get_node().m_table.heard_about(id
, detail::read_v4_endpoint<udp::endpoint>(nodes));
}
}
@ -455,7 +455,7 @@ struct ping_observer : observer
};
void node_impl::tick()
void node::tick()
{
// every now and then we refresh our own ID, just to keep
// expanding the routing table buckets closer to us.
@ -483,7 +483,7 @@ void node_impl::tick()
send_single_refresh(ne->ep(), bucket, ne->id);
}
void node_impl::send_single_refresh(udp::endpoint const& ep, int bucket
void node::send_single_refresh(udp::endpoint const& ep, int bucket
, node_id const& id)
{
TORRENT_ASSERT(id != m_id);
@ -524,7 +524,7 @@ void node_impl::send_single_refresh(udp::endpoint const& ep, int bucket
m_rpc.invoke(e, ep, o);
}
time_duration node_impl::connection_timeout()
time_duration node::connection_timeout()
{
time_duration d = m_rpc.tick();
time_point now(aux::time_now());
@ -567,7 +567,7 @@ time_duration node_impl::connection_timeout()
return d;
}
void node_impl::status(std::vector<dht_routing_bucket>& table
void node::status(std::vector<dht_routing_bucket>& table
, std::vector<dht_lookup>& requests)
{
mutex_t::scoped_lock l(m_mutex);
@ -585,7 +585,7 @@ void node_impl::status(std::vector<dht_routing_bucket>& table
#ifndef TORRENT_NO_DEPRECATE
// TODO: 2 use the non deprecated function instead of this one
void node_impl::status(session_status& s)
void node::status(session_status& s)
{
mutex_t::scoped_lock l(m_mutex);
@ -603,7 +603,7 @@ void node_impl::status(session_status& s)
}
#endif
void node_impl::lookup_peers(sha1_hash const& info_hash, entry& reply
void node::lookup_peers(sha1_hash const& info_hash, entry& reply
, bool noseed, bool scrape) const
{
if (m_observer)
@ -803,7 +803,7 @@ private:
};
// build response
void node_impl::incoming_request(msg const& m, entry& e)
void node::incoming_request(msg const& m, entry& e)
{
if (!m_sock->has_quota())
return;

View File

@ -70,10 +70,10 @@ bool bootstrap::invoke(observer_ptr o)
}
bootstrap::bootstrap(
node_impl& node
node& dht_node
, node_id target
, done_callback const& callback)
: get_peers(node, target, get_peers::data_callback(), callback, false)
: get_peers(dht_node, target, get_peers::data_callback(), callback, false)
{
}

View File

@ -82,9 +82,9 @@ observer_ptr traversal_algorithm::new_observer(void* ptr
}
traversal_algorithm::traversal_algorithm(
node_impl& node
node& dht_node
, node_id target)
: m_node(node)
: m_node(dht_node)
, m_target(target)
, m_ref_count(0)
, m_invoke_count(0)

View File

@ -136,7 +136,7 @@ void lazy_from_entry(entry const& e, bdecode_node& l)
TEST_CHECK(ret == 0);
}
void send_dht_request(node_impl& node, char const* msg, udp::endpoint const& ep
void send_dht_request(node& node, char const* msg, udp::endpoint const& ep
, bdecode_node* reply, char const* t = "10", char const* info_hash = 0
, char const* name = 0, std::string const token = std::string(), int port = 0
, char const* target = 0, entry const* value = 0
@ -216,7 +216,7 @@ void write_peers(entry::dictionary_type& r, std::set<tcp::endpoint> const& peers
}
}
void send_dht_response(node_impl& node, bdecode_node const& request, udp::endpoint const& ep
void send_dht_response(node& node, bdecode_node const& request, udp::endpoint const& ep
, nodes_t const& nodes = nodes_t()
, std::string const token = std::string(), int port = 0
, std::set<tcp::endpoint> const& peers = std::set<tcp::endpoint>()
@ -280,7 +280,7 @@ struct announce_item
}
};
void announce_immutable_items(node_impl& node, udp::endpoint const* eps
void announce_immutable_items(node& node, udp::endpoint const* eps
, announce_item const* items, int num_items)
{
std::string token;
@ -445,7 +445,7 @@ int test_main()
mock_socket s;
obs observer;
counters cnt;
dht::node_impl node(&s, sett, node_id(0), &observer, cnt);
dht::node node(&s, sett, node_id(0), &observer, cnt);
// DHT should be running on port 48199 now
bdecode_node response;
@ -1462,7 +1462,7 @@ int test_main()
g_sent_packets.clear();
do
{
dht::node_impl node(&s, sett, (node_id::min)(), &observer, cnt);
dht::node node(&s, sett, (node_id::min)(), &observer, cnt);
udp::endpoint initial_node(address_v4::from_string("4.4.4.4"), 1234);
std::vector<udp::endpoint> nodesv;
@ -1534,7 +1534,7 @@ int test_main()
do
{
dht::node_id target = to_hash("1234876923549721020394873245098347598635");
dht::node_impl node(&s, sett, (node_id::min)(), &observer, cnt);
dht::node node(&s, sett, (node_id::min)(), &observer, cnt);
udp::endpoint initial_node(address_v4::from_string("4.4.4.4"), 1234);
node.m_table.add_node(initial_node);
@ -1627,7 +1627,7 @@ int test_main()
g_sent_packets.clear();
do
{
dht::node_impl node(&s, sett, (node_id::min)(), &observer, cnt);
dht::node node(&s, sett, (node_id::min)(), &observer, cnt);
udp::endpoint initial_node(address_v4::from_string("4.4.4.4"), 1234);
node.m_table.add_node(initial_node);
@ -1673,7 +1673,7 @@ int test_main()
g_sent_packets.clear();
do
{
dht::node_impl node(&s, sett, (node_id::min)(), &observer, cnt);
dht::node node(&s, sett, (node_id::min)(), &observer, cnt);
udp::endpoint initial_node(address_v4::from_string("4.4.4.4"), 1234);
node.m_table.add_node(initial_node);
@ -1749,7 +1749,7 @@ int test_main()
g_sent_packets.clear();
do
{
dht::node_impl node(&s, sett, (node_id::min)(), &observer, cnt);
dht::node node(&s, sett, (node_id::min)(), &observer, cnt);
enum { num_test_nodes = 2 };
node_entry nodes[num_test_nodes] =
{ node_entry(generate_next(), udp::endpoint(address_v4::from_string("4.4.4.4"), 1234))
@ -1831,7 +1831,7 @@ int test_main()
g_sent_packets.clear();
do
{
dht::node_impl node(&s, sett, (node_id::min)(), &observer, cnt);
dht::node node(&s, sett, (node_id::min)(), &observer, cnt);
enum { num_test_nodes = 2 };
node_entry nodes[num_test_nodes] =
{ node_entry(generate_next(), udp::endpoint(address_v4::from_string("4.4.4.4"), 1234))