*** empty log message ***

This commit is contained in:
Magnus Jonsson 2004-01-14 11:46:26 +00:00
parent 5b242a6464
commit 5068562916
6 changed files with 34 additions and 19 deletions

View File

@ -219,8 +219,8 @@ int main(int argc, char* argv[])
std::vector<torrent_handle> handles; std::vector<torrent_handle> handles;
session ses(6881); session ses(6881);
// limit global upload rate to 30 kB/s // // limit global upload rate to 30 kB/s
ses.set_upload_rate_limit(30 * 1024); // ses.set_upload_rate_limit(30 * 1024);
ses.set_http_settings(settings); ses.set_http_settings(settings);
ses.set_severity_level(alert::debug); ses.set_severity_level(alert::debug);
@ -249,8 +249,8 @@ int main(int argc, char* argv[])
{} {}
handles.push_back(ses.add_torrent(t, save_path, resume_data)); handles.push_back(ses.add_torrent(t, save_path, resume_data));
handles.back().set_max_uploads(7); handles.back().set_max_uploads(-1);
handles.back().set_ratio(1); handles.back().set_ratio(1.02);
} }
catch (std::exception& e) catch (std::exception& e)
{ {
@ -357,8 +357,11 @@ int main(int argc, char* argv[])
<< "(" << add_suffix(i->total_download) << ") " << "(" << add_suffix(i->total_download) << ") "
<< "u: " << add_suffix(i->up_speed) << "/s " << "u: " << add_suffix(i->up_speed) << "/s "
<< "(" << add_suffix(i->total_upload) << ") " << "(" << add_suffix(i->total_upload) << ") "
<< "ul:" << add_suffix(i->upload_limit) << "/s "
// << "uc:" << add_suffix(i->upload_ceiling) << "/s "
// << "df: " << ratio(i->total_download, i->total_upload) << " " // << "df: " << ratio(i->total_download, i->total_upload) << " "
<< "q: " << i->download_queue_length << " " // << "q: " << i->download_queue_length << " "
<< "r: " << i->upload_queue_length << " "
<< "f: " << "f: "
<< static_cast<const char*>((i->flags & peer_info::interesting)?"I":"_") << static_cast<const char*>((i->flags & peer_info::interesting)?"I":"_")
<< static_cast<const char*>((i->flags & peer_info::choked)?"C":"_") << static_cast<const char*>((i->flags & peer_info::choked)?"C":"_")
@ -367,7 +370,7 @@ int main(int argc, char* argv[])
<< static_cast<const char*>((i->flags & peer_info::supports_extensions)?"e":"_") << static_cast<const char*>((i->flags & peer_info::supports_extensions)?"e":"_")
<< static_cast<const char*>((i->flags & peer_info::local_connection)?"l":"r") << static_cast<const char*>((i->flags & peer_info::local_connection)?"l":"r")
<< "\n"; << "\n";
/*
if (i->downloading_piece_index >= 0) if (i->downloading_piece_index >= 0)
{ {
out << i->downloading_piece_index << ";" out << i->downloading_piece_index << ";"
@ -383,8 +386,9 @@ int main(int argc, char* argv[])
} }
out << "\n"; out << "\n";
} }
*/
} }
/*
out << "___________________________________\n"; out << "___________________________________\n";
i->get_download_queue(queue); i->get_download_queue(queue);
@ -405,19 +409,20 @@ int main(int argc, char* argv[])
} }
out << "___________________________________\n"; out << "___________________________________\n";
*/
} }
/*
for (std::deque<std::string>::iterator i = events.begin(); for (std::deque<std::string>::iterator i = events.begin();
i != events.end(); i != events.end();
++i) ++i)
{ {
out << *i << "\n"; out << *i << "\n";
} }
*/
clear(); clear();
set_cursor(0, 0); set_cursor(0, 0);
std::cout << out.str(); std::cout << out.str();
std::cout.flush();
} }
} }
catch (std::exception& e) catch (std::exception& e)

