an approximate peer download rate is now in peer_info
This commit is contained in:
@@ -273,7 +273,7 @@ void print_peer_info(std::ostream& out, std::vector<libtorrent::peer_info> const
|
|||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
"country "
|
"country "
|
||||||
#endif
|
#endif
|
||||||
"client \n";
|
"peer-rate client \n";
|
||||||
|
|
||||||
for (std::vector<peer_info>::const_iterator i = peers.begin();
|
for (std::vector<peer_info>::const_iterator i = peers.begin();
|
||||||
i != peers.end(); ++i)
|
i != peers.end(); ++i)
|
||||||
@@ -300,6 +300,8 @@ void print_peer_info(std::ostream& out, std::vector<libtorrent::peer_info> const
|
|||||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||||
<< ((i->flags & peer_info::rc4_encrypted)?'E':
|
<< ((i->flags & peer_info::rc4_encrypted)?'E':
|
||||||
(i->flags & peer_info::plaintext_encrypted)?'e':'.')
|
(i->flags & peer_info::plaintext_encrypted)?'e':'.')
|
||||||
|
#else
|
||||||
|
<< " "
|
||||||
#endif
|
#endif
|
||||||
<< " "
|
<< " "
|
||||||
<< ((i->source & peer_info::tracker)?"T":"_")
|
<< ((i->source & peer_info::tracker)?"T":"_")
|
||||||
@@ -333,6 +335,8 @@ void print_peer_info(std::ostream& out, std::vector<libtorrent::peer_info> const
|
|||||||
out << " " << i->country[0] << i->country[1];
|
out << " " << i->country[0] << i->country[1];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
out << (i->remote_dl_rate > 0 ? add_suffix(i->remote_dl_rate) + "/s ": " ") << " ";
|
||||||
|
|
||||||
if (i->flags & peer_info::handshake)
|
if (i->flags & peer_info::handshake)
|
||||||
{
|
{
|
||||||
out << esc("31") << " waiting for handshake" << esc("0") << "\n";
|
out << esc("31") << " waiting for handshake" << esc("0") << "\n";
|
||||||
|
@@ -681,6 +681,15 @@ namespace libtorrent
|
|||||||
// so that it can be removed from the queue
|
// so that it can be removed from the queue
|
||||||
// once the connection completes
|
// once the connection completes
|
||||||
int m_connection_ticket;
|
int m_connection_ticket;
|
||||||
|
|
||||||
|
// bytes downloaded since last second
|
||||||
|
// timer timeout; used for determining
|
||||||
|
// approx download rate
|
||||||
|
int m_remote_bytes_dled;
|
||||||
|
|
||||||
|
// approximate peer download rate
|
||||||
|
int m_remote_dl_rate;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
public:
|
public:
|
||||||
bool m_in_constructor;
|
bool m_in_constructor;
|
||||||
|
@@ -141,6 +141,9 @@ namespace libtorrent
|
|||||||
web_seed = 1
|
web_seed = 1
|
||||||
};
|
};
|
||||||
int connection_type;
|
int connection_type;
|
||||||
|
|
||||||
|
// approximate peer download rate
|
||||||
|
int remote_dl_rate;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -128,6 +128,8 @@ namespace libtorrent
|
|||||||
, m_peer_info(peerinfo)
|
, m_peer_info(peerinfo)
|
||||||
, m_speed(slow)
|
, m_speed(slow)
|
||||||
, m_connection_ticket(-1)
|
, m_connection_ticket(-1)
|
||||||
|
, m_remote_bytes_dled(0)
|
||||||
|
, m_remote_dl_rate(0)
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
, m_in_constructor(true)
|
, m_in_constructor(true)
|
||||||
#endif
|
#endif
|
||||||
@@ -198,6 +200,8 @@ namespace libtorrent
|
|||||||
, m_download_limit(resource_request::inf)
|
, m_download_limit(resource_request::inf)
|
||||||
, m_peer_info(peerinfo)
|
, m_peer_info(peerinfo)
|
||||||
, m_speed(slow)
|
, m_speed(slow)
|
||||||
|
, m_remote_bytes_dled(0)
|
||||||
|
, m_remote_dl_rate(0)
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
, m_in_constructor(true)
|
, m_in_constructor(true)
|
||||||
#endif
|
#endif
|
||||||
@@ -744,6 +748,9 @@ namespace libtorrent
|
|||||||
t->get_policy().peer_is_interesting(*this);
|
t->get_policy().peer_is_interesting(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update bytes downloaded since last timer
|
||||||
|
m_remote_bytes_dled += t->torrent_file().piece_size(index);
|
||||||
|
|
||||||
if (is_seed())
|
if (is_seed())
|
||||||
{
|
{
|
||||||
assert(m_peer_info);
|
assert(m_peer_info);
|
||||||
@@ -1753,12 +1760,14 @@ namespace libtorrent
|
|||||||
p.failcount = peer_info_struct()->failcount;
|
p.failcount = peer_info_struct()->failcount;
|
||||||
p.num_hashfails = peer_info_struct()->hashfails;
|
p.num_hashfails = peer_info_struct()->hashfails;
|
||||||
p.flags |= peer_info_struct()->on_parole ? peer_info::on_parole : 0;
|
p.flags |= peer_info_struct()->on_parole ? peer_info::on_parole : 0;
|
||||||
|
p.remote_dl_rate = m_remote_dl_rate;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.source = 0;
|
p.source = 0;
|
||||||
p.failcount = 0;
|
p.failcount = 0;
|
||||||
p.num_hashfails = 0;
|
p.num_hashfails = 0;
|
||||||
|
p.remote_dl_rate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.send_buffer_size = send_buffer_size();
|
p.send_buffer_size = send_buffer_size();
|
||||||
@@ -1915,6 +1924,24 @@ namespace libtorrent
|
|||||||
, m_upload_limit));
|
, m_upload_limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// note the 1/60 multiplication here - this is per second of the
|
||||||
|
// minute; but since timers are not exact this makes this
|
||||||
|
// calculation REALLY approximate.
|
||||||
|
|
||||||
|
float factor = 0.6666666666667f;
|
||||||
|
|
||||||
|
if(m_remote_dl_rate == 0) {
|
||||||
|
factor = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_remote_dl_rate =
|
||||||
|
(m_remote_dl_rate * factor) +
|
||||||
|
((m_remote_bytes_dled * (1.0f-factor)) * (1.f/60.f));
|
||||||
|
|
||||||
|
m_remote_bytes_dled = 0;
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
fill_send_buffer();
|
fill_send_buffer();
|
||||||
/*
|
/*
|
||||||
size_type diff = share_diff();
|
size_type diff = share_diff();
|
||||||
|
Reference in New Issue
Block a user