diff --git a/src/ChannelGlobals.java b/src/ChannelGlobals.java index eaa7114..0525420 100644 --- a/src/ChannelGlobals.java +++ b/src/ChannelGlobals.java @@ -14,9 +14,11 @@ public class ChannelGlobals public static final String NODE_TAG = "node"; - public static final int LONG_RANGE_POINTS=2; - public static final int SHORT_RANGE_POINTS=2; + //public static final int LONG_RANGE_POINTS=2; + //public static final int SHORT_RANGE_POINTS=2; public static final int NEAR_POINTS=4; + public static final int RING_DIVISONS=6; + public static final int DHT_ELEMENT_SIZE = snowblossom.lib.Globals.BLOCKCHAIN_HASH_LEN; @@ -25,4 +27,5 @@ public class ChannelGlobals public static final long MAX_DATA_PEER_AGE=2L * 86400L * 1000L; + } diff --git a/src/DHTMaintainer.java b/src/DHTMaintainer.java index 33038bb..b65257c 100644 --- a/src/DHTMaintainer.java +++ b/src/DHTMaintainer.java @@ -100,7 +100,7 @@ public void runPass() throws Exception } logger.info("Connected peers: " + connected_peers); logger.info("New connections: " + connect_map.keySet()); - int desired_peers = ChannelGlobals.NEAR_POINTS + ChannelGlobals.LONG_RANGE_POINTS + ChannelGlobals.SHORT_RANGE_POINTS; + int desired_peers = ChannelGlobals.NEAR_POINTS + ChannelGlobals.RING_DIVISONS * 2; int to_close_count = connected_peers.size() - desired_peers; while ((to_close_count > 0) && (extra_peers.size() > 0)) { @@ -144,7 +144,21 @@ private Map pickTargetsFromDB() // Close neighbors target_map.putAll( getClosestValid( node.getNodeID().getBytes(), ChannelGlobals.NEAR_POINTS)); - double long_wedge = 1.0 / ChannelGlobals.LONG_RANGE_POINTS; + + double ring_dist= 0.5; + for(int i=0; i pickTargetsFromDB() { ByteString target = HashMath.shiftHashOnRing( node.getNodeID().getBytes(), -long_wedge/2.0 + short_wedge * i); target_map.putAll( getClosestValid( target, 1)); - } + }*/ // TODO - if we have a really full ring then the short range peers might not be very close to the target // and that peer won't have any way to get closer without just doing close neighbors to close neighbor hops @@ -310,7 +324,7 @@ public PruneThread() public void runPass() { - if (node.getPeerManager().getPeersWithReason("DHT").size() > ChannelGlobals.NEAR_POINTS) + if (node.getPeerManager().getPeersWithReason("DHT").size() > ChannelGlobals.NEAR_POINTS + ChannelGlobals.RING_DIVISONS) { byte[] b = new byte[1]; diff --git a/test/DHTTest.java b/test/DHTTest.java index b5b78df..2a40a0d 100644 --- a/test/DHTTest.java +++ b/test/DHTTest.java @@ -52,7 +52,6 @@ public void testDHTReadWrite() Random rnd = new Random(); byte[] id_bytes = new byte[16]; - int b_match = 0; for(int i=0; i<100; i++)