forked from premiere/premiere-libtorrent
small dht status cleanup
This commit is contained in:
parent
b3a17b1787
commit
2b4a49ea19
|
@ -52,6 +52,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <libtorrent/size_type.hpp>
|
#include <libtorrent/size_type.hpp>
|
||||||
#include <libtorrent/assert.hpp>
|
#include <libtorrent/assert.hpp>
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
struct session_status;
|
||||||
|
}
|
||||||
|
|
||||||
namespace libtorrent { namespace dht
|
namespace libtorrent { namespace dht
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -160,6 +165,8 @@ public:
|
||||||
routing_table(node_id const& id, int bucket_size
|
routing_table(node_id const& id, int bucket_size
|
||||||
, dht_settings const& settings);
|
, dht_settings const& settings);
|
||||||
|
|
||||||
|
void status(session_status& s) const;
|
||||||
|
|
||||||
void node_failed(node_id const& id);
|
void node_failed(node_id const& id);
|
||||||
|
|
||||||
// adds an endpoint that will never be added to
|
// adds an endpoint that will never be added to
|
||||||
|
|
|
@ -272,9 +272,6 @@ namespace libtorrent { namespace dht
|
||||||
void dht_tracker::dht_status(session_status& s)
|
void dht_tracker::dht_status(session_status& s)
|
||||||
{
|
{
|
||||||
mutex_t::scoped_lock l(m_mutex);
|
mutex_t::scoped_lock l(m_mutex);
|
||||||
boost::tie(s.dht_nodes, s.dht_node_cache) = m_dht.size();
|
|
||||||
s.dht_torrents = m_dht.data_size();
|
|
||||||
s.dht_global_nodes = m_dht.num_global_nodes();
|
|
||||||
m_dht.status(s);
|
m_dht.status(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -419,6 +419,9 @@ namespace
|
||||||
void node_impl::status(session_status& s)
|
void node_impl::status(session_status& s)
|
||||||
{
|
{
|
||||||
mutex_t::scoped_lock l(m_mutex);
|
mutex_t::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
|
m_table.status(s);
|
||||||
|
s.dht_torrents = int(m_map.size());
|
||||||
s.active_requests.clear();
|
s.active_requests.clear();
|
||||||
for (std::set<traversal_algorithm*>::iterator i = m_running_requests.begin()
|
for (std::set<traversal_algorithm*>::iterator i = m_running_requests.begin()
|
||||||
, end(m_running_requests.end()); i != end; ++i)
|
, end(m_running_requests.end()); i != end; ++i)
|
||||||
|
|
|
@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
#include "libtorrent/kademlia/routing_table.hpp"
|
#include "libtorrent/kademlia/routing_table.hpp"
|
||||||
|
#include "libtorrent/session_status.hpp"
|
||||||
#include "libtorrent/kademlia/node_id.hpp"
|
#include "libtorrent/kademlia/node_id.hpp"
|
||||||
#include "libtorrent/session_settings.hpp"
|
#include "libtorrent/session_settings.hpp"
|
||||||
|
|
||||||
|
@ -62,12 +63,18 @@ routing_table::routing_table(node_id const& id, int bucket_size
|
||||||
, m_lowest_active_bucket(160)
|
, m_lowest_active_bucket(160)
|
||||||
{
|
{
|
||||||
// distribute the refresh times for the buckets in an
|
// distribute the refresh times for the buckets in an
|
||||||
// attempt do even out the network load
|
// attempt to even out the network load
|
||||||
for (int i = 0; i < 160; ++i)
|
for (int i = 0; i < 160; ++i)
|
||||||
m_bucket_activity[i] = time_now() - milliseconds(i*5625);
|
m_bucket_activity[i] = time_now() - milliseconds(i*5625);
|
||||||
m_bucket_activity[0] = time_now() - minutes(15);
|
m_bucket_activity[0] = time_now() - minutes(15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void routing_table::status(session_status& s) const
|
||||||
|
{
|
||||||
|
boost::tie(s.dht_nodes, s.dht_node_cache) = size();
|
||||||
|
s.dht_global_nodes = num_global_nodes();
|
||||||
|
}
|
||||||
|
|
||||||
boost::tuple<int, int> routing_table::size() const
|
boost::tuple<int, int> routing_table::size() const
|
||||||
{
|
{
|
||||||
int nodes = 0;
|
int nodes = 0;
|
||||||
|
|
Loading…
Reference in New Issue