X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b558f9b18c938af6a35ebea66ac2323a60178202..f2df13795e01302813a6aef10825ec7e922ce530:/examples/java/bittorrent/Peer.java diff --git a/examples/java/bittorrent/Peer.java b/examples/java/bittorrent/Peer.java index 47b300fd84..6ce5a5473d 100644 --- a/examples/java/bittorrent/Peer.java +++ b/examples/java/bittorrent/Peer.java @@ -1,14 +1,13 @@ -/* - * Copyright 2006-2012. The SimGrid Team. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. - */ +/* Copyright (c) 2006-2014. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + package bittorrent; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; @@ -16,12 +15,10 @@ import org.simgrid.msg.Comm; 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.RngStream; import org.simgrid.msg.Task; -import bittorrent.Connection; - /** * Main class for peers execution */ @@ -422,10 +419,9 @@ public class Peer extends Process { return; } if (true || pieces < 3) { - int i = 0, peerPiece; + int peerPiece; do { currentPiece = stream.randInt(0,Common.FILE_PIECES - 1); - i++; } while (!(bitfield[currentPiece] == '0' && !currentPieces.contains(currentPiece))); } else { @@ -484,8 +480,7 @@ public class Peer extends Process { peerChoosed = null; } j++; - } while (peerChoosed == null && j < - Common.MAXIMUM_PEERS); + } while (peerChoosed == null && j < Common.MAXIMUM_PEERS); } else { Connection fastest = null;