diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-19 20:49:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-19 20:49:42 +0000 |
commit | 8d2317b03bebc45dcf5b2c0414b657059c4b7a95 (patch) | |
tree | ea7e89eb9e9819b9a9b61f7cc68322383a239a9b /src/dht/gnunet-service-dht.c | |
parent | a575280ed6edf410317ff605088426b514370bbb (diff) | |
download | gnunet-8d2317b03bebc45dcf5b2c0414b657059c4b7a95.tar.gz gnunet-8d2317b03bebc45dcf5b2c0414b657059c4b7a95.zip |
stuff
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r-- | src/dht/gnunet-service-dht.c | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index ce1687df9..55e18f3ab 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -1941,8 +1941,10 @@ route_result_message (struct GNUNET_MessageHeader *msg, | |||
1941 | continue; | 1941 | continue; |
1942 | } | 1942 | } |
1943 | else | 1943 | else |
1944 | { | ||
1944 | GNUNET_CONTAINER_bloomfilter_add (pos->find_peers_responded, | 1945 | GNUNET_CONTAINER_bloomfilter_add (pos->find_peers_responded, |
1945 | &new_peer.hashPubKey); | 1946 | &new_peer.hashPubKey); |
1947 | } | ||
1946 | } | 1948 | } |
1947 | #endif | 1949 | #endif |
1948 | 1950 | ||
@@ -2988,6 +2990,7 @@ select_peer (const GNUNET_HashCode * target, | |||
2988 | GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)) | 2990 | GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)) |
2989 | { | 2991 | { |
2990 | pos = pos->next; | 2992 | pos = pos->next; |
2993 | increment_stats ("# peer blocked from selection by Bloom filter"); | ||
2991 | continue; /* Ignore bloomfiltered peers */ | 2994 | continue; /* Ignore bloomfiltered peers */ |
2992 | } | 2995 | } |
2993 | count++; | 2996 | count++; |
@@ -3250,8 +3253,6 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3250 | (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER)) | 3253 | (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER)) |
3251 | target_forward_count = 0; | 3254 | target_forward_count = 0; |
3252 | 3255 | ||
3253 | |||
3254 | GNUNET_CONTAINER_bloomfilter_add (msg_ctx->bloom, &my_identity.hashPubKey); | ||
3255 | #if HAVE_UID_FOR_TESTING > 1 | 3256 | #if HAVE_UID_FOR_TESTING > 1 |
3256 | /* BUG HERE: recent uses unique_id! So if all unique-IDs are 0, we get | 3257 | /* BUG HERE: recent uses unique_id! So if all unique-IDs are 0, we get |
3257 | easily into trouble!!! Also, this should not even be necessary... */ | 3258 | easily into trouble!!! Also, this should not even be necessary... */ |
@@ -3304,52 +3305,50 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3304 | for (i = 0; i < target_forward_count; i++) | 3305 | for (i = 0; i < target_forward_count; i++) |
3305 | { | 3306 | { |
3306 | selected = select_peer (&msg_ctx->key, msg_ctx->bloom, msg_ctx->hop_count); | 3307 | selected = select_peer (&msg_ctx->key, msg_ctx->bloom, msg_ctx->hop_count); |
3307 | 3308 | if (selected == NULL) | |
3308 | if (selected != NULL) | 3309 | break; |
3310 | forward_count++; | ||
3311 | if (GNUNET_CRYPTO_hash_matching_bits | ||
3312 | (&selected->id.hashPubKey, | ||
3313 | &msg_ctx->key) >= | ||
3314 | GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, | ||
3315 | &msg_ctx->key)) | ||
3316 | GNUNET_asprintf (&temp_stat_str, | ||
3317 | "# requests routed to close(r) peer hop %u", | ||
3318 | msg_ctx->hop_count); | ||
3319 | else | ||
3320 | GNUNET_asprintf (&temp_stat_str, | ||
3321 | "# requests routed to less close peer hop %u", | ||
3322 | msg_ctx->hop_count); | ||
3323 | if (temp_stat_str != NULL) | ||
3309 | { | 3324 | { |
3310 | forward_count++; | 3325 | increment_stats (temp_stat_str); |
3311 | if (GNUNET_CRYPTO_hash_matching_bits | 3326 | GNUNET_free (temp_stat_str); |
3312 | (&selected->id.hashPubKey, | 3327 | } |
3313 | &msg_ctx->key) >= | 3328 | GNUNET_CONTAINER_bloomfilter_add (msg_ctx->bloom, |
3314 | GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, | 3329 | &selected->id.hashPubKey); |
3315 | &msg_ctx->key)) | ||
3316 | GNUNET_asprintf (&temp_stat_str, | ||
3317 | "# requests routed to close(r) peer hop %u", | ||
3318 | msg_ctx->hop_count); | ||
3319 | else | ||
3320 | GNUNET_asprintf (&temp_stat_str, | ||
3321 | "# requests routed to less close peer hop %u", | ||
3322 | msg_ctx->hop_count); | ||
3323 | if (temp_stat_str != NULL) | ||
3324 | { | ||
3325 | increment_stats (temp_stat_str); | ||
3326 | GNUNET_free (temp_stat_str); | ||
3327 | } | ||
3328 | GNUNET_CONTAINER_bloomfilter_add (msg_ctx->bloom, | ||
3329 | &selected->id.hashPubKey); | ||
3330 | #if DEBUG_DHT_ROUTING > 1 | 3330 | #if DEBUG_DHT_ROUTING > 1 |
3331 | nearest = find_closest_peer (&msg_ctx->key); | 3331 | nearest = find_closest_peer (&msg_ctx->key); |
3332 | nearest_buf = GNUNET_strdup (GNUNET_i2s (&nearest->id)); | 3332 | nearest_buf = GNUNET_strdup (GNUNET_i2s (&nearest->id)); |
3333 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3333 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3334 | "`%s:%s': Forwarding request key %s uid %llu to peer %s (closest %s, bits %d, distance %u)\n", | 3334 | "`%s:%s': Forwarding request key %s uid %llu to peer %s (closest %s, bits %d, distance %u)\n", |
3335 | my_short_id, "DHT", GNUNET_h2s (&msg_ctx->key), | 3335 | my_short_id, "DHT", GNUNET_h2s (&msg_ctx->key), |
3336 | msg_ctx->unique_id, GNUNET_i2s (&selected->id), nearest_buf, | 3336 | msg_ctx->unique_id, GNUNET_i2s (&selected->id), nearest_buf, |
3337 | GNUNET_CRYPTO_hash_matching_bits (&nearest->id.hashPubKey, | 3337 | GNUNET_CRYPTO_hash_matching_bits (&nearest->id.hashPubKey, |
3338 | msg_ctx->key), | 3338 | msg_ctx->key), |
3339 | distance (&nearest->id.hashPubKey, msg_ctx->key)); | 3339 | distance (&nearest->id.hashPubKey, msg_ctx->key)); |
3340 | GNUNET_free (nearest_buf); | 3340 | GNUNET_free (nearest_buf); |
3341 | #endif | 3341 | #endif |
3342 | #if DEBUG_DHT_ROUTING | 3342 | #if DEBUG_DHT_ROUTING |
3343 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 3343 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
3344 | { | 3344 | { |
3345 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 3345 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
3346 | msg_ctx->hop_count, GNUNET_NO, | 3346 | msg_ctx->hop_count, GNUNET_NO, |
3347 | &my_identity, &msg_ctx->key, &msg_ctx->peer, | 3347 | &my_identity, &msg_ctx->key, &msg_ctx->peer, |
3348 | &selected->id); | 3348 | &selected->id); |
3349 | } | ||
3350 | #endif | ||
3351 | forward_message (msg, selected, msg_ctx); | ||
3352 | } | 3349 | } |
3350 | #endif | ||
3351 | forward_message (msg, selected, msg_ctx); | ||
3353 | } | 3352 | } |
3354 | 3353 | ||
3355 | if (msg_ctx->bloom != NULL) | 3354 | if (msg_ctx->bloom != NULL) |
@@ -4343,7 +4342,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
4343 | * @param identity the public identity of this peer | 4342 | * @param identity the public identity of this peer |
4344 | * @param publicKey the public key of this peer | 4343 | * @param publicKey the public key of this peer |
4345 | */ | 4344 | */ |
4346 | void | 4345 | static void |
4347 | core_init (void *cls, struct GNUNET_CORE_Handle *server, | 4346 | core_init (void *cls, struct GNUNET_CORE_Handle *server, |
4348 | const struct GNUNET_PeerIdentity *identity, | 4347 | const struct GNUNET_PeerIdentity *identity, |
4349 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 4348 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) |