added feature to not count downloaded bytes from web seeds in stats

This commit is contained in:
Arvid Norberg 2010-07-15 06:27:44 +00:00
parent 89ca5a157a
commit 4c6be42b74
8 changed files with 39 additions and 2 deletions

View File

@ -1,3 +1,4 @@
* added feature to not count downloaded bytes from web seeds in stats
* added alert for incoming local service discovery messages * added alert for incoming local service discovery messages
* added option to set file priorities when adding torrents * added option to set file priorities when adding torrents
* removed the session mutex for improved performance * removed the session mutex for improved performance

View File

@ -245,6 +245,9 @@ namespace libtorrent
bool no_download() const { return m_no_download; } bool no_download() const { return m_no_download; }
void no_download(bool b) { m_no_download = b; } void no_download(bool b) { m_no_download = b; }
bool ignore_stats() const { return m_ignore_stats; }
void ignore_stats(bool b) { m_ignore_stats = b; }
void set_priority(int p) void set_priority(int p)
{ {
TORRENT_ASSERT(p > 0); TORRENT_ASSERT(p > 0);
@ -1055,6 +1058,10 @@ namespace libtorrent
// set to true when we've sent the first round of suggests // set to true when we've sent the first round of suggests
bool m_sent_suggests:1; bool m_sent_suggests:1;
// when this is set, the transfer stats for this connection
// is not included in the torrent or session stats
bool m_ignore_stats:1;
template <std::size_t Size> template <std::size_t Size>
struct handler_storage struct handler_storage
{ {

View File

@ -216,6 +216,7 @@ namespace libtorrent
, ignore_resume_timestamps(false) , ignore_resume_timestamps(false)
, anonymous_mode(false) , anonymous_mode(false)
, tick_interval(100) , tick_interval(100)
, report_web_seed_downloads(true)
{} {}
// libtorrent version. Used for forward binary compatibility // libtorrent version. Used for forward binary compatibility
@ -834,6 +835,10 @@ namespace libtorrent
// the number of milliseconds between internal ticks. Should be no // the number of milliseconds between internal ticks. Should be no
// more than one second (i.e. 1000). // more than one second (i.e. 1000).
int tick_interval; int tick_interval;
// specifies whether downloads from web seeds is reported to the
// tracker or not. Defaults to on
bool report_web_seed_downloads;
}; };
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT

View File

@ -69,6 +69,9 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
if (!ses.settings().report_web_seed_downloads)
ignore_stats(true);
// we want large blocks as well, so // we want large blocks as well, so
// we can request more bytes at once // we can request more bytes at once
request_large_blocks(true); request_large_blocks(true);

View File

@ -148,6 +148,7 @@ namespace libtorrent
, m_bitfield_received(false) , m_bitfield_received(false)
, m_no_download(false) , m_no_download(false)
, m_sent_suggests(false) , m_sent_suggests(false)
, m_ignore_stats(false)
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
, m_in_constructor(true) , m_in_constructor(true)
, m_disconnect_started(false) , m_disconnect_started(false)
@ -283,6 +284,7 @@ namespace libtorrent
, m_bitfield_received(false) , m_bitfield_received(false)
, m_no_download(false) , m_no_download(false)
, m_sent_suggests(false) , m_sent_suggests(false)
, m_ignore_stats(false)
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
, m_in_constructor(true) , m_in_constructor(true)
, m_disconnect_started(false) , m_disconnect_started(false)
@ -3237,7 +3239,7 @@ namespace libtorrent
if (t) if (t)
{ {
// make sure we keep all the stats! // make sure we keep all the stats!
t->add_stats(statistics()); if (!m_ignore_stats) t->add_stats(statistics());
if (t->has_picker()) if (t->has_picker())
{ {

View File

@ -1253,6 +1253,19 @@ namespace aux {
// if anonymous mode was enabled, clear out the peer ID // if anonymous mode was enabled, clear out the peer ID
bool anonymous = (m_settings.anonymous_mode != s.anonymous_mode && s.anonymous_mode); bool anonymous = (m_settings.anonymous_mode != s.anonymous_mode && s.anonymous_mode);
if (m_settings.report_web_seed_downloads != s.report_web_seed_downloads)
{
// if this flag changed, update all web seed connections
for (connection_map::iterator i = m_connections.begin()
, end(m_connections.end()); i != end; ++i)
{
int type = (*i)->type();
if (type == peer_connection::url_seed_connection
|| type == peer_connection::http_seed_connection)
(*i)->ignore_stats(!s.report_web_seed_downloads);
}
}
m_settings = s; m_settings = s;
// enable anonymous mode. We don't want to accept any incoming // enable anonymous mode. We don't want to accept any incoming

View File

@ -5770,7 +5770,10 @@ namespace libtorrent
{ {
peer_connection* p = *i; peer_connection* p = *i;
++i; ++i;
if (!p->ignore_stats())
m_stat += p->statistics(); m_stat += p->statistics();
// updates the peer connection's ul/dl bandwidth // updates the peer connection's ul/dl bandwidth
// resource requests // resource requests
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS

View File

@ -70,6 +70,9 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
if (!ses.settings().report_web_seed_downloads)
ignore_stats(true);
// we want large blocks as well, so // we want large blocks as well, so
// we can request more bytes at once // we can request more bytes at once
request_large_blocks(true); request_large_blocks(true);