00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef FIND_DATA_050323_HPP
00034 #define FIND_DATA_050323_HPP
00035
00036 #include <vector>
00037
00038 #include <libtorrent/kademlia/traversal_algorithm.hpp>
00039 #include <libtorrent/kademlia/node_id.hpp>
00040 #include <libtorrent/kademlia/routing_table.hpp>
00041 #include <libtorrent/kademlia/rpc_manager.hpp>
00042 #include <libtorrent/kademlia/packet_iterator.hpp>
00043 #include <boost/optional.hpp>
00044
00045 #include <boost/function.hpp>
00046
00047 namespace libtorrent { namespace dht
00048 {
00049
00050 using asio::ip::udp;
00051
00052 typedef std::vector<char> packet_t;
00053
00054 class rpc_manager;
00055
00056
00057
00058 class find_data : public traversal_algorithm
00059 {
00060 public:
00061 typedef boost::function<void(msg const*)> done_callback;
00062
00063 static void initiate(
00064 node_id target
00065 , int branch_factor
00066 , int max_results
00067 , routing_table& table
00068 , rpc_manager& rpc
00069 , done_callback const& callback
00070 );
00071
00072 void got_data(msg const* m);
00073
00074 private:
00075 void done();
00076 void invoke(node_id const& id, udp::endpoint addr);
00077
00078 find_data(
00079 node_id target
00080 , int branch_factor
00081 , int max_results
00082 , routing_table& table
00083 , rpc_manager& rpc
00084 , done_callback const& callback
00085 );
00086
00087 done_callback m_done_callback;
00088 boost::shared_ptr<packet_t> m_packet;
00089 bool m_done;
00090 };
00091
00092 } }
00093
00094 #endif // FIND_DATA_050323_HPP
00095