- update_bitfield_blocks(peer, message->index, message->block_index,
- message->block_length);
- if (piece_complete(peer, message->index)) {
- peer->pieces_requested--;
- //Removing the piece from our piece list
- unsigned i;
- int piece_index = -1, piece;
- xbt_dynar_foreach(peer->current_pieces, i, piece) {
- if (piece == message->index) {
- piece_index = i;
- break;
- }
- }
- xbt_assert(piece_index != -1, "Received an incorrect piece");
- xbt_dynar_remove_at(peer->current_pieces, piece_index, NULL);
- //Setting the fact that we have the piece
- peer->bitfield[message->index] = '1';
- peer->pieces++;
- XBT_DEBUG("My status is now %s", peer->bitfield);
- //Sending the information to all the peers we are connected to
- send_have(peer, message->index);
- //sending UNINTERSTED to peers that doesn't have what we want.
- update_interested_after_receive(peer);
- }
+ update_bitfield_blocks(peer, message->index, message->block_index,
+ message->block_length);
+ if (piece_complete(peer, message->index)) {
+ peer->pieces_requested--;
+ //Removing the piece from our piece list
+ unsigned i;
+ int piece_index = -1, piece;
+ xbt_dynar_foreach(peer->current_pieces, i, piece) {
+ if (piece == message->index) {
+ piece_index = i;
+ break;
+ }
+ }
+ xbt_assert(piece_index != -1, "Received an incorrect piece");
+ xbt_dynar_remove_at(peer->current_pieces, piece_index, NULL);
+ //Setting the fact that we have the piece
+ peer->bitfield[message->index] = '1';
+ peer->pieces++;
+ XBT_DEBUG("My status is now %s", peer->bitfield);
+ //Sending the information to all the peers we are connected to
+ send_have(peer, message->index);
+ //sending UNINTERSTED to peers that doesn't have what we want.
+ update_interested_after_receive(peer);
+ }