small dht status cleanup

This commit is contained in:
Arvid Norberg 2009-01-23 10:36:07 +00:00
parent b3a17b1787
commit 2b4a49ea19
4 changed files with 18 additions and 4 deletions

View File

@ -52,6 +52,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/size_type.hpp>
#include <libtorrent/assert.hpp>
namespace libtorrent
{
struct session_status;
}
namespace libtorrent { namespace dht
{
@ -160,6 +165,8 @@ public:
routing_table(node_id const& id, int bucket_size
, dht_settings const& settings);
void status(session_status& s) const;
void node_failed(node_id const& id);
// adds an endpoint that will never be added to

View File

@ -272,9 +272,6 @@ namespace libtorrent { namespace dht
void dht_tracker::dht_status(session_status& s)
{
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);
}

View File

@ -419,6 +419,9 @@ namespace
void node_impl::status(session_status& s)
{
mutex_t::scoped_lock l(m_mutex);
m_table.status(s);
s.dht_torrents = int(m_map.size());
s.active_requests.clear();
for (std::set<traversal_algorithm*>::iterator i = m_running_requests.begin()
, end(m_running_requests.end()); i != end; ++i)

View File

@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#include "libtorrent/kademlia/routing_table.hpp"
#include "libtorrent/session_status.hpp"
#include "libtorrent/kademlia/node_id.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)
{
// 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)
m_bucket_activity[i] = time_now() - milliseconds(i*5625);
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
{
int nodes = 0;