import org.simgrid.msg.Host;
import org.simgrid.msg.Msg;
import org.simgrid.msg.MsgException;
+import org.simgrid.msg.RngStream;
import org.simgrid.msg.Process;
import org.simgrid.msg.Task;
protected double deadline;
+ protected static RngStream stream = new RngStream();
+
protected int id;
protected String mailbox;
protected String mailboxTracker;
if (bitfield[message.index] == '0') {
piecesRequested--;
//Removing the piece from our piece list.
- //TODO: It can not work, I should test it
if (!currentPieces.remove((Object)Integer.valueOf(message.index))) {
}
//Setting the fact that we have the piece
if (true || pieces < 3) {
int i = 0, peerPiece;
do {
- currentPiece = ((int)Msg.getClock() + id + i) % Common.FILE_PIECES;
+ currentPiece = stream.randInt(0,Common.FILE_PIECES - 1);
i++;
} while (!(bitfield[currentPiece] == '0' && !currentPieces.contains(currentPiece)));
}
sendUnchoked(peerChoosed.mailbox);
}
}
+ //TODO: Use the leecher choke algorithm.
}
/**
* Updates our "interested" state about peers: send "not interested" to peers