more DHT fixes
This commit is contained in:
parent
31d8c7d9b7
commit
5ee6266e93
|
@ -184,7 +184,7 @@ bool routing_table::need_refresh(node_id& target) const
|
||||||
ptime now = time_now();
|
ptime now = time_now();
|
||||||
|
|
||||||
// refresh our own bucket once every 15 minutes
|
// refresh our own bucket once every 15 minutes
|
||||||
if (now - m_last_self_refresh < minutes(15))
|
if (now - m_last_self_refresh > minutes(15))
|
||||||
{
|
{
|
||||||
m_last_self_refresh = now;
|
m_last_self_refresh = now;
|
||||||
target = m_id;
|
target = m_id;
|
||||||
|
@ -272,11 +272,6 @@ bool routing_table::add_node(node_entry const& e)
|
||||||
bucket_t& b = i->live_nodes;
|
bucket_t& b = i->live_nodes;
|
||||||
bucket_t& rb = i->replacements;
|
bucket_t& rb = i->replacements;
|
||||||
|
|
||||||
// if the replacement cache is full, we don't
|
|
||||||
// need another node. The table is fine the
|
|
||||||
// way it is.
|
|
||||||
if ((int)rb.size() >= m_bucket_size) return ret;
|
|
||||||
|
|
||||||
// if the node already exists, we don't need it
|
// if the node already exists, we don't need it
|
||||||
bucket_t::iterator j = std::find_if(b.begin(), b.end()
|
bucket_t::iterator j = std::find_if(b.begin(), b.end()
|
||||||
, boost::bind(&node_entry::id, _1) == e.id);
|
, boost::bind(&node_entry::id, _1) == e.id);
|
||||||
|
|
|
@ -973,7 +973,6 @@ namespace aux {
|
||||||
{
|
{
|
||||||
m_dht_state = *settings;
|
m_dht_state = *settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
|
@ -4350,6 +4349,9 @@ namespace aux {
|
||||||
if (is_loopback(ip)) return;
|
if (is_loopback(ip)) return;
|
||||||
if (m_external_address == ip) return;
|
if (m_external_address == ip) return;
|
||||||
|
|
||||||
|
// for now, just trust whoever tells us our external address first
|
||||||
|
if (m_external_address != address()) return;
|
||||||
|
|
||||||
m_external_address = ip;
|
m_external_address = ip;
|
||||||
if (m_alerts.should_post<external_ip_alert>())
|
if (m_alerts.should_post<external_ip_alert>())
|
||||||
m_alerts.post_alert(external_ip_alert(ip));
|
m_alerts.post_alert(external_ip_alert(ip));
|
||||||
|
@ -4357,7 +4359,18 @@ namespace aux {
|
||||||
// since we have a new external IP now, we need to
|
// since we have a new external IP now, we need to
|
||||||
// restart the DHT with a new node ID
|
// restart the DHT with a new node ID
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
start_dht(m_dht_state);
|
if (m_dht)
|
||||||
|
{
|
||||||
|
entry s = m_dht->state();
|
||||||
|
int cur_state = 0;
|
||||||
|
int prev_state = 0;
|
||||||
|
entry* nodes1 = s.find_key("nodes");
|
||||||
|
if (nodes1 && nodes1->type() == entry::list_t) cur_state = nodes1->list().size();
|
||||||
|
entry* nodes2 = m_dht_state.find_key("nodes");
|
||||||
|
if (nodes2 && nodes2->type() == entry::list_t) prev_state = nodes2->list().size();
|
||||||
|
if (cur_state > prev_state) m_dht_state = s;
|
||||||
|
start_dht(m_dht_state);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue