@Test public void testDeadNodes() { GSFSignature p = new GSFSignature( new GSFSignature.GSFSignatureParameters(32, 0.8, 3, 20, 10, 10, 0.1, nb, nl)); p.init(); long dead = p.network.allNodes.stream().filter(n -> n.isDown()).count(); Assert.assertEquals(3, dead); }
public void init() { for (int i = 0; i < params.nodeCount; i++) { final GSFNode n = new GSFNode(); network.addNode(n); } for (int setDown = 0; setDown < params.nodesDown; ) { int down = network.rd.nextInt(params.nodeCount); Node n = network.allNodes.get(down); if (!n.isDown() && down != 1) { n.stop(); setDown++; } } for (GSFNode n : network.allNodes) { if (!n.isDown()) { n.initLevel(); network.registerPeriodicTask(n::doCycle, 1, params.periodDurationMs, n); network.registerConditionalTask( n::checkSigs, 1, n.nodePairingTime, n, () -> !n.toVerify.isEmpty(), () -> !n.done); } } }
GSFSignature implements Protocol { public void init() { for (int i = 0; i < params.nodeCount; i++) { final GSFNode n = new GSFNode(); network.addNode(n); } for (int setDown = 0; setDown < params.nodesDown; ) { int down = network.rd.nextInt(params.nodeCount); Node n = network.allNodes.get(down); if (!n.isDown() && down != 1) { n.stop(); setDown++; } } for (GSFNode n : network.allNodes) { if (!n.isDown()) { n.initLevel(); network.registerPeriodicTask(n::doCycle, 1, params.periodDurationMs, n); network.registerConditionalTask( n::checkSigs, 1, n.nodePairingTime, n, () -> !n.toVerify.isEmpty(), () -> !n.done); } } } }
GSFSignature implements Protocol { public void init() { for (int i = 0; i < params.nodeCount; i++) { final GSFNode n = new GSFNode(); network.addNode(n); } for (int setDown = 0; setDown < params.nodesDown; ) { int down = network.rd.nextInt(params.nodeCount); Node n = network.allNodes.get(down); if (!n.isDown() && down != 1) { n.stop(); setDown++; } } for (GSFNode n : network.allNodes) { if (!n.isDown()) { n.initLevel(); network.registerPeriodicTask(n::doCycle, 1, params.periodDurationMs, n); network.registerConditionalTask( n::checkSigs, 1, n.nodePairingTime, n, () -> !n.toVerify.isEmpty(), () -> !n.done); } } } GSFSignature(GSFSignatureParameters params); }
GSFSignature implements Protocol { public void init() { for (int i = 0; i < params.nodeCount; i++) { final GSFNode n = new GSFNode(); network.addNode(n); } for (int setDown = 0; setDown < params.nodesDown; ) { int down = network.rd.nextInt(params.nodeCount); Node n = network.allNodes.get(down); if (!n.isDown() && down != 1) { n.stop(); setDown++; } } for (GSFNode n : network.allNodes) { if (!n.isDown()) { n.initLevel(); network.registerPeriodicTask(n::doCycle, 1, params.periodDurationMs, n); network.registerConditionalTask( n::checkSigs, 1, n.nodePairingTime, n, () -> !n.toVerify.isEmpty(), () -> !n.done); } } } GSFSignature(GSFSignatureParameters params); @Override String toString(); @Override GSFSignature copy(); void init(); @Override Network<GSFNode> network(); static void drawImgs(); static void sigsPerTime(); static void main(String... args); }
GSFSignature implements Protocol { public void init() { for (int i = 0; i < params.nodeCount; i++) { final GSFNode n = new GSFNode(); network.addNode(n); } for (int setDown = 0; setDown < params.nodesDown; ) { int down = network.rd.nextInt(params.nodeCount); Node n = network.allNodes.get(down); if (!n.isDown() && down != 1) { n.stop(); setDown++; } } for (GSFNode n : network.allNodes) { if (!n.isDown()) { n.initLevel(); network.registerPeriodicTask(n::doCycle, 1, params.periodDurationMs, n); network.registerConditionalTask( n::checkSigs, 1, n.nodePairingTime, n, () -> !n.toVerify.isEmpty(), () -> !n.done); } } } GSFSignature(GSFSignatureParameters params); @Override String toString(); @Override GSFSignature copy(); void init(); @Override Network<GSFNode> network(); static void drawImgs(); static void sigsPerTime(); static void main(String... args);  }