dht source code and headers cleanup (#1150)

This commit is contained in:
Alden Torres 2016-09-24 22:20:20 -04:00 committed by Arvid Norberg
parent da8af033cc
commit 4693fcf3f1
16 changed files with 14 additions and 60 deletions

View File

@ -154,4 +154,3 @@ namespace libtorrent
}
#endif

View File

@ -30,8 +30,6 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_DISABLE_DHT
#ifndef TORRENT_DHT_TRACKER
#define TORRENT_DHT_TRACKER
@ -183,4 +181,3 @@ namespace libtorrent { namespace dht
}}
#endif
#endif

View File

@ -46,9 +46,6 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace dht
{
typedef std::vector<char> packet_t;
class rpc_manager;
class node;
// -------- find data -----------

View File

@ -58,9 +58,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
namespace libtorrent {
class alert_manager;
struct alert_dispatcher;
class alert;
struct counters;
struct dht_routing_bucket;
}
@ -74,8 +71,6 @@ struct msg;
TORRENT_EXTRA_EXPORT entry write_nodes_entry(std::vector<node_entry> const& nodes);
struct null_type {};
class announce_observer : public observer
{
public:

View File

@ -44,9 +44,9 @@ namespace libtorrent { namespace dht
struct TORRENT_EXTRA_EXPORT node_entry
{
node_entry(node_id const& id_, udp::endpoint ep, int roundtriptime = 0xffff
node_entry(node_id const& id_, udp::endpoint const& ep, int roundtriptime = 0xffff
, bool pinged = false);
node_entry(udp::endpoint ep);
node_entry(udp::endpoint const& ep);
node_entry();
void update_rtt(int new_rtt);

View File

@ -56,7 +56,7 @@ struct put_data: traversal_algorithm
void set_data(item const& data) { m_data = data; }
void set_targets(std::vector<std::pair<node_entry, std::string> > const& targets);
void set_targets(std::vector<std::pair<node_entry, std::string>> const& targets);
protected:

View File

@ -33,16 +33,12 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef REFRESH_050324_HPP
#define REFRESH_050324_HPP
#include <libtorrent/kademlia/traversal_algorithm.hpp>
#include <libtorrent/kademlia/node_id.hpp>
#include <libtorrent/kademlia/get_peers.hpp>
namespace libtorrent { namespace dht
{
class routing_table;
class rpc_manager;
class bootstrap : public get_peers
{
public:

View File

@ -50,7 +50,6 @@ namespace libtorrent { struct dht_lookup; }
namespace libtorrent { namespace dht
{
class rpc_manager;
class node;
// this class may not be instantiated as a stack object

View File

@ -93,4 +93,3 @@ namespace libtorrent { namespace dht
}}
#endif // LIBTORRENT_TYPES_HPP

View File

@ -31,16 +31,8 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/close_reason.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/error.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/system/error_code.hpp>
#include <boost/asio/error.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent
{
@ -173,4 +165,3 @@ namespace libtorrent
return close_no_reason;
}
}

View File

@ -57,10 +57,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/hex.hpp> // to_hex
#endif
using libtorrent::dht::node;
using libtorrent::dht::node_id;
using libtorrent::dht::packet_t;
using libtorrent::dht::msg;
using libtorrent::detail::write_endpoint;
using namespace std::placeholders;
@ -149,9 +145,6 @@ namespace libtorrent { namespace dht
update_storage_node_ids();
}
// defined in node.cpp
void nop();
void dht_tracker::start(dht_state const& bootstrap
, find_data::nodes_callback const& f)
{

View File

@ -43,9 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace dht
{
using detail::read_endpoint_list;
using detail::read_v4_endpoint;
void get_peers_observer::reply(msg const& m)
{
bdecode_node r = m.message.dict_find_dict("r");
@ -91,12 +88,12 @@ void get_peers_observer::reply(msg const& m)
}
#endif
while (end - peers >= 6)
peer_list.push_back(read_v4_endpoint<tcp::endpoint>(peers));
peer_list.push_back(detail::read_v4_endpoint<tcp::endpoint>(peers));
}
else
{
// assume it's uTorrent/libtorrent format
peer_list = read_endpoint_list<tcp::endpoint>(n);
peer_list = detail::read_endpoint_list<tcp::endpoint>(n);
#ifndef TORRENT_DISABLE_LOGGING
auto logger = get_observer();
if (logger != nullptr && logger->should_log(dht_logger::traversal))

View File

@ -67,8 +67,6 @@ using namespace std::placeholders;
namespace libtorrent { namespace dht
{
using detail::write_endpoint;
namespace {
void nop() {}
@ -776,7 +774,7 @@ entry write_nodes_entry(std::vector<node_entry> const& nodes)
for (auto const& n : nodes)
{
std::copy(n.id.begin(), n.id.end(), out);
write_endpoint(udp::endpoint(n.addr(), n.port()), out);
detail::write_endpoint(udp::endpoint(n.addr(), n.port()), out);
}
return r;
}

View File

@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace dht
{
node_entry::node_entry(node_id const& id_, udp::endpoint ep
node_entry::node_entry(node_id const& id_, udp::endpoint const& ep
, int roundtriptime
, bool pinged)
: last_queried(pinged ? aux::time_now() : min_time())
@ -50,7 +50,7 @@ namespace libtorrent { namespace dht
#endif
}
node_entry::node_entry(udp::endpoint ep)
node_entry::node_entry(udp::endpoint const& ep)
: last_queried(min_time())
, id(nullptr)
, endpoint(ep)

View File

@ -62,8 +62,6 @@ using namespace std::placeholders;
namespace libtorrent { namespace dht
{
namespace io = libtorrent::detail;
// TODO: 3 move this into it's own .cpp file
dht_observer* observer::get_observer() const
{
@ -249,7 +247,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id)
if (transaction_id.empty()) return false;
auto ptr = transaction_id.begin();
int tid = transaction_id.size() != 2 ? -1 : io::read_uint16(ptr);
int tid = transaction_id.size() != 2 ? -1 : detail::read_uint16(ptr);
observer_ptr o;
auto range = m_transactions.equal_range(tid);
@ -451,7 +449,7 @@ bool rpc_manager::invoke(entry& e, udp::endpoint const& target_addr
transaction_id.resize(2);
char* out = &transaction_id[0];
int tid = random(0x7fff);
io::write_uint16(tid, out);
detail::write_uint16(tid, out);
e["t"] = transaction_id;
// When a DHT node enters the read-only state, in each outgoing query message,

View File

@ -50,11 +50,6 @@ using namespace std::placeholders;
namespace libtorrent { namespace dht
{
using detail::address_size;
using detail::read_v4_endpoint;
#if TORRENT_USE_IPV6
using detail::read_v6_endpoint;
#endif
#if TORRENT_USE_ASSERTS
template <class It, class Cmp>
@ -599,7 +594,7 @@ void traversal_observer::reply(msg const& m)
char const* nodes = n.string_ptr();
char const* end = nodes + n.string_length();
while (end - nodes >= 20 + address_size(protocol) + 2)
while (end - nodes >= 20 + detail::address_size(protocol) + 2)
{
node_id id;
std::copy(nodes, nodes + 20, id.begin());
@ -607,10 +602,10 @@ void traversal_observer::reply(msg const& m)
udp::endpoint ep;
#if TORRENT_USE_IPV6
if (protocol == udp::v6())
ep = read_v6_endpoint<udp::endpoint>(nodes);
ep = detail::read_v6_endpoint<udp::endpoint>(nodes);
else
#endif
ep = read_v4_endpoint<udp::endpoint>(nodes);
ep = detail::read_v4_endpoint<udp::endpoint>(nodes);
algorithm()->traverse(id, ep);
}
}