Skip to content

Commit

Permalink
Merge branch 'probe-link-lengths' of github.com:bertm/fred-staging in…
Browse files Browse the repository at this point in the history
…to next
  • Loading branch information
Thynix committed May 26, 2014
2 parents 57733db + 51c5552 commit ba3543d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/freenet/node/probe/Probe.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import freenet.io.comm.MessageFilter;
import freenet.io.comm.NotConnectedException;
import freenet.io.comm.PeerContext;
import freenet.node.Location;
import freenet.node.Node;
import freenet.node.OpennetManager;
import freenet.node.PeerNode;
Expand Down Expand Up @@ -636,10 +637,15 @@ private void respond(final Type type, final Listener listener) {
* assumption that a change of 0.002 is enough to make it still useful for statistics but not
* useful for identification, 0.002 change / 0.2 link length = 0.01 sigma.
*/
double myLoc = node.getLocation();
for (PeerNode peer : peers) {
linkLengths[i++] = (float)randomNoise(Math.min(Math.abs(peer.getLocation() - node.getLocation()),
1.0 - Math.abs(peer.getLocation() - node.getLocation())), 0.01);
double peerLoc = peer.getLocation();
if (Location.isValid(peerLoc)) {
linkLengths[i++] = (float)randomNoise(Location.distance(myLoc, peerLoc), 0.01);
}
}
linkLengths = java.util.Arrays.copyOf(linkLengths, i);
java.util.Arrays.sort(linkLengths);
listener.onLinkLengths(linkLengths);
break;
case LOCATION:
Expand Down

0 comments on commit ba3543d

Please sign in to comment.