XBT_DEBUG("Got %d peers from the tracker", xbt_dict_length(peer.peers));
XBT_DEBUG("Here is my current status: %s", peer.bitfield);
peer.begin_receive_time = MSG_get_clock();
+ MSG_mailbox_set_async(peer.mailbox);
if (has_finished(peer.bitfield)) {
peer.pieces = FILE_PIECES;
send_handshake_all(&peer);
peer->current_pieces = xbt_dynar_new(sizeof(int), NULL);
peer->current_piece = -1;
- peer->stream = RngStream_CreateStream("");
+ peer->stream = MSG_host_get_data(MSG_host_self());
peer->comm_received = NULL;
peer->round = 0;
xbt_free(peer->pieces_count);
xbt_free(peer->bitfield);
xbt_free(peer->bitfield_blocks);
-
- RngStream_DeleteStream(&peer->stream);
}
/**
//remove a peer from the list
xbt_dict_cursor_t cursor = NULL;
xbt_dict_cursor_first(peer->active_peers, &cursor);
- if (xbt_dict_length(peer->active_peers) > 0) {
+ if (!xbt_dict_is_empty(peer->active_peers)) {
key = xbt_dict_cursor_get_key(cursor);
connection_t peer_choked = xbt_dict_cursor_get_data(cursor);
if (peer_choked) {