diff --git a/pwmlib/src/main/java/pt/ulisboa/tecnico/sec/tg11/PwmLib.java b/pwmlib/src/main/java/pt/ulisboa/tecnico/sec/tg11/PwmLib.java index ab9e3be..28aa582 100644 --- a/pwmlib/src/main/java/pt/ulisboa/tecnico/sec/tg11/PwmLib.java +++ b/pwmlib/src/main/java/pt/ulisboa/tecnico/sec/tg11/PwmLib.java @@ -31,13 +31,16 @@ import java.sql.Timestamp; import java.util.concurrent.*; +import static java.lang.Math.floor; +import static java.lang.Math.round; + /** * Created by trosado on 01/03/17. */ public class PwmLib { - private int REPLICAS; - private int NEEDEDANSWERS; + private Integer REPLICAS; + private double NEEDEDANSWERS; private final String CLIENT_PUBLIC_KEY = "privatekey"; private static final String PATH_TO_KEYSTORE = "./src/main/resources/keystore.jks"; @@ -72,8 +75,9 @@ issued at the client side, until a close() function is called. this._threadList = new ConcurrentHashMap(); this._serverKey = new HashMap(); this.REPLICAS = getNumberServers(); - this.NEEDEDANSWERS = ((2/3)*(REPLICAS-1))+1; - + this.NEEDEDANSWERS = round((2.0/3.0)*(REPLICAS-1)); + System.out.println("Detected "+REPLICAS+" servers."); + System.out.println("Needs "+(NEEDEDANSWERS+1)+" answers to succeed."); for(int i=1;i<=REPLICAS;i++){ String serverName = "PWMServer"+i;