diff --git a/libtorrent/include/libtorrent/kademlia/node.hpp b/libtorrent/include/libtorrent/kademlia/node.hpp index 9d2af75d..757d38dc 100644 --- a/libtorrent/include/libtorrent/kademlia/node.hpp +++ b/libtorrent/include/libtorrent/kademlia/node.hpp @@ -247,7 +247,9 @@ public: void putData(std::string const &username, std::string const &resource, bool multi, entry const &value, std::string const &sig_user, - int timeutc, int seq, + int timeutc, int seq); + + void getData(std::string const &username, std::string const &resource, bool multi, boost::function f); bool verify_token(std::string const& token, char const* info_hash diff --git a/libtorrent/src/kademlia/node.cpp b/libtorrent/src/kademlia/node.cpp index c41f7340..1b71af87 100644 --- a/libtorrent/src/kademlia/node.cpp +++ b/libtorrent/src/kademlia/node.cpp @@ -403,21 +403,34 @@ void node_impl::announce(sha1_hash const& info_hash, int listen_port, bool seed void node_impl::putData(std::string const &username, std::string const &resource, bool multi, entry const &value, std::string const &sig_user, - int timeutc, int seq, - boost::function f) + int timeutc, int seq) { #ifdef TORRENT_DHT_VERBOSE_LOGGING TORRENT_LOG(node) << "putData [ username: " << info_hash << " res: " << resource << " ]" ; #endif // search for nodes with ids close to id or with peers - // for info-hash id. then send announce_peer to them. - boost::intrusive_ptr ta(new dht_get(*this, username, resource, multi, f, + // for info-hash id. then send putData to them. + boost::intrusive_ptr ta(new dht_get(*this, username, resource, multi, + boost::bind(&nop), boost::bind(&putData_fun, _1, boost::ref(*this), username, resource, multi, value, sig_user, timeutc, seq), true)); ta->start(); } +void node_impl::getData(std::string const &username, std::string const &resource, bool multi, + boost::function f) +{ +#ifdef TORRENT_DHT_VERBOSE_LOGGING + TORRENT_LOG(node) << "getData [ username: " << info_hash << " res: " << resource << " ]" ; +#endif + // search for nodes with ids close to id or with peers + // for info-hash id. callback is used to return data. + boost::intrusive_ptr ta(new dht_get(*this, username, resource, multi, f, + boost::bind(&nop), false)); + ta->start(); +} + void node_impl::tick() { node_id target;