@Test public void testEstimateLatency() { NetworkLatency nl = new NetworkLatency.EthScanNetworkLatency(); Network<Node> network = new Network<>(); network.setNetworkLatency(nl); NodeBuilder nb = new NodeBuilder(); for (int i = 0; i < 1000; i++) { network.addNode(new Node(new Random(0), nb)); } NetworkLatency.MeasuredNetworkLatency m1 = NetworkLatency.estimateLatency(network, 100000); network.setNetworkLatency(m1); NetworkLatency.MeasuredNetworkLatency m2 = NetworkLatency.estimateLatency(network, 100000); for (int i = 0; i < m1.longDistrib.length; i++) { Assert.assertEquals(m1.longDistrib[i], m2.longDistrib[i]); } }
public static MeasuredNetworkLatency estimateLatency(Network net, final int rounds) { return estimateLatency( net, n -> { Random rd = new Random(0); Node res = n; while (res == n) { res = (Node) net.allNodes.get(rd.nextInt(net.allNodes.size())); } return res; }, rounds); }
NetworkLatency { public static MeasuredNetworkLatency estimateLatency(Network net, final int rounds) { return estimateLatency( net, n -> { Random rd = new Random(0); Node res = n; while (res == n) { res = (Node) net.allNodes.get(rd.nextInt(net.allNodes.size())); } return res; }, rounds); } }
NetworkLatency { public static MeasuredNetworkLatency estimateLatency(Network net, final int rounds) { return estimateLatency( net, n -> { Random rd = new Random(0); Node res = n; while (res == n) { res = (Node) net.allNodes.get(rd.nextInt(net.allNodes.size())); } return res; }, rounds); }  }
NetworkLatency { public static MeasuredNetworkLatency estimateLatency(Network net, final int rounds) { return estimateLatency( net, n -> { Random rd = new Random(0); Node res = n; while (res == n) { res = (Node) net.allNodes.get(rd.nextInt(net.allNodes.size())); } return res; }, rounds); }  @Override String toString(); static MeasuredNetworkLatency estimateLatency(Network net, final int rounds); static MeasuredNetworkLatency estimateP2PLatency(P2PNetwork<?> net, final int rounds); static MeasuredNetworkLatency estimateLatency(
      Network net, PeerGetter pg, final int rounds); }
NetworkLatency { public static MeasuredNetworkLatency estimateLatency(Network net, final int rounds) { return estimateLatency( net, n -> { Random rd = new Random(0); Node res = n; while (res == n) { res = (Node) net.allNodes.get(rd.nextInt(net.allNodes.size())); } return res; }, rounds); }  @Override String toString(); static MeasuredNetworkLatency estimateLatency(Network net, final int rounds); static MeasuredNetworkLatency estimateP2PLatency(P2PNetwork<?> net, final int rounds); static MeasuredNetworkLatency estimateLatency(
      Network net, PeerGetter pg, final int rounds);  }