void update_pieces_count_from_bitfield(peer_t peer, unsigned int bitfield)
{
for (int i = 0; i < FILE_PIECES; i++) {
- if ((bitfield & (1U << i))) {
+ if (bitfield & (1U << i)) {
peer->pieces_count[i]++;
}
}
xbt_dict_cursor_t cursor;
connection_t connection;
xbt_dict_foreach(peer->peers, cursor, key, connection) {
- int interested = 0;
if (connection->am_interested != 0) {
+ int interested = 0;
//Check if the peer still has a piece we want.
for (int i = 0; i < FILE_PIECES; i++) {
if (peer_has_not_piece(peer, i) && connection_has_piece(connection,i)) {
int partially_downloaded_piece(peer_t peer, connection_t remote_peer)
{
for (int i = 0; i < FILE_PIECES; i++) {
- if (peer_has_not_piece(peer, i) && connection_has_piece(remote_peer,i)&& peer_is_not_downloading_piece(peer, i)) {
- if (get_first_block(peer, i) > 0)
- return i;
- }
+ if (peer_has_not_piece(peer, i) && connection_has_piece(remote_peer, i) && peer_is_not_downloading_piece(peer, i) &&
+ get_first_block(peer, i) > 0)
+ return i;
}
return -1;
}