changed sequencial download threshold api, it is now per torrent

This commit is contained in:
Arvid Norberg 2006-09-04 23:22:21 +00:00
parent 191fd76b42
commit dc2e25141c
9 changed files with 119 additions and 19 deletions

View File

@ -473,6 +473,10 @@ struct session_status
size_type total_payload_upload;
int num_peers;
int dht_nodes;
int dht_cache_nodes;
int dht_torrents;
};
</pre>
<p><tt class="docutils literal"><span class="pre">has_incoming_connections</span></tt> is false as long as no incoming connections have been
@ -485,6 +489,14 @@ versions is the payload download only.</p>
uploaded to and from all torrents. <tt class="docutils literal"><span class="pre">total_payload_download</span></tt> and <tt class="docutils literal"><span class="pre">total_payload_upload</span></tt>
are the same thing but where only the payload is considered.</p>
<p><tt class="docutils literal"><span class="pre">num_peers</span></tt> is the total number of peer connections this session have.</p>
<p><tt class="docutils literal"><span class="pre">dht_nodes</span></tt>, <tt class="docutils literal"><span class="pre">dht_cache_nodes</span></tt> and <tt class="docutils literal"><span class="pre">dht_torrents</span></tt> are only available when
built with DHT support. They are all set to 0 if the DHT isn't running. When
the DHT is running, <tt class="docutils literal"><span class="pre">dht_nodes</span></tt> is set to the number of nodes in the routing
table. This number only includes <em>active</em> nodes, not cache nodes. The
<tt class="docutils literal"><span class="pre">dht_cache_nodes</span></tt> is set to the number of nodes in the node cache. These nodes
are used to replace the regular nodes in the routing table in case any of them
becomes unresponsive.</p>
<p><tt class="docutils literal"><span class="pre">dht_torrents</span></tt> are the number of torrents tracked by the DHT at the moment.</p>
</div>
<div class="section" id="is-listening-listen-port-listen-on">
<h2><a name="is-listening-listen-port-listen-on">is_listening() listen_port() listen_on()</a></h2>

View File

@ -334,6 +334,10 @@ struct has the following members::
size_type total_payload_upload;
int num_peers;
int dht_nodes;
int dht_cache_nodes;
int dht_torrents;
};
``has_incoming_connections`` is false as long as no incoming connections have been
@ -350,6 +354,16 @@ are the same thing but where only the payload is considered.
``num_peers`` is the total number of peer connections this session have.
``dht_nodes``, ``dht_cache_nodes`` and ``dht_torrents`` are only available when
built with DHT support. They are all set to 0 if the DHT isn't running. When
the DHT is running, ``dht_nodes`` is set to the number of nodes in the routing
table. This number only includes *active* nodes, not cache nodes. The
``dht_cache_nodes`` is set to the number of nodes in the node cache. These nodes
are used to replace the regular nodes in the routing table in case any of them
becomes unresponsive.
``dht_torrents`` are the number of torrents tracked by the DHT at the moment.
is_listening() listen_port() listen_on()
----------------------------------------

View File

@ -29,6 +29,7 @@ libtorrent/random_sample.hpp \
libtorrent/resource_request.hpp \
libtorrent/session.hpp \
libtorrent/session_settings.hpp \
libtorrent/session_status.hpp \
libtorrent/size_type.hpp \
libtorrent/socket.hpp \
libtorrent/stat.hpp \

View File

@ -51,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/kademlia/traversal_algorithm.hpp"
#include "libtorrent/kademlia/packet_iterator.hpp"
#include "libtorrent/session_settings.hpp"
#include "libtorrent/session_status.hpp"
namespace libtorrent { namespace dht
{
@ -75,6 +76,8 @@ namespace libtorrent { namespace dht
, boost::function<void(std::vector<tcp::endpoint> const&
, sha1_hash const&)> f);
void dht_status(session_status& s);
private:
void on_name_lookup(asio::error const& e

View File

@ -118,6 +118,7 @@ public:
data_iterator begin_data() { return m_map.begin(); }
data_iterator end_data() { return m_map.end(); }
int data_size() const { return int(m_map.size()); }
void print_state(std::ostream& os) const
{ m_table.print_state(os); }

View File

@ -73,6 +73,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session_settings.hpp"
#include "libtorrent/version.hpp"
#include "libtorrent/kademlia/dht_tracker.hpp"
#include "libtorrent/session_status.hpp"
#if !defined(NDEBUG) && defined(_MSC_VER)
# include <float.h>
@ -326,25 +327,6 @@ namespace libtorrent
};
}
struct TORRENT_EXPORT session_status
{
bool has_incoming_connections;
float upload_rate;
float download_rate;
float payload_upload_rate;
float payload_download_rate;
size_type total_download;
size_type total_upload;
size_type total_payload_download;
size_type total_payload_upload;
int num_peers;
};
class TORRENT_EXPORT session: public boost::noncopyable, detail::eh_initializer
{
public:

View File

@ -0,0 +1,68 @@
/*
Copyright (c) 2006, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_SESSION_STATUS_HPP_INCLUDED
#define TORRENT_SESSION_STATUS_HPP_INCLUDED
namespace libtorrent
{
struct TORRENT_EXPORT session_status
{
bool has_incoming_connections;
float upload_rate;
float download_rate;
float payload_upload_rate;
float payload_download_rate;
size_type total_download;
size_type total_upload;
size_type total_payload_download;
size_type total_payload_upload;
int num_peers;
#ifndef TORRENT_DISABLE_DHT
int m_dht_nodes;
int m_dht_node_cache;
int m_dht_torrents;
#endif
};
}
#endif // TORRENT_SESSION_STATUS_HPP_INCLUDED

View File

@ -196,6 +196,12 @@ namespace libtorrent { namespace dht
m_refresh_timer.async_wait(bind(&dht_tracker::refresh_timeout, this, _1));
}
void dht_tracker::dht_status(session_status& s)
{
boost::tie(s.m_dht_nodes, s.m_dht_node_cache) = m_dht.size();
s.m_dht_torrents = m_dht.data_size();
}
void dht_tracker::connection_timeout(asio::error const& e)
try
{

View File

@ -1464,6 +1464,19 @@ namespace libtorrent
s.total_payload_download = m_impl.m_stat.total_payload_download();
s.total_payload_upload = m_impl.m_stat.total_payload_upload();
#ifndef TORRENT_DISABLE_DHT
if (m_impl.m_dht)
{
m_impl.m_dht->dht_status(s);
}
else
{
s.m_dht_nodes = 0;
s.m_dht_node_cache = 0;
s.m_dht_torrents = 0;
}
#endif
return s;
}