*** empty log message ***

This commit is contained in:
Magnus Jonsson 2004-02-25 13:18:41 +00:00
parent 6d614bc6d3
commit 7af8beff02
5 changed files with 24 additions and 19 deletions

View File

@ -170,6 +170,9 @@ namespace libtorrent
peer* find_unchoke_candidate();
void connect_peer(peer *);
bool connect_one_peer();
bool disconnect_one_peer();
peer* find_disconnect_candidate();

View File

@ -208,7 +208,7 @@ namespace libtorrent
int toGive = 1+std::min(max_give-1,r->used);
resources_to_distribute-=give(r,toGive);
}
#elif 1
#elif 0
size_type total_used=0;
size_type max_used=0;
for(int i = 0;i < (int)requests.size();++i)
@ -288,13 +288,13 @@ namespace libtorrent
kNumer=1;
kDenom=max_used;
}
/*
if(kNumer > kDenom)
{
kNumer=1;
kDenom=1;
}
*/
for(int i = 0;i < (int)requests.size() && resources_to_distribute;++i)
{
resource_request *r=requests[i];

View File

@ -1232,7 +1232,7 @@ namespace libtorrent
// client has sent us. This is the mean to
// maintain the share ratio given by m_ratio
// with all peers.
/*
if (m_torrent->is_seed() || is_choked() || m_torrent->ratio()==0.0f)
{
// if we have downloaded more than one piece more
@ -1241,19 +1241,19 @@ namespace libtorrent
if(!m_send_buffer.empty() || (!m_requests.empty() && !is_choked()))
upload_bandwidth.wanted = std::numeric_limits<int>::max();
else
upload_bandwidth.wanted = 0;
upload_bandwidth.wanted = 1;
}
else
{
double bias = 0x20000 + m_free_upload;
double break_even_time = 10;
double break_even_time = 5;
double have_uploaded = (double)m_statistics.total_payload_upload();
double have_downloaded = (double)m_statistics.total_payload_download();
double download_speed = m_statistics.download_rate();
double soon_downloaded =
have_downloaded+download_speed * 2 * break_even_time;
have_downloaded+download_speed * 1.5 * break_even_time;
double upload_speed_limit = (soon_downloaded*m_torrent->ratio()
- have_uploaded + bias) / break_even_time;
@ -1263,8 +1263,8 @@ namespace libtorrent
upload_bandwidth.wanted = (int) upload_speed_limit;
}
*/
/*
size_type diff = share_diff();
enum { block_limit = 2 }; // how many blocks difference is considered unfair
@ -1300,7 +1300,6 @@ namespace libtorrent
// the maximum send_quota given our download rate from this peer
if (upload_bandwidth.wanted < 256) upload_bandwidth.wanted = 256;
}
*/
}
// --------------------------

View File

@ -779,9 +779,7 @@ namespace libtorrent
if(m_torrent->num_peers() < m_max_connections)
{
i->connection = &m_torrent->connect_to_peer(remote);
i->connected = boost::posix_time::second_clock::local_time();
m_last_optimistic_disconnect=boost::posix_time::second_clock::local_time();
connect_peer(&*i);
}
return;
}
@ -911,12 +909,19 @@ namespace libtorrent
assert(!p->connection);
assert(p->type==peer::connectable);
connect_peer(p);
return true;
}
void policy::connect_peer(peer *p)
{
p->connection = &m_torrent->connect_to_peer(p->id);
p->connection->add_stat(p->prev_amount_download, p->prev_amount_upload);
p->prev_amount_download = 0;
p->prev_amount_upload = 0;
p->connected = boost::posix_time::second_clock::local_time();
return true;
p->connected =
m_last_optimistic_disconnect =
boost::posix_time::second_clock::local_time();
}
bool policy::disconnect_one_peer()
@ -940,8 +945,6 @@ namespace libtorrent
assert(i->connection == &c);
i->connected = boost::posix_time::second_clock::local_time();
i->prev_amount_download += c.statistics().total_payload_download();
i->prev_amount_upload += c.statistics().total_payload_upload();
if (!i->connection->is_choked() && !m_torrent->is_aborted())
{
--m_num_unchoked;
@ -956,6 +959,8 @@ namespace libtorrent
assert(i->connection->share_diff() < std::numeric_limits<int>::max());
m_available_free_upload += i->connection->share_diff();
}
i->prev_amount_download += c.statistics().total_payload_download();
i->prev_amount_upload += c.statistics().total_payload_upload();
i->connection = 0;
}

View File

@ -454,8 +454,6 @@ namespace libtorrent
p.id = peer->get_peer_id();
p.ip = peer->get_socket()->sender();
// TODO: add the prev_amount_downloaded and prev_amount_uploaded
// from the peer list in the policy
p.total_download = statistics.total_payload_download();
p.total_upload = statistics.total_payload_upload();