diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-03-08 13:27:39 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-03-08 13:27:39 +0000 |
commit | ea0e0d2f150110ab95da3ee208965333581e3454 (patch) | |
tree | e6e398e3b4dc12f5bd42c5d4f805aaa55b65ecef /src/dht | |
parent | b458b5eb0c54e835f5b3295a900159955fc13d60 (diff) | |
download | gnunet-ea0e0d2f150110ab95da3ee208965333581e3454.tar.gz gnunet-ea0e0d2f150110ab95da3ee208965333581e3454.zip |
-make DHt routing more sane
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 38ee2b8b4..21938cd27 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -857,12 +857,12 @@ get_forward_count (uint32_t hop_count, uint32_t target_replication) | |||
857 | uint32_t forward_count; | 857 | uint32_t forward_count; |
858 | float target_value; | 858 | float target_value; |
859 | 859 | ||
860 | if (hop_count > GDS_NSE_get () * 6.0) | 860 | if (hop_count > GDS_NSE_get () * 4.0) |
861 | { | 861 | { |
862 | /* forcefully terminate */ | 862 | /* forcefully terminate */ |
863 | return 0; | 863 | return 0; |
864 | } | 864 | } |
865 | if (hop_count > GDS_NSE_get () * 4.0) | 865 | if (hop_count > GDS_NSE_get () * 2.0) |
866 | { | 866 | { |
867 | /* Once we have reached our ideal number of hops, only forward to 1 peer */ | 867 | /* Once we have reached our ideal number of hops, only forward to 1 peer */ |
868 | return 1; | 868 | return 1; |
@@ -1053,6 +1053,12 @@ select_peer (const struct GNUNET_HashCode * key, | |||
1053 | gettext_noop | 1053 | gettext_noop |
1054 | ("# Peers excluded from routing due to Bloomfilter"), | 1054 | ("# Peers excluded from routing due to Bloomfilter"), |
1055 | 1, GNUNET_NO); | 1055 | 1, GNUNET_NO); |
1056 | dist = get_distance (key, &pos->id.hashPubKey); | ||
1057 | if (dist < smallest_distance) | ||
1058 | { | ||
1059 | chosen = NULL; | ||
1060 | smallest_distance = dist; | ||
1061 | } | ||
1056 | } | 1062 | } |
1057 | count++; | 1063 | count++; |
1058 | pos = pos->next; | 1064 | pos = pos->next; |
@@ -1091,7 +1097,7 @@ select_peer (const struct GNUNET_HashCode * key, | |||
1091 | pos = pos->next; | 1097 | pos = pos->next; |
1092 | } | 1098 | } |
1093 | } | 1099 | } |
1094 | if (count == 0) /* No peers to select from! */ | 1100 | if (0 == count) /* No peers to select from! */ |
1095 | { | 1101 | { |
1096 | GNUNET_STATISTICS_update (GDS_stats, | 1102 | GNUNET_STATISTICS_update (GDS_stats, |
1097 | gettext_noop ("# Peer selection failed"), 1, | 1103 | gettext_noop ("# Peer selection failed"), 1, |
@@ -1146,7 +1152,7 @@ get_target_peers (const struct GNUNET_HashCode *key, | |||
1146 | 1152 | ||
1147 | GNUNET_assert (NULL != bloom); | 1153 | GNUNET_assert (NULL != bloom); |
1148 | ret = get_forward_count (hop_count, target_replication); | 1154 | ret = get_forward_count (hop_count, target_replication); |
1149 | if (ret == 0) | 1155 | if (0 == ret) |
1150 | { | 1156 | { |
1151 | *targets = NULL; | 1157 | *targets = NULL; |
1152 | return 0; | 1158 | return 0; |
@@ -1155,7 +1161,7 @@ get_target_peers (const struct GNUNET_HashCode *key, | |||
1155 | for (off = 0; off < ret; off++) | 1161 | for (off = 0; off < ret; off++) |
1156 | { | 1162 | { |
1157 | nxt = select_peer (key, bloom, hop_count); | 1163 | nxt = select_peer (key, bloom, hop_count); |
1158 | if (nxt == NULL) | 1164 | if (NULL == nxt) |
1159 | break; | 1165 | break; |
1160 | rtargets[off] = nxt; | 1166 | rtargets[off] = nxt; |
1161 | GNUNET_break (GNUNET_NO == | 1167 | GNUNET_break (GNUNET_NO == |