X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b836accb70f6c40db457d70bfd57b010a142dc8e..a25788919c83a83375651551211725b44b50d5e2:/examples/java/app/bittorrent/Peer.java diff --git a/examples/java/app/bittorrent/Peer.java b/examples/java/app/bittorrent/Peer.java index b7ce0c3899..0bdc770232 100644 --- a/examples/java/app/bittorrent/Peer.java +++ b/examples/java/app/bittorrent/Peer.java @@ -50,12 +50,12 @@ public class Peer extends Process { Msg.info("Wrong number of arguments"); } if (args.length == 3) { - init(Integer.valueOf(args[0]),true); + init(Integer.parseInt(args[0]),true); } else { - init(Integer.valueOf(args[0]),false); + init(Integer.parseInt(args[0]),false); } //Retrieve the deadline - deadline = Double.valueOf(args[1]); + deadline = Double.parseDouble(args[1]); if (deadline < 0) { Msg.info("Wrong deadline supplied"); return; @@ -365,7 +365,7 @@ public class Peer extends Process { * @brief Updates the list of who has a piece from a bitfield * @param bitfield bitfield */ - private void updatePiecesCountFromBitfield(char bitfield[]) { + private void updatePiecesCountFromBitfield(char[] bitfield) { for (int i = 0; i < Common.FILE_PIECES; i++) { if (bitfield[i] == '1') { piecesCount[i]++; @@ -426,9 +426,9 @@ public class Peer extends Process { } else { //Random optimistic unchoking if (round == 0) { - int j = 0, i; + int j = 0; do { - i = 0; + int i = 0; int idChosen = stream.randInt(0,peers.size() - 1); for (Connection connection : peers.values()) { if (i == idChosen) { @@ -519,10 +519,9 @@ public class Peer extends Process { return; } for (Integer piece : currentPieces) { - //Getting the block to send. - int blockIndex = -1, blockLength = 0; - blockIndex = getFirstBlock(piece); - blockLength = Common.PIECES_BLOCKS - blockIndex ; + //Getting the block to send. + int blockIndex = getFirstBlock(piece); + int blockLength = Common.PIECES_BLOCKS - blockIndex ; blockLength = blockLength > Common.BLOCKS_REQUESTED ? Common.BLOCKS_REQUESTED : blockLength; if (remotePeer.bitfield[piece] == '1') { sendRequest(remotePeer.mailbox, piece, blockIndex, blockLength);