mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 20:44:50 +00:00
fix multiple router_node support lt rev 2089
This commit is contained in:
parent
f55fdcf118
commit
d2d0e26f4c
@ -54,6 +54,8 @@ bool compare_ref(node_id const& n1, node_id const& n2, node_id const& ref);
|
|||||||
// usefult for finding out which bucket a node belongs to
|
// usefult for finding out which bucket a node belongs to
|
||||||
int distance_exp(node_id const& n1, node_id const& n2);
|
int distance_exp(node_id const& n1, node_id const& n2);
|
||||||
|
|
||||||
|
node_id generate_id();
|
||||||
|
|
||||||
} } // namespace libtorrent::dht
|
} } // namespace libtorrent::dht
|
||||||
|
|
||||||
#endif // NODE_ID_HPP
|
#endif // NODE_ID_HPP
|
||||||
|
@ -150,7 +150,7 @@ traversal_algorithm::traversal_algorithm(
|
|||||||
for (routing_table::router_iterator i = table.router_begin()
|
for (routing_table::router_iterator i = table.router_begin()
|
||||||
, end(table.router_end()); i != end; ++i)
|
, end(table.router_end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
add_entry(node_id(0), *i, result::initial);
|
add_entry(generate_id(), *i, result::initial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,21 +72,6 @@ using asio::ip::udp;
|
|||||||
TORRENT_DEFINE_LOG(node)
|
TORRENT_DEFINE_LOG(node)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
node_id generate_id()
|
|
||||||
{
|
|
||||||
char random[20];
|
|
||||||
std::srand(std::time(0));
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
std::generate(random, random + 20, &rand);
|
|
||||||
#else
|
|
||||||
std::generate(random, random + 20, &std::rand);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
hasher h;
|
|
||||||
h.update(random, 20);
|
|
||||||
return h.final();
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove peers that have timed out
|
// remove peers that have timed out
|
||||||
void purge_peers(std::set<peer_entry>& peers)
|
void purge_peers(std::set<peer_entry>& peers)
|
||||||
{
|
{
|
||||||
|
@ -34,9 +34,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <ctime>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
#include "libtorrent/kademlia/node_id.hpp"
|
#include "libtorrent/kademlia/node_id.hpp"
|
||||||
|
#include "libtorrent/hasher.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
|
|
||||||
using boost::bind;
|
using boost::bind;
|
||||||
@ -95,5 +97,21 @@ int distance_exp(node_id const& n1, node_id const& n2)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct static_ { static_() { std::srand(std::time(0)); } } static__;
|
||||||
|
|
||||||
|
node_id generate_id()
|
||||||
|
{
|
||||||
|
char random[20];
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
std::generate(random, random + 20, &rand);
|
||||||
|
#else
|
||||||
|
std::generate(random, random + 20, &std::rand);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
hasher h;
|
||||||
|
h.update(random, 20);
|
||||||
|
return h.final();
|
||||||
|
}
|
||||||
|
|
||||||
} } // namespace libtorrent::dht
|
} } // namespace libtorrent::dht
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user