View File

@ -244,6 +244,8 @@ namespace libtorrent
const std::deque<piece_block>& download_queue() const const std::deque<piece_block>& download_queue() const
{ return m_download_queue; } { return m_download_queue; }
const std::deque<peer_request>& upload_queue() const
{ return m_requests; }
// returns the block currently being // returns the block currently being
// downloaded. And the progress of that // downloaded. And the progress of that

View File

@ -69,6 +69,11 @@ namespace libtorrent
// for yet // for yet
int download_queue_length; int download_queue_length;
// this is the number of requests
// the peer has sent to us
// that we haven't sent yet
int upload_queue_length;
// the currently downloading piece // the currently downloading piece
// if piece index is -1 all associated // if piece index is -1 all associated
// members are just set to 0 // members are just set to 0

View File

@ -1143,7 +1143,9 @@ namespace libtorrent
int diff = share_diff(); int diff = share_diff();
if (diff > 2*m_torrent->block_size() || m_torrent->is_seed()) enum { blockLimit=2 }; // how many blocks difference is considered unfair
if (diff > blockLimit*m_torrent->block_size() || m_torrent->is_seed())
{ {
// if we have downloaded more than one piece more // if we have downloaded more than one piece more
// than we have uploaded OR if we are a seed // than we have uploaded OR if we are a seed
@ -1158,7 +1160,7 @@ namespace libtorrent
// if we have uploaded too much, send with a rate of // if we have uploaded too much, send with a rate of
// 10 kB/s less than we receive // 10 kB/s less than we receive
int bias = 0; int bias = 0;
if (diff > -2*m_torrent->block_size()) if (diff > -blockLimit*m_torrent->block_size())
{ {
bias = static_cast<int>(m_statistics.download_rate() * ratio) / 2; bias = static_cast<int>(m_statistics.download_rate() * ratio) / 2;
if (bias < 10*1024) bias = 10*1024; if (bias < 10*1024) bias = 10*1024;

View File

@ -302,8 +302,9 @@ namespace libtorrent
if (!c->is_peer_interested()) if (!c->is_peer_interested())
return &(*i); return &(*i);
int diff = i->total_download() // int diff = i->total_download()
- i->total_upload(); // - i->total_upload();
int diff = c->share_diff();
int weight = static_cast<int>(c->statistics().download_rate() * 10.f) int weight = static_cast<int>(c->statistics().download_rate() * 10.f)
+ diff + diff
@ -448,18 +449,17 @@ namespace libtorrent
peer_connection* c = i->connection; peer_connection* c = i->connection;
if (c == 0) continue; if (c == 0) continue;
int downloaded = i->total_download(); int diff=c->share_diff();
int uploaded = i->total_upload();
if (downloaded - uploaded < -free_upload_amount if (diff <= -free_upload_amount
&& !c->is_choked()) && !c->is_choked())
{ {
// if we have uploaded more than a piece for free, choke peer and // if we have uploaded more than a piece for free, choke peer and
// wait until we catch up with our download. // wait until we catch up with our download.
c->send_choke(); c->send_choke();
} }
else if (downloaded - uploaded > -free_upload_amount else if (diff > -free_upload_amount
&& c->is_choked() && c->is_peer_interested()) && c->is_choked() /* && c->is_peer_interested()*/)
{ {
// we have catched up. We have now shared the same amount // we have catched up. We have now shared the same amount
// to eachother. Unchoke this peer. // to eachother. Unchoke this peer.

View File

@ -390,6 +390,7 @@ namespace libtorrent
p.load_balancing = peer->total_free_upload(); p.load_balancing = peer->total_free_upload();
p.download_queue_length = peer->download_queue().size(); p.download_queue_length = peer->download_queue().size();
p.upload_queue_length = peer->upload_queue().size();
boost::optional<piece_block_progress> ret = peer->downloading_piece(); boost::optional<piece_block_progress> ret = peer->downloading_piece();
if (ret) if (ret)