@Test public void testRepeatability() { P2PHandel.P2PHandelParameters params = new P2PHandel.P2PHandelParameters( 100, 0, 25, 10, 2, 5, false, P2PHandel.SendSigsStrategy.dif, true, nb, nl); P2PHandel p1 = new P2PHandel(params); P2PHandel p2 = new P2PHandel(params); p1.init(); p1.network.run(10); p2.init(); p2.network.run(10); for (Node n : p1.network.allNodes) { Assert.assertEquals(n.getDoneAt(), p2.network.getNodeById(n.nodeId).getDoneAt()); } }
@Override public void init() { Set<Integer> justRelay = new HashSet<>(params.relayingNodeCount); while (justRelay.size() < params.relayingNodeCount) { justRelay.add(network.rd.nextInt(params.signingNodeCount + params.relayingNodeCount)); } for (int i = 0; i < params.signingNodeCount + params.relayingNodeCount; i++) { final P2PHandelNode n = new P2PHandelNode(justRelay.contains(i)); network.addNode(n); if (params.sendState) { network.registerTask(n::sendStateToPeers, 1, n); } network.registerPeriodicTask(n::sendSigs, 1, params.sigsSendPeriod, n); network.registerConditionalTask( n::checkSigs, 1, params.pairingTime, n, () -> !n.toVerify.isEmpty(), () -> n.doneAt == 0); } network.setPeers(); }
P2PHandel implements Protocol { @Override public void init() { Set<Integer> justRelay = new HashSet<>(params.relayingNodeCount); while (justRelay.size() < params.relayingNodeCount) { justRelay.add(network.rd.nextInt(params.signingNodeCount + params.relayingNodeCount)); } for (int i = 0; i < params.signingNodeCount + params.relayingNodeCount; i++) { final P2PHandelNode n = new P2PHandelNode(justRelay.contains(i)); network.addNode(n); if (params.sendState) { network.registerTask(n::sendStateToPeers, 1, n); } network.registerPeriodicTask(n::sendSigs, 1, params.sigsSendPeriod, n); network.registerConditionalTask( n::checkSigs, 1, params.pairingTime, n, () -> !n.toVerify.isEmpty(), () -> n.doneAt == 0); } network.setPeers(); } }
P2PHandel implements Protocol { @Override public void init() { Set<Integer> justRelay = new HashSet<>(params.relayingNodeCount); while (justRelay.size() < params.relayingNodeCount) { justRelay.add(network.rd.nextInt(params.signingNodeCount + params.relayingNodeCount)); } for (int i = 0; i < params.signingNodeCount + params.relayingNodeCount; i++) { final P2PHandelNode n = new P2PHandelNode(justRelay.contains(i)); network.addNode(n); if (params.sendState) { network.registerTask(n::sendStateToPeers, 1, n); } network.registerPeriodicTask(n::sendSigs, 1, params.sigsSendPeriod, n); network.registerConditionalTask( n::checkSigs, 1, params.pairingTime, n, () -> !n.toVerify.isEmpty(), () -> n.doneAt == 0); } network.setPeers(); } P2PHandel(P2PHandelParameters params); }
P2PHandel implements Protocol { @Override public void init() { Set<Integer> justRelay = new HashSet<>(params.relayingNodeCount); while (justRelay.size() < params.relayingNodeCount) { justRelay.add(network.rd.nextInt(params.signingNodeCount + params.relayingNodeCount)); } for (int i = 0; i < params.signingNodeCount + params.relayingNodeCount; i++) { final P2PHandelNode n = new P2PHandelNode(justRelay.contains(i)); network.addNode(n); if (params.sendState) { network.registerTask(n::sendStateToPeers, 1, n); } network.registerPeriodicTask(n::sendSigs, 1, params.sigsSendPeriod, n); network.registerConditionalTask( n::checkSigs, 1, params.pairingTime, n, () -> !n.toVerify.isEmpty(), () -> n.doneAt == 0); } network.setPeers(); } P2PHandel(P2PHandelParameters params); @Override void init(); @Override Network<P2PHandelNode> network(); @Override P2PHandel copy(); }
P2PHandel implements Protocol { @Override public void init() { Set<Integer> justRelay = new HashSet<>(params.relayingNodeCount); while (justRelay.size() < params.relayingNodeCount) { justRelay.add(network.rd.nextInt(params.signingNodeCount + params.relayingNodeCount)); } for (int i = 0; i < params.signingNodeCount + params.relayingNodeCount; i++) { final P2PHandelNode n = new P2PHandelNode(justRelay.contains(i)); network.addNode(n); if (params.sendState) { network.registerTask(n::sendStateToPeers, 1, n); } network.registerPeriodicTask(n::sendSigs, 1, params.sigsSendPeriod, n); network.registerConditionalTask( n::checkSigs, 1, params.pairingTime, n, () -> !n.toVerify.isEmpty(), () -> n.doneAt == 0); } network.setPeers(); } P2PHandel(P2PHandelParameters params); @Override void init(); @Override Network<P2PHandelNode> network(); @Override P2PHandel copy();  }