*** empty log message ***

This commit is contained in:
Arvid Norberg 2003-12-17 03:40:13 +00:00
parent f32c3ce918
commit 029e185a1e
7 changed files with 43 additions and 9 deletions

View File

@ -282,7 +282,7 @@ int main(int argc, char* argv[])
<< "u: " << add_suffix(i->up_speed) << "/s "
<< "(" << add_suffix(i->total_upload) << ") "
// << "df: " << add_suffix((int)i->total_download - (int)i->total_upload) << " "
<< "b: " << add_suffix(i->load_balancing) << "/s "
<< "b: " << add_suffix(i->load_balancing) << " "
<< "f: "
<< static_cast<const char*>((i->flags & peer_info::interesting)?"I":"_")
<< static_cast<const char*>((i->flags & peer_info::choked)?"C":"_")

View File

@ -56,7 +56,7 @@ int main(int argc, char* argv[])
try
{
session s(6881, "E\x1");
session s(6881);
std::ifstream in(argv[1], std::ios_base::binary);
in.unsetf(std::ios_base::skipws);

View File

@ -61,10 +61,10 @@ namespace libtorrent
{
std::stringstream s;
s << "-" << id[0] << id[1]
<< major_version
<< minor_version
<< revision_version
<< tag_version << "-";
<< (int)major_version
<< (int)minor_version
<< (int)revision_version
<< (int)tag_version << "-";
return s.str();
}

View File

@ -192,6 +192,9 @@ namespace libtorrent
bool have_piece(unsigned int index) const
{ return m_have_pieces[index]; }
const std::vector<bool>& pieces() const
{ return m_have_pieces; }
// when we get a have- or bitfield- messages, this is called for every
// piece a peer has gained.
// returns true if this piece is interesting (i.e. if we would like to download it)

View File

@ -377,7 +377,7 @@ bool libtorrent::peer_connection::dispatch_message(int received)
else
{
m_have_piece[index] = true;
if (m_torrent->peer_has(index))
if (!m_torrent->peer_has(index) && !is_interesting())
m_torrent->get_policy().peer_is_interesting(*this);
}
break;

View File

@ -507,14 +507,45 @@ namespace libtorrent
void policy::piece_finished(int index, bool successfully_verified)
{
if (successfully_verified)
{
// have all peers update their interested-flag
for (std::vector<peer>::iterator i = m_peers.begin();
i != m_peers.end();
++i)
{
if (i->connection == 0) continue;
// if we're not interested, we will not become interested
if (!i->connection->is_interesting()) continue;
bool interested = false;
const std::vector<bool>& peer_has = i->connection->get_bitfield();
const std::vector<bool>& we_have = m_torrent->pieces();
assert(we_have.size() == peer_has.size());
for (int j = 0; j != we_have.size(); ++j)
{
if (!we_have[j] && peer_has[j])
{
interested = true;
break;
}
}
if (!interested)
i->connection->not_interested();
}
}
// TODO: if verification failed, mark the peers that were involved
// in some way
}
// TODO: we must be able to get interested
// in a peer again, if a piece fails that
// this peer has.
void policy::block_finished(peer_connection& c, piece_block b)
{
// if the peer hasn't choked us, ask for another piece
if (!c.has_peer_choked()) request_a_block(*m_torrent, c);
if (!c.has_peer_choked())
request_a_block(*m_torrent, c);
}
// this is called when we are unchoked by a peer

View File

@ -76,7 +76,7 @@ namespace
int quota_limit; // bandwidth limit
int estimated_upload_capacity; // estimated channel bandwidth
bool operator < (connection_info &other) const
bool operator < (const connection_info &other) const
{
return estimated_upload_capacity < other.estimated_upload_capacity;
}