aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-08-08 13:17:24 +0000
committerChristian Grothoff <christian@grothoff.org>2016-08-08 13:17:24 +0000
commit86a3fcdd55ad2cb221fbc2d495a90def1532b01a (patch)
tree19915f47f3ca4fa9c29e0688df331c5b6f9d5494 /src/dht/gnunet-service-dht_neighbours.c
parent6c67d9bc9b059cd2fc77ad276936cdeaa4ad2296 (diff)
downloadgnunet-86a3fcdd55ad2cb221fbc2d495a90def1532b01a.tar.gz
gnunet-86a3fcdd55ad2cb221fbc2d495a90def1532b01a.zip
eliminate constantly hashing PIDs by storing and caching the result
Diffstat (limited to 'src/dht/gnunet-service-dht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c168
1 files changed, 73 insertions, 95 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 1a2fa32e4..2dd6c800b 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -281,6 +281,16 @@ struct PeerInfo
281 */ 281 */
282 const struct GNUNET_PeerIdentity *id; 282 const struct GNUNET_PeerIdentity *id;
283 283
284 /**
285 * Hash of @e id.
286 */
287 struct GNUNET_HashCode phash;
288
289 /**
290 * Which bucket is this peer in?
291 */
292 int peer_bucket;
293
284}; 294};
285 295
286 296
@@ -630,8 +640,10 @@ add_known_to_bloom (void *cls,
630 &mh); 640 &mh);
631 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 641 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
632 "Adding known peer (%s) to bloomfilter for FIND PEER with mutation %u\n", 642 "Adding known peer (%s) to bloomfilter for FIND PEER with mutation %u\n",
633 GNUNET_i2s (key), ctx->bf_mutator); 643 GNUNET_i2s (key),
634 GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, &mh); 644 ctx->bf_mutator);
645 GNUNET_CONTAINER_bloomfilter_add (ctx->bloom,
646 &mh);
635 return GNUNET_YES; 647 return GNUNET_YES;
636} 648}
637 649
@@ -713,9 +725,7 @@ handle_core_connect (void *cls,
713 const struct GNUNET_PeerIdentity *peer, 725 const struct GNUNET_PeerIdentity *peer,
714 struct GNUNET_MQ_Handle *mq) 726 struct GNUNET_MQ_Handle *mq)
715{ 727{
716 struct PeerInfo *ret; 728 struct PeerInfo *pi;
717 struct GNUNET_HashCode phash;
718 int peer_bucket;
719 729
720 /* Check for connect to self message */ 730 /* Check for connect to self message */
721 if (0 == memcmp (&my_identity, 731 if (0 == memcmp (&my_identity,
@@ -732,27 +742,28 @@ handle_core_connect (void *cls,
732 gettext_noop ("# peers connected"), 742 gettext_noop ("# peers connected"),
733 1, 743 1,
734 GNUNET_NO); 744 GNUNET_NO);
745 pi = GNUNET_new (struct PeerInfo);
746 pi->id = peer;
747 pi->mq = mq;
735 GNUNET_CRYPTO_hash (peer, 748 GNUNET_CRYPTO_hash (peer,
736 sizeof (struct GNUNET_PeerIdentity), 749 sizeof (struct GNUNET_PeerIdentity),
737 &phash); 750 &pi->phash);
738 peer_bucket = find_bucket (&phash); 751 pi->peer_bucket = find_bucket (&pi->phash);
739 GNUNET_assert ((peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS)); 752 GNUNET_assert ( (pi->peer_bucket >= 0) &&
740 ret = GNUNET_new (struct PeerInfo); 753 (pi->peer_bucket < MAX_BUCKETS) );
741 ret->id = peer; 754 GNUNET_CONTAINER_DLL_insert_tail (k_buckets[pi->peer_bucket].head,
742 ret->mq = mq; 755 k_buckets[pi->peer_bucket].tail,
743 GNUNET_CONTAINER_DLL_insert_tail (k_buckets[peer_bucket].head, 756 pi);
744 k_buckets[peer_bucket].tail, 757 k_buckets[pi->peer_bucket].peers_size++;
745 ret);
746 k_buckets[peer_bucket].peers_size++;
747 closest_bucket = GNUNET_MAX (closest_bucket, 758 closest_bucket = GNUNET_MAX (closest_bucket,
748 peer_bucket); 759 pi->peer_bucket);
749 GNUNET_assert (GNUNET_OK == 760 GNUNET_assert (GNUNET_OK ==
750 GNUNET_CONTAINER_multipeermap_put (all_connected_peers, 761 GNUNET_CONTAINER_multipeermap_put (all_connected_peers,
751 ret->id, 762 pi->id,
752 ret, 763 pi,
753 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 764 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
754 if ( (peer_bucket > 0) && 765 if ( (pi->peer_bucket > 0) &&
755 (k_buckets[peer_bucket].peers_size <= bucket_size)) 766 (k_buckets[pi->peer_bucket].peers_size <= bucket_size))
756 { 767 {
757 update_connect_preferences (); 768 update_connect_preferences ();
758 newly_found_peers++; 769 newly_found_peers++;
@@ -765,7 +776,7 @@ handle_core_connect (void *cls,
765 find_peer_task = GNUNET_SCHEDULER_add_now (&send_find_peer_message, 776 find_peer_task = GNUNET_SCHEDULER_add_now (&send_find_peer_message,
766 NULL); 777 NULL);
767 } 778 }
768 return ret; 779 return pi;
769} 780}
770 781
771 782
@@ -782,8 +793,6 @@ handle_core_disconnect (void *cls,
782 void *internal_cls) 793 void *internal_cls)
783{ 794{
784 struct PeerInfo *to_remove = internal_cls; 795 struct PeerInfo *to_remove = internal_cls;
785 int current_bucket;
786 struct GNUNET_HashCode phash;
787 796
788 /* Check for disconnect from self message */ 797 /* Check for disconnect from self message */
789 if (NULL == to_remove) 798 if (NULL == to_remove)
@@ -805,20 +814,16 @@ handle_core_disconnect (void *cls,
805 GNUNET_SCHEDULER_cancel (find_peer_task); 814 GNUNET_SCHEDULER_cancel (find_peer_task);
806 find_peer_task = NULL; 815 find_peer_task = NULL;
807 } 816 }
808 GNUNET_CRYPTO_hash (peer, 817 GNUNET_assert (to_remove->peer_bucket >= 0);
809 sizeof (struct GNUNET_PeerIdentity), 818 GNUNET_CONTAINER_DLL_remove (k_buckets[to_remove->peer_bucket].head,
810 &phash); 819 k_buckets[to_remove->peer_bucket].tail,
811 current_bucket = find_bucket (&phash);
812 GNUNET_assert (current_bucket >= 0);
813 GNUNET_CONTAINER_DLL_remove (k_buckets[current_bucket].head,
814 k_buckets[current_bucket].tail,
815 to_remove); 820 to_remove);
816 GNUNET_assert (k_buckets[current_bucket].peers_size > 0); 821 GNUNET_assert (k_buckets[to_remove->peer_bucket].peers_size > 0);
817 k_buckets[current_bucket].peers_size--; 822 k_buckets[to_remove->peer_bucket].peers_size--;
818 while ( (closest_bucket > 0) && 823 while ( (closest_bucket > 0) &&
819 (0 == k_buckets[closest_bucket].peers_size) ) 824 (0 == k_buckets[to_remove->peer_bucket].peers_size) )
820 closest_bucket--; 825 closest_bucket--;
821 if (k_buckets[current_bucket].peers_size < bucket_size) 826 if (k_buckets[to_remove->peer_bucket].peers_size < bucket_size)
822 update_connect_preferences (); 827 update_connect_preferences ();
823 GNUNET_free (to_remove); 828 GNUNET_free (to_remove);
824} 829}
@@ -907,7 +912,8 @@ get_distance (const struct GNUNET_HashCode *target,
907 912
908 /* first, calculate the most significant 9 bits of our 913 /* first, calculate the most significant 9 bits of our
909 * result, aka the number of LSBs */ 914 * result, aka the number of LSBs */
910 bucket = GNUNET_CRYPTO_hash_matching_bits (target, have); 915 bucket = GNUNET_CRYPTO_hash_matching_bits (target,
916 have);
911 /* bucket is now a value between 0 and 512 */ 917 /* bucket is now a value between 0 and 512 */
912 if (bucket == 512) 918 if (bucket == 512)
913 return 0; /* perfect match */ 919 return 0; /* perfect match */
@@ -953,28 +959,27 @@ am_closest_peer (const struct GNUNET_HashCode *key,
953 int bucket_num; 959 int bucket_num;
954 int count; 960 int count;
955 struct PeerInfo *pos; 961 struct PeerInfo *pos;
956 struct GNUNET_HashCode phash;
957 962
958 if (0 == memcmp (&my_identity_hash, key, sizeof (struct GNUNET_HashCode))) 963 if (0 == memcmp (&my_identity_hash, key, sizeof (struct GNUNET_HashCode)))
959 return GNUNET_YES; 964 return GNUNET_YES;
960 bucket_num = find_bucket (key); 965 bucket_num = find_bucket (key);
961 GNUNET_assert (bucket_num >= 0); 966 GNUNET_assert (bucket_num >= 0);
962 bits = GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash, key); 967 bits = GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash,
968 key);
963 pos = k_buckets[bucket_num].head; 969 pos = k_buckets[bucket_num].head;
964 count = 0; 970 count = 0;
965 while ((NULL != pos) && (count < bucket_size)) 971 while ((NULL != pos) && (count < bucket_size))
966 { 972 {
967 GNUNET_CRYPTO_hash (pos->id,
968 sizeof (struct GNUNET_PeerIdentity),
969 &phash);
970 if ((NULL != bloom) && 973 if ((NULL != bloom) &&
971 (GNUNET_YES == 974 (GNUNET_YES ==
972 GNUNET_CONTAINER_bloomfilter_test (bloom, &phash))) 975 GNUNET_CONTAINER_bloomfilter_test (bloom,
976 &pos->phash)))
973 { 977 {
974 pos = pos->next; 978 pos = pos->next;
975 continue; /* Skip already checked entries */ 979 continue; /* Skip already checked entries */
976 } 980 }
977 other_bits = GNUNET_CRYPTO_hash_matching_bits (&phash, key); 981 other_bits = GNUNET_CRYPTO_hash_matching_bits (&pos->phash,
982 key);
978 if (other_bits > bits) 983 if (other_bits > bits)
979 return GNUNET_NO; 984 return GNUNET_NO;
980 if (other_bits == bits) /* We match the same number of bits */ 985 if (other_bits == bits) /* We match the same number of bits */
@@ -1015,7 +1020,6 @@ select_peer (const struct GNUNET_HashCode *key,
1015 unsigned int dist; 1020 unsigned int dist;
1016 unsigned int smallest_distance; 1021 unsigned int smallest_distance;
1017 struct PeerInfo *chosen; 1022 struct PeerInfo *chosen;
1018 struct GNUNET_HashCode phash;
1019 1023
1020 if (hops >= GDS_NSE_get ()) 1024 if (hops >= GDS_NSE_get ())
1021 { 1025 {
@@ -1028,14 +1032,13 @@ select_peer (const struct GNUNET_HashCode *key,
1028 count = 0; 1032 count = 0;
1029 while ((pos != NULL) && (count < bucket_size)) 1033 while ((pos != NULL) && (count < bucket_size))
1030 { 1034 {
1031 GNUNET_CRYPTO_hash (pos->id,
1032 sizeof (struct GNUNET_PeerIdentity),
1033 &phash);
1034 if ((bloom == NULL) || 1035 if ((bloom == NULL) ||
1035 (GNUNET_NO == 1036 (GNUNET_NO ==
1036 GNUNET_CONTAINER_bloomfilter_test (bloom, &phash))) 1037 GNUNET_CONTAINER_bloomfilter_test (bloom,
1038 &pos->phash)))
1037 { 1039 {
1038 dist = get_distance (key, &phash); 1040 dist = get_distance (key,
1041 &pos->phash);
1039 if (dist < smallest_distance) 1042 if (dist < smallest_distance)
1040 { 1043 {
1041 chosen = pos; 1044 chosen = pos;
@@ -1049,10 +1052,11 @@ select_peer (const struct GNUNET_HashCode *key,
1049 GNUNET_i2s (pos->id), 1052 GNUNET_i2s (pos->id),
1050 GNUNET_h2s (key)); 1053 GNUNET_h2s (key));
1051 GNUNET_STATISTICS_update (GDS_stats, 1054 GNUNET_STATISTICS_update (GDS_stats,
1052 gettext_noop 1055 gettext_noop ("# Peers excluded from routing due to Bloomfilter"),
1053 ("# Peers excluded from routing due to Bloomfilter"), 1056 1,
1054 1, GNUNET_NO); 1057 GNUNET_NO);
1055 dist = get_distance (key, &phash); 1058 dist = get_distance (key,
1059 &pos->phash);
1056 if (dist < smallest_distance) 1060 if (dist < smallest_distance)
1057 { 1061 {
1058 chosen = NULL; 1062 chosen = NULL;
@@ -1078,12 +1082,10 @@ select_peer (const struct GNUNET_HashCode *key,
1078 pos = k_buckets[bc].head; 1082 pos = k_buckets[bc].head;
1079 while ((pos != NULL) && (count < bucket_size)) 1083 while ((pos != NULL) && (count < bucket_size))
1080 { 1084 {
1081 GNUNET_CRYPTO_hash (pos->id,
1082 sizeof (struct GNUNET_PeerIdentity),
1083 &phash);
1084 if ((bloom != NULL) && 1085 if ((bloom != NULL) &&
1085 (GNUNET_YES == 1086 (GNUNET_YES ==
1086 GNUNET_CONTAINER_bloomfilter_test (bloom, &phash))) 1087 GNUNET_CONTAINER_bloomfilter_test (bloom,
1088 &pos->phash)))
1087 { 1089 {
1088 GNUNET_STATISTICS_update (GDS_stats, 1090 GNUNET_STATISTICS_update (GDS_stats,
1089 gettext_noop 1091 gettext_noop
@@ -1108,18 +1110,17 @@ select_peer (const struct GNUNET_HashCode *key,
1108 return NULL; 1110 return NULL;
1109 } 1111 }
1110 /* Now actually choose a peer */ 1112 /* Now actually choose a peer */
1111 selected = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, count); 1113 selected = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1114 count);
1112 count = 0; 1115 count = 0;
1113 for (bc = 0; bc <= closest_bucket; bc++) 1116 for (bc = 0; bc <= closest_bucket; bc++)
1114 { 1117 {
1115 for (pos = k_buckets[bc].head; ((pos != NULL) && (count < bucket_size)); pos = pos->next) 1118 for (pos = k_buckets[bc].head; ((pos != NULL) && (count < bucket_size)); pos = pos->next)
1116 { 1119 {
1117 GNUNET_CRYPTO_hash (pos->id,
1118 sizeof (struct GNUNET_PeerIdentity),
1119 &phash);
1120 if ((bloom != NULL) && 1120 if ((bloom != NULL) &&
1121 (GNUNET_YES == 1121 (GNUNET_YES ==
1122 GNUNET_CONTAINER_bloomfilter_test (bloom, &phash))) 1122 GNUNET_CONTAINER_bloomfilter_test (bloom,
1123 &pos->phash)))
1123 { 1124 {
1124 continue; /* Ignore bloomfiltered peers */ 1125 continue; /* Ignore bloomfiltered peers */
1125 } 1126 }
@@ -1156,7 +1157,6 @@ get_target_peers (const struct GNUNET_HashCode *key,
1156 unsigned int off; 1157 unsigned int off;
1157 struct PeerInfo **rtargets; 1158 struct PeerInfo **rtargets;
1158 struct PeerInfo *nxt; 1159 struct PeerInfo *nxt;
1159 struct GNUNET_HashCode nhash;
1160 1160
1161 GNUNET_assert (NULL != bloom); 1161 GNUNET_assert (NULL != bloom);
1162 ret = get_forward_count (hop_count, 1162 ret = get_forward_count (hop_count,
@@ -1174,13 +1174,11 @@ get_target_peers (const struct GNUNET_HashCode *key,
1174 if (NULL == nxt) 1174 if (NULL == nxt)
1175 break; 1175 break;
1176 rtargets[off] = nxt; 1176 rtargets[off] = nxt;
1177 GNUNET_CRYPTO_hash (nxt->id,
1178 sizeof (struct GNUNET_PeerIdentity),
1179 &nhash);
1180 GNUNET_break (GNUNET_NO == 1177 GNUNET_break (GNUNET_NO ==
1181 GNUNET_CONTAINER_bloomfilter_test (bloom, 1178 GNUNET_CONTAINER_bloomfilter_test (bloom,
1182 &nhash)); 1179 &nxt->phash));
1183 GNUNET_CONTAINER_bloomfilter_add (bloom, &nhash); 1180 GNUNET_CONTAINER_bloomfilter_add (bloom,
1181 &nxt->phash);
1184 } 1182 }
1185 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1186 "Selected %u/%u peers at hop %u for %s (target was %u)\n", 1184 "Selected %u/%u peers at hop %u for %s (target was %u)\n",
@@ -1246,7 +1244,6 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
1246 struct GNUNET_MQ_Envelope *env; 1244 struct GNUNET_MQ_Envelope *env;
1247 struct PeerPutMessage *ppm; 1245 struct PeerPutMessage *ppm;
1248 struct GNUNET_PeerIdentity *pp; 1246 struct GNUNET_PeerIdentity *pp;
1249 struct GNUNET_HashCode thash;
1250 unsigned int skip_count; 1247 unsigned int skip_count;
1251 1248
1252 GNUNET_assert (NULL != bf); 1249 GNUNET_assert (NULL != bf);
@@ -1320,12 +1317,9 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
1320 ppm->desired_replication_level = htonl (desired_replication_level); 1317 ppm->desired_replication_level = htonl (desired_replication_level);
1321 ppm->put_path_length = htonl (put_path_length); 1318 ppm->put_path_length = htonl (put_path_length);
1322 ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time); 1319 ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
1323 GNUNET_CRYPTO_hash (target->id,
1324 sizeof (struct GNUNET_PeerIdentity),
1325 &thash);
1326 GNUNET_break (GNUNET_YES == 1320 GNUNET_break (GNUNET_YES ==
1327 GNUNET_CONTAINER_bloomfilter_test (bf, 1321 GNUNET_CONTAINER_bloomfilter_test (bf,
1328 &thash)); 1322 &target->phash));
1329 GNUNET_assert (GNUNET_OK == 1323 GNUNET_assert (GNUNET_OK ==
1330 GNUNET_CONTAINER_bloomfilter_get_raw_data (bf, 1324 GNUNET_CONTAINER_bloomfilter_get_raw_data (bf,
1331 ppm->bloomfilter, 1325 ppm->bloomfilter,
@@ -1383,7 +1377,6 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
1383 struct PeerGetMessage *pgm; 1377 struct PeerGetMessage *pgm;
1384 char *xq; 1378 char *xq;
1385 size_t reply_bf_size; 1379 size_t reply_bf_size;
1386 struct GNUNET_HashCode thash;
1387 unsigned int skip_count; 1380 unsigned int skip_count;
1388 1381
1389 GNUNET_assert (NULL != peer_bf); 1382 GNUNET_assert (NULL != peer_bf);
@@ -1451,12 +1444,9 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
1451 pgm->desired_replication_level = htonl (desired_replication_level); 1444 pgm->desired_replication_level = htonl (desired_replication_level);
1452 pgm->xquery_size = htonl (xquery_size); 1445 pgm->xquery_size = htonl (xquery_size);
1453 pgm->bf_mutator = reply_bf_mutator; 1446 pgm->bf_mutator = reply_bf_mutator;
1454 GNUNET_CRYPTO_hash (target->id,
1455 sizeof (struct GNUNET_PeerIdentity),
1456 &thash);
1457 GNUNET_break (GNUNET_YES == 1447 GNUNET_break (GNUNET_YES ==
1458 GNUNET_CONTAINER_bloomfilter_test (peer_bf, 1448 GNUNET_CONTAINER_bloomfilter_test (peer_bf,
1459 &thash)); 1449 &target->phash));
1460 GNUNET_assert (GNUNET_OK == 1450 GNUNET_assert (GNUNET_OK ==
1461 GNUNET_CONTAINER_bloomfilter_get_raw_data (peer_bf, 1451 GNUNET_CONTAINER_bloomfilter_get_raw_data (peer_bf,
1462 pgm->bloomfilter, 1452 pgm->bloomfilter,
@@ -1649,7 +1639,6 @@ handle_dht_p2p_put (void *cls,
1649 enum GNUNET_DHT_RouteOption options; 1639 enum GNUNET_DHT_RouteOption options;
1650 struct GNUNET_CONTAINER_BloomFilter *bf; 1640 struct GNUNET_CONTAINER_BloomFilter *bf;
1651 struct GNUNET_HashCode test_key; 1641 struct GNUNET_HashCode test_key;
1652 struct GNUNET_HashCode phash;
1653 int forwarded; 1642 int forwarded;
1654 1643
1655 msize = ntohs (put->header.size); 1644 msize = ntohs (put->header.size);
@@ -1672,9 +1661,6 @@ handle_dht_p2p_put (void *cls,
1672 "PUT for `%s' from %s\n", 1661 "PUT for `%s' from %s\n",
1673 GNUNET_h2s (&put->key), 1662 GNUNET_h2s (&put->key),
1674 GNUNET_i2s (peer->id)); 1663 GNUNET_i2s (peer->id));
1675 GNUNET_CRYPTO_hash (peer->id,
1676 sizeof (struct GNUNET_PeerIdentity),
1677 &phash);
1678 if (GNUNET_YES == log_route_details_stderr) 1664 if (GNUNET_YES == log_route_details_stderr)
1679 { 1665 {
1680 char *tmp; 1666 char *tmp;
@@ -1686,7 +1672,7 @@ handle_dht_p2p_put (void *cls,
1686 GNUNET_i2s (peer->id), 1672 GNUNET_i2s (peer->id),
1687 tmp, 1673 tmp,
1688 ntohl(put->hop_count), 1674 ntohl(put->hop_count),
1689 GNUNET_CRYPTO_hash_matching_bits (&phash, 1675 GNUNET_CRYPTO_hash_matching_bits (&peer->phash,
1690 &put->key), 1676 &put->key),
1691 GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash, 1677 GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash,
1692 &put->key) 1678 &put->key)
@@ -1754,7 +1740,7 @@ handle_dht_p2p_put (void *cls,
1754 GNUNET_CONSTANTS_BLOOMFILTER_K); 1740 GNUNET_CONSTANTS_BLOOMFILTER_K);
1755 GNUNET_break_op (GNUNET_YES == 1741 GNUNET_break_op (GNUNET_YES ==
1756 GNUNET_CONTAINER_bloomfilter_test (bf, 1742 GNUNET_CONTAINER_bloomfilter_test (bf,
1757 &phash)); 1743 &peer->phash));
1758 { 1744 {
1759 struct GNUNET_PeerIdentity pp[putlen + 1]; 1745 struct GNUNET_PeerIdentity pp[putlen + 1];
1760 1746
@@ -1835,7 +1821,6 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
1835 struct PeerBucket *bucket; 1821 struct PeerBucket *bucket;
1836 struct PeerInfo *peer; 1822 struct PeerInfo *peer;
1837 unsigned int choice; 1823 unsigned int choice;
1838 struct GNUNET_HashCode phash;
1839 struct GNUNET_HashCode mhash; 1824 struct GNUNET_HashCode mhash;
1840 const struct GNUNET_HELLO_Message *hello; 1825 const struct GNUNET_HELLO_Message *hello;
1841 1826
@@ -1906,10 +1891,7 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
1906 return; /* no non-masked peer available */ 1891 return; /* no non-masked peer available */
1907 if (NULL == peer) 1892 if (NULL == peer)
1908 peer = bucket->head; 1893 peer = bucket->head;
1909 GNUNET_CRYPTO_hash (peer->id, 1894 GNUNET_BLOCK_mingle_hash (&peer->phash,
1910 sizeof (struct GNUNET_PeerIdentity),
1911 &phash);
1912 GNUNET_BLOCK_mingle_hash (&phash,
1913 bf_mutator, 1895 bf_mutator,
1914 &mhash); 1896 &mhash);
1915 hello = GDS_HELLO_get (peer->id); 1897 hello = GDS_HELLO_get (peer->id);
@@ -1976,7 +1958,6 @@ handle_dht_p2p_get (void *cls,
1976 struct GNUNET_CONTAINER_BloomFilter *reply_bf; 1958 struct GNUNET_CONTAINER_BloomFilter *reply_bf;
1977 struct GNUNET_CONTAINER_BloomFilter *peer_bf; 1959 struct GNUNET_CONTAINER_BloomFilter *peer_bf;
1978 const char *xquery; 1960 const char *xquery;
1979 struct GNUNET_HashCode phash;
1980 int forwarded; 1961 int forwarded;
1981 1962
1982 if (NULL == peer) 1963 if (NULL == peer)
@@ -2000,9 +1981,6 @@ handle_dht_p2p_get (void *cls,
2000 gettext_noop ("# P2P GET bytes received"), 1981 gettext_noop ("# P2P GET bytes received"),
2001 msize, 1982 msize,
2002 GNUNET_NO); 1983 GNUNET_NO);
2003 GNUNET_CRYPTO_hash (peer->id,
2004 sizeof (struct GNUNET_PeerIdentity),
2005 &phash);
2006 if (GNUNET_YES == log_route_details_stderr) 1984 if (GNUNET_YES == log_route_details_stderr)
2007 { 1985 {
2008 char *tmp; 1986 char *tmp;
@@ -2014,7 +1992,7 @@ handle_dht_p2p_get (void *cls,
2014 GNUNET_i2s (peer->id), 1992 GNUNET_i2s (peer->id),
2015 tmp, 1993 tmp,
2016 ntohl(get->hop_count), 1994 ntohl(get->hop_count),
2017 GNUNET_CRYPTO_hash_matching_bits (&phash, 1995 GNUNET_CRYPTO_hash_matching_bits (&peer->phash,
2018 &get->key), 1996 &get->key),
2019 GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash, 1997 GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash,
2020 &get->key), 1998 &get->key),
@@ -2052,7 +2030,7 @@ handle_dht_p2p_get (void *cls,
2052 GNUNET_CONSTANTS_BLOOMFILTER_K); 2030 GNUNET_CONSTANTS_BLOOMFILTER_K);
2053 GNUNET_break_op (GNUNET_YES == 2031 GNUNET_break_op (GNUNET_YES ==
2054 GNUNET_CONTAINER_bloomfilter_test (peer_bf, 2032 GNUNET_CONTAINER_bloomfilter_test (peer_bf,
2055 &phash)); 2033 &peer->phash));
2056 /* remember request for routing replies */ 2034 /* remember request for routing replies */
2057 GDS_ROUTING_add (peer->id, 2035 GDS_ROUTING_add (peer->id,
2058 type, 2036 type,
@@ -2164,7 +2142,7 @@ check_dht_p2p_result (void *cls,
2164 } 2142 }
2165 return GNUNET_OK; 2143 return GNUNET_OK;
2166} 2144}
2167 2145
2168 2146
2169/** 2147/**
2170 * Core handler for p2p result messages. 2148 * Core handler for p2p result messages.