Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / dht / gnunet-service-dht_neighbours.c
index 1a2fa32e4d159da90529f8390f3851a596c8e431..15071edcae97aa5492df739f437bf5e31b38ba79 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009-2016 GNUnet e.V.
+     Copyright (C) 2009-2017 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -39,7 +39,6 @@
 #include "gnunet_dht_service.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet-service-dht.h"
-#include "gnunet-service-dht_clients.h"
 #include "gnunet-service-dht_datacache.h"
 #include "gnunet-service-dht_hello.h"
 #include "gnunet-service-dht_neighbours.h"
 
 #define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__)
 
+/**
+ * Enable slow sanity checks to debug issues.
+ */
+#define SANITY_CHECKS 1
+
 /**
  * How many buckets will we allow total.
  */
@@ -281,6 +285,16 @@ struct PeerInfo
    */
   const struct GNUNET_PeerIdentity *id;
 
+  /**
+   * Hash of @e id.
+   */
+  struct GNUNET_HashCode phash;
+
+  /**
+   * Which bucket is this peer in?
+   */
+  int peer_bucket;
+
 };
 
 
@@ -587,28 +601,11 @@ update_connect_preferences ()
 }
 
 
-/**
- * Closure for #add_known_to_bloom().
- */
-struct BloomConstructorContext
-{
-  /**
-   * Bloom filter under construction.
-   */
-  struct GNUNET_CONTAINER_BloomFilter *bloom;
-
-  /**
-   * Mutator to use.
-   */
-  uint32_t bf_mutator;
-};
-
-
 /**
  * Add each of the peers we already know to the bloom filter of
  * the request so that we don't get duplicate HELLOs.
  *
- * @param cls the 'struct BloomConstructorContext'.
+ * @param cls the `struct GNUNET_BLOCK_Group`
  * @param key peer identity to add to the bloom filter
  * @param value value the peer information (unused)
  * @return #GNUNET_YES (we should continue to iterate)
@@ -618,20 +615,18 @@ add_known_to_bloom (void *cls,
                    const struct GNUNET_PeerIdentity *key,
                    void *value)
 {
-  struct BloomConstructorContext *ctx = cls;
+  struct GNUNET_BLOCK_Group *bg = cls;
   struct GNUNET_HashCode key_hash;
-  struct GNUNET_HashCode mh;
 
   GNUNET_CRYPTO_hash (key,
                       sizeof (struct GNUNET_PeerIdentity),
                       &key_hash);
-  GNUNET_BLOCK_mingle_hash (&key_hash,
-                            ctx->bf_mutator,
-                            &mh);
+  GNUNET_BLOCK_group_set_seen (bg,
+                               &key_hash,
+                               1);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Adding known peer (%s) to bloomfilter for FIND PEER with mutation %u\n",
-              GNUNET_i2s (key), ctx->bf_mutator);
-  GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, &mh);
+              "Adding known peer (%s) to bloomfilter for FIND PEER\n",
+              GNUNET_i2s (key));
   return GNUNET_YES;
 }
 
@@ -647,7 +642,7 @@ static void
 send_find_peer_message (void *cls)
 {
   struct GNUNET_TIME_Relative next_send_time;
-  struct BloomConstructorContext bcc;
+  struct GNUNET_BLOCK_Group *bg;
   struct GNUNET_CONTAINER_BloomFilter *peer_bf;
 
   find_peer_task = NULL;
@@ -661,30 +656,38 @@ send_find_peer_message (void *cls)
     newly_found_peers = 0;
     return;
   }
-  bcc.bf_mutator =
-      GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                UINT32_MAX);
-  bcc.bloom =
-      GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
-                                         GNUNET_CONSTANTS_BLOOMFILTER_K);
+  bg = GNUNET_BLOCK_group_create (GDS_block_context,
+                                  GNUNET_BLOCK_TYPE_DHT_HELLO,
+                                  GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+                                                            UINT32_MAX),
+                                  NULL,
+                                  0,
+                                  "filter-size",
+                                  DHT_BLOOM_SIZE,
+                                  NULL);
   GNUNET_CONTAINER_multipeermap_iterate (all_connected_peers,
                                          &add_known_to_bloom,
-                                         &bcc);
+                                         bg);
   GNUNET_STATISTICS_update (GDS_stats,
                             gettext_noop ("# FIND PEER messages initiated"),
                             1,
                             GNUNET_NO);
-  peer_bf =
-      GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
+  peer_bf
+    = GNUNET_CONTAINER_bloomfilter_init (NULL,
+                                         DHT_BLOOM_SIZE,
                                          GNUNET_CONSTANTS_BLOOMFILTER_K);
   // FIXME: pass priority!?
   GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO,
-                             GNUNET_DHT_RO_FIND_PEER,
-                             FIND_PEER_REPLICATION_LEVEL, 0,
-                             &my_identity_hash, NULL, 0, bcc.bloom,
-                             bcc.bf_mutator, peer_bf);
+                             GNUNET_DHT_RO_FIND_PEER | GNUNET_DHT_RO_RECORD_ROUTE,
+                             FIND_PEER_REPLICATION_LEVEL,
+                             0,
+                             &my_identity_hash,
+                             NULL,
+                             0,
+                             bg,
+                             peer_bf);
   GNUNET_CONTAINER_bloomfilter_free (peer_bf);
-  GNUNET_CONTAINER_bloomfilter_free (bcc.bloom);
+  GNUNET_BLOCK_group_destroy (bg);
   /* schedule next round */
   next_send_time.rel_value_us =
       DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value_us +
@@ -713,9 +716,7 @@ handle_core_connect (void *cls,
                      const struct GNUNET_PeerIdentity *peer,
                     struct GNUNET_MQ_Handle *mq)
 {
-  struct PeerInfo *ret;
-  struct GNUNET_HashCode phash;
-  int peer_bucket;
+  struct PeerInfo *pi;
 
   /* Check for connect to self message */
   if (0 == memcmp (&my_identity,
@@ -732,27 +733,28 @@ handle_core_connect (void *cls,
                             gettext_noop ("# peers connected"),
                             1,
                             GNUNET_NO);
+  pi = GNUNET_new (struct PeerInfo);
+  pi->id = peer;
+  pi->mq = mq;
   GNUNET_CRYPTO_hash (peer,
                      sizeof (struct GNUNET_PeerIdentity),
-                     &phash);
-  peer_bucket = find_bucket (&phash);
-  GNUNET_assert ((peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS));
-  ret = GNUNET_new (struct PeerInfo);
-  ret->id = peer;
-  ret->mq = mq;
-  GNUNET_CONTAINER_DLL_insert_tail (k_buckets[peer_bucket].head,
-                                    k_buckets[peer_bucket].tail,
-                                    ret);
-  k_buckets[peer_bucket].peers_size++;
+                     &pi->phash);
+  pi->peer_bucket = find_bucket (&pi->phash);
+  GNUNET_assert ( (pi->peer_bucket >= 0) &&
+                  (pi->peer_bucket < MAX_BUCKETS) );
+  GNUNET_CONTAINER_DLL_insert_tail (k_buckets[pi->peer_bucket].head,
+                                    k_buckets[pi->peer_bucket].tail,
+                                    pi);
+  k_buckets[pi->peer_bucket].peers_size++;
   closest_bucket = GNUNET_MAX (closest_bucket,
-                               peer_bucket);
+                               pi->peer_bucket);
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONTAINER_multipeermap_put (all_connected_peers,
-                                                    ret->id,
-                                                    ret,
+                                                    pi->id,
+                                                    pi,
                                                     GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
-  if ( (peer_bucket > 0) &&
-       (k_buckets[peer_bucket].peers_size <= bucket_size))
+  if ( (pi->peer_bucket > 0) &&
+       (k_buckets[pi->peer_bucket].peers_size <= bucket_size))
   {
     update_connect_preferences ();
     newly_found_peers++;
@@ -765,7 +767,7 @@ handle_core_connect (void *cls,
     find_peer_task = GNUNET_SCHEDULER_add_now (&send_find_peer_message,
                                                NULL);
   }
-  return ret;
+  return pi;
 }
 
 
@@ -782,8 +784,6 @@ handle_core_disconnect (void *cls,
                        void *internal_cls)
 {
   struct PeerInfo *to_remove = internal_cls;
-  int current_bucket;
-  struct GNUNET_HashCode phash;
 
   /* Check for disconnect from self message */
   if (NULL == to_remove)
@@ -805,20 +805,16 @@ handle_core_disconnect (void *cls,
     GNUNET_SCHEDULER_cancel (find_peer_task);
     find_peer_task = NULL;
   }
-  GNUNET_CRYPTO_hash (peer,
-                     sizeof (struct GNUNET_PeerIdentity),
-                     &phash);
-  current_bucket = find_bucket (&phash);
-  GNUNET_assert (current_bucket >= 0);
-  GNUNET_CONTAINER_DLL_remove (k_buckets[current_bucket].head,
-                               k_buckets[current_bucket].tail,
+  GNUNET_assert (to_remove->peer_bucket >= 0);
+  GNUNET_CONTAINER_DLL_remove (k_buckets[to_remove->peer_bucket].head,
+                               k_buckets[to_remove->peer_bucket].tail,
                                to_remove);
-  GNUNET_assert (k_buckets[current_bucket].peers_size > 0);
-  k_buckets[current_bucket].peers_size--;
+  GNUNET_assert (k_buckets[to_remove->peer_bucket].peers_size > 0);
+  k_buckets[to_remove->peer_bucket].peers_size--;
   while ( (closest_bucket > 0) &&
-          (0 == k_buckets[closest_bucket].peers_size) )
+          (0 == k_buckets[to_remove->peer_bucket].peers_size) )
     closest_bucket--;
-  if (k_buckets[current_bucket].peers_size < bucket_size)
+  if (k_buckets[to_remove->peer_bucket].peers_size < bucket_size)
     update_connect_preferences ();
   GNUNET_free (to_remove);
 }
@@ -907,7 +903,8 @@ get_distance (const struct GNUNET_HashCode *target,
 
   /* first, calculate the most significant 9 bits of our
    * result, aka the number of LSBs */
-  bucket = GNUNET_CRYPTO_hash_matching_bits (target, have);
+  bucket = GNUNET_CRYPTO_hash_matching_bits (target,
+                                             have);
   /* bucket is now a value between 0 and 512 */
   if (bucket == 512)
     return 0;                   /* perfect match */
@@ -953,28 +950,27 @@ am_closest_peer (const struct GNUNET_HashCode *key,
   int bucket_num;
   int count;
   struct PeerInfo *pos;
-  struct GNUNET_HashCode phash;
 
   if (0 == memcmp (&my_identity_hash, key, sizeof (struct GNUNET_HashCode)))
     return GNUNET_YES;
   bucket_num = find_bucket (key);
   GNUNET_assert (bucket_num >= 0);
-  bits = GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash, key);
+  bits = GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash,
+                                           key);
   pos = k_buckets[bucket_num].head;
   count = 0;
   while ((NULL != pos) && (count < bucket_size))
   {
-    GNUNET_CRYPTO_hash (pos->id,
-                       sizeof (struct GNUNET_PeerIdentity),
-                       &phash);
     if ((NULL != bloom) &&
         (GNUNET_YES ==
-         GNUNET_CONTAINER_bloomfilter_test (bloom, &phash)))
+         GNUNET_CONTAINER_bloomfilter_test (bloom,
+                                            &pos->phash)))
     {
       pos = pos->next;
       continue;                 /* Skip already checked entries */
     }
-    other_bits = GNUNET_CRYPTO_hash_matching_bits (&phash, key);
+    other_bits = GNUNET_CRYPTO_hash_matching_bits (&pos->phash,
+                                                   key);
     if (other_bits > bits)
       return GNUNET_NO;
     if (other_bits == bits)     /* We match the same number of bits */
@@ -1015,7 +1011,6 @@ select_peer (const struct GNUNET_HashCode *key,
   unsigned int dist;
   unsigned int smallest_distance;
   struct PeerInfo *chosen;
-  struct GNUNET_HashCode phash;
 
   if (hops >= GDS_NSE_get ())
   {
@@ -1028,14 +1023,13 @@ select_peer (const struct GNUNET_HashCode *key,
       count = 0;
       while ((pos != NULL) && (count < bucket_size))
       {
-       GNUNET_CRYPTO_hash (pos->id,
-                           sizeof (struct GNUNET_PeerIdentity),
-                           &phash);
-        if ((bloom == NULL) ||
-            (GNUNET_NO ==
-             GNUNET_CONTAINER_bloomfilter_test (bloom, &phash)))
+        if ( (NULL == bloom) ||
+             (GNUNET_NO ==
+              GNUNET_CONTAINER_bloomfilter_test (bloom,
+                                                 &pos->phash)))
         {
-          dist = get_distance (key, &phash);
+          dist = get_distance (key,
+                               &pos->phash);
           if (dist < smallest_distance)
           {
             chosen = pos;
@@ -1049,10 +1043,11 @@ select_peer (const struct GNUNET_HashCode *key,
                       GNUNET_i2s (pos->id),
                      GNUNET_h2s (key));
           GNUNET_STATISTICS_update (GDS_stats,
-                                    gettext_noop
-                                    ("# Peers excluded from routing due to Bloomfilter"),
-                                    1, GNUNET_NO);
-          dist = get_distance (key, &phash);
+                                    gettext_noop ("# Peers excluded from routing due to Bloomfilter"),
+                                    1,
+                                    GNUNET_NO);
+          dist = get_distance (key,
+                               &pos->phash);
           if (dist < smallest_distance)
           {
             chosen = NULL;
@@ -1065,8 +1060,14 @@ select_peer (const struct GNUNET_HashCode *key,
     }
     if (NULL == chosen)
       GNUNET_STATISTICS_update (GDS_stats,
-                                gettext_noop ("# Peer selection failed"), 1,
+                                gettext_noop ("# Peer selection failed"),
+                                1,
                                 GNUNET_NO);
+    else
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Selected peer `%s' in greedy routing for %s\n",
+                  GNUNET_i2s (chosen->id),
+                  GNUNET_h2s (key));
     return chosen;
   }
 
@@ -1076,14 +1077,12 @@ select_peer (const struct GNUNET_HashCode *key,
   for (bc = 0; bc <= closest_bucket; bc++)
   {
     pos = k_buckets[bc].head;
-    while ((pos != NULL) && (count < bucket_size))
+    while ( (NULL != pos) && (count < bucket_size) )
     {
-      GNUNET_CRYPTO_hash (pos->id,
-                         sizeof (struct GNUNET_PeerIdentity),
-                         &phash);
-      if ((bloom != NULL) &&
-          (GNUNET_YES ==
-           GNUNET_CONTAINER_bloomfilter_test (bloom, &phash)))
+      if ( (NULL != bloom) &&
+           (GNUNET_YES ==
+            GNUNET_CONTAINER_bloomfilter_test (bloom,
+                                               &pos->phash)) )
       {
         GNUNET_STATISTICS_update (GDS_stats,
                                   gettext_noop
@@ -1108,23 +1107,28 @@ select_peer (const struct GNUNET_HashCode *key,
     return NULL;
   }
   /* Now actually choose a peer */
-  selected = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, count);
+  selected = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+                                       count);
   count = 0;
   for (bc = 0; bc <= closest_bucket; bc++)
   {
     for (pos = k_buckets[bc].head; ((pos != NULL) && (count < bucket_size)); pos = pos->next)
     {
-      GNUNET_CRYPTO_hash (pos->id,
-                         sizeof (struct GNUNET_PeerIdentity),
-                         &phash);
       if ((bloom != NULL) &&
           (GNUNET_YES ==
-           GNUNET_CONTAINER_bloomfilter_test (bloom, &phash)))
+           GNUNET_CONTAINER_bloomfilter_test (bloom,
+                                              &pos->phash)))
       {
         continue;               /* Ignore bloomfiltered peers */
       }
       if (0 == selected--)
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "Selected peer `%s' in random routing for %s\n",
+                    GNUNET_i2s (pos->id),
+                    GNUNET_h2s (key));
         return pos;
+      }
     }
   }
   GNUNET_break (0);
@@ -1156,7 +1160,6 @@ get_target_peers (const struct GNUNET_HashCode *key,
   unsigned int off;
   struct PeerInfo **rtargets;
   struct PeerInfo *nxt;
-  struct GNUNET_HashCode nhash;
 
   GNUNET_assert (NULL != bloom);
   ret = get_forward_count (hop_count,
@@ -1170,17 +1173,17 @@ get_target_peers (const struct GNUNET_HashCode *key,
                               struct PeerInfo *);
   for (off = 0; off < ret; off++)
   {
-    nxt = select_peer (key, bloom, hop_count);
+    nxt = select_peer (key,
+                       bloom,
+                       hop_count);
     if (NULL == nxt)
       break;
     rtargets[off] = nxt;
-    GNUNET_CRYPTO_hash (nxt->id,
-                       sizeof (struct GNUNET_PeerIdentity),
-                       &nhash);
     GNUNET_break (GNUNET_NO ==
                   GNUNET_CONTAINER_bloomfilter_test (bloom,
-                                                     &nhash));
-    GNUNET_CONTAINER_bloomfilter_add (bloom, &nhash);
+                                                     &nxt->phash));
+    GNUNET_CONTAINER_bloomfilter_add (bloom,
+                                      &nxt->phash);
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Selected %u/%u peers at hop %u for %s (target was %u)\n",
@@ -1246,7 +1249,6 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
   struct GNUNET_MQ_Envelope *env;
   struct PeerPutMessage *ppm;
   struct GNUNET_PeerIdentity *pp;
-  struct GNUNET_HashCode thash;
   unsigned int skip_count;
 
   GNUNET_assert (NULL != bf);
@@ -1254,13 +1256,14 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
               "Adding myself (%s) to PUT bloomfilter for %s\n",
               GNUNET_i2s (&my_identity),
               GNUNET_h2s (key));
-  GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity_hash);
+  GNUNET_CONTAINER_bloomfilter_add (bf,
+                                    &my_identity_hash);
   GNUNET_STATISTICS_update (GDS_stats,
                            gettext_noop ("# PUT requests routed"),
                             1,
                            GNUNET_NO);
-  target_count =
-      get_target_peers (key,
+  target_count
+    = get_target_peers (key,
                        bf,
                        hop_count,
                        desired_replication_level,
@@ -1320,12 +1323,9 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
     ppm->desired_replication_level = htonl (desired_replication_level);
     ppm->put_path_length = htonl (put_path_length);
     ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
-    GNUNET_CRYPTO_hash (target->id,
-                       sizeof (struct GNUNET_PeerIdentity),
-                       &thash);
     GNUNET_break (GNUNET_YES ==
                   GNUNET_CONTAINER_bloomfilter_test (bf,
-                                                     &thash));
+                                                     &target->phash));
     GNUNET_assert (GNUNET_OK ==
                    GNUNET_CONTAINER_bloomfilter_get_raw_data (bf,
                                                               ppm->bloomfilter,
@@ -1359,8 +1359,7 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
  * @param key key for the content
  * @param xquery extended query
  * @param xquery_size number of bytes in @a xquery
- * @param reply_bf bloomfilter to filter duplicates
- * @param reply_bf_mutator mutator for @a reply_bf
+ * @param bg group to use for filtering replies
  * @param peer_bf filter for peers not to select (again)
  * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not
  */
@@ -1368,14 +1367,14 @@ int
 GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
                            enum GNUNET_DHT_RouteOption options,
                            uint32_t desired_replication_level,
-                           uint32_t hop_count, const struct GNUNET_HashCode * key,
-                           const void *xquery, size_t xquery_size,
-                           const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
-                           uint32_t reply_bf_mutator,
+                           uint32_t hop_count,
+                           const struct GNUNET_HashCode *key,
+                           const void *xquery,
+                           size_t xquery_size,
+                           struct GNUNET_BLOCK_Group *bg,
                            struct GNUNET_CONTAINER_BloomFilter *peer_bf)
 {
   unsigned int target_count;
-  unsigned int i;
   struct PeerInfo **targets;
   struct PeerInfo *target;
   struct GNUNET_MQ_Envelope *env;
@@ -1383,8 +1382,9 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
   struct PeerGetMessage *pgm;
   char *xq;
   size_t reply_bf_size;
-  struct GNUNET_HashCode thash;
+  void *reply_bf;
   unsigned int skip_count;
+  uint32_t bf_nonce;
 
   GNUNET_assert (NULL != peer_bf);
   GNUNET_STATISTICS_update (GDS_stats,
@@ -1411,11 +1411,22 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
                 GNUNET_i2s (&my_identity));
     return GNUNET_NO;
   }
-  reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf);
+  if (GNUNET_OK !=
+      GNUNET_BLOCK_group_serialize (bg,
+                                    &bf_nonce,
+                                    &reply_bf,
+                                    &reply_bf_size))
+  {
+    reply_bf = NULL;
+    reply_bf_size = 0;
+    bf_nonce = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+                                         UINT32_MAX);
+  }
   msize = xquery_size + reply_bf_size;
   if (msize + sizeof (struct PeerGetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
   {
     GNUNET_break (0);
+    GNUNET_free_non_null (reply_bf);
     GNUNET_free (targets);
     return GNUNET_NO;
   }
@@ -1425,7 +1436,7 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
                            GNUNET_NO);
   /* forward request */
   skip_count = 0;
-  for (i = 0; i < target_count; i++)
+  for (unsigned int i = 0; i < target_count; i++)
   {
     target = targets[i];
     if (GNUNET_MQ_get_length (target->mq) >= MAXIMUM_PENDING_PER_PEER)
@@ -1450,13 +1461,10 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
     pgm->hop_count = htonl (hop_count + 1);
     pgm->desired_replication_level = htonl (desired_replication_level);
     pgm->xquery_size = htonl (xquery_size);
-    pgm->bf_mutator = reply_bf_mutator;
-    GNUNET_CRYPTO_hash (target->id,
-                       sizeof (struct GNUNET_PeerIdentity),
-                       &thash);
+    pgm->bf_mutator = bf_nonce;
     GNUNET_break (GNUNET_YES ==
                   GNUNET_CONTAINER_bloomfilter_test (peer_bf,
-                                                     &thash));
+                                                     &target->phash));
     GNUNET_assert (GNUNET_OK ==
                    GNUNET_CONTAINER_bloomfilter_get_raw_data (peer_bf,
                                                               pgm->bloomfilter,
@@ -1466,16 +1474,14 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
     GNUNET_memcpy (xq,
                   xquery,
                   xquery_size);
-    if (NULL != reply_bf)
-      GNUNET_assert (GNUNET_OK ==
-                     GNUNET_CONTAINER_bloomfilter_get_raw_data (reply_bf,
-                                                                &xq
-                                                                [xquery_size],
-                                                                reply_bf_size));
+    GNUNET_memcpy (&xq[xquery_size],
+                   reply_bf,
+                   reply_bf_size);
     GNUNET_MQ_send (target->mq,
                    env);
   }
   GNUNET_free (targets);
+  GNUNET_free_non_null (reply_bf);
   return (skip_count < target_count) ? GNUNET_OK : GNUNET_NO;
 }
 
@@ -1597,7 +1603,7 @@ core_init (void *cls,
   GNUNET_CRYPTO_hash (identity,
                      sizeof (struct GNUNET_PeerIdentity),
                      &my_identity_hash);
-  GDS_CLIENTS_init ();
+  GNUNET_SERVICE_resume (GDS_service);
 }
 
 
@@ -1649,7 +1655,6 @@ handle_dht_p2p_put (void *cls,
   enum GNUNET_DHT_RouteOption options;
   struct GNUNET_CONTAINER_BloomFilter *bf;
   struct GNUNET_HashCode test_key;
-  struct GNUNET_HashCode phash;
   int forwarded;
 
   msize = ntohs (put->header.size);
@@ -1672,25 +1677,26 @@ handle_dht_p2p_put (void *cls,
              "PUT for `%s' from %s\n",
               GNUNET_h2s (&put->key),
              GNUNET_i2s (peer->id));
-  GNUNET_CRYPTO_hash (peer->id,
-                     sizeof (struct GNUNET_PeerIdentity),
-                     &phash);
   if (GNUNET_YES == log_route_details_stderr)
   {
     char *tmp;
+    char *pp;
 
+    pp = GNUNET_STRINGS_pp2s (put_path,
+                              putlen);
     tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
     LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
-                 "R5N PUT %s: %s->%s (%u, %u=>%u)\n",
+                 "R5N PUT %s: %s->%s (%u, %u=>%u, PP: %s)\n",
                  GNUNET_h2s (&put->key),
                  GNUNET_i2s (peer->id),
                  tmp,
                  ntohl(put->hop_count),
-                 GNUNET_CRYPTO_hash_matching_bits (&phash,
+                 GNUNET_CRYPTO_hash_matching_bits (&peer->phash,
                                                    &put->key),
                  GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash,
-                                                   &put->key)
-                );
+                                                   &put->key),
+                 pp);
+    GNUNET_free (pp);
     GNUNET_free (tmp);
   }
   switch (GNUNET_BLOCK_get_key
@@ -1727,11 +1733,12 @@ handle_dht_p2p_put (void *cls,
   {
     switch (GNUNET_BLOCK_evaluate (GDS_block_context,
                                    ntohl (put->type),
+                                   NULL, /* query group */
                                    GNUNET_BLOCK_EO_NONE,
                                    NULL,    /* query */
-                                   NULL, 0, /* bloom filer */
                                    NULL, 0, /* xquery */
-                                   payload, payload_size))
+                                   payload,
+                                   payload_size))
     {
     case GNUNET_BLOCK_EVALUATION_OK_MORE:
     case GNUNET_BLOCK_EVALUATION_OK_LAST:
@@ -1754,13 +1761,27 @@ handle_dht_p2p_put (void *cls,
                                           GNUNET_CONSTANTS_BLOOMFILTER_K);
   GNUNET_break_op (GNUNET_YES ==
                    GNUNET_CONTAINER_bloomfilter_test (bf,
-                                                     &phash));
+                                                     &peer->phash));
   {
     struct GNUNET_PeerIdentity pp[putlen + 1];
 
     /* extend 'put path' by sender */
     if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE))
     {
+#if SANITY_CHECKS
+      for (unsigned int i=0;i<=putlen;i++)
+      {
+       for (unsigned int j=0;j<i;j++)
+       {
+         GNUNET_break (0 != memcmp (&pp[i],
+                                    &pp[j],
+                                    sizeof (struct GNUNET_PeerIdentity)));
+       }
+       GNUNET_break (0 != memcmp (&pp[i],
+                                  peer->id,
+                                  sizeof (struct GNUNET_PeerIdentity)));
+      }
+#endif
       GNUNET_memcpy (pp,
                     put_path,
                     putlen * sizeof (struct GNUNET_PeerIdentity));
@@ -1783,9 +1804,13 @@ handle_dht_p2p_put (void *cls,
     /* store locally */
     if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
         (am_closest_peer (&put->key, bf)))
-      GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh
-                                (put->expiration_time), &put->key, putlen, pp,
-                                ntohl (put->type), payload_size, payload);
+      GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time),
+                                &put->key,
+                                putlen,
+                                pp,
+                                ntohl (put->type),
+                                payload_size,
+                                payload);
     /* route to other peers */
     forwarded = GDS_NEIGHBOURS_handle_put (ntohl (put->type),
                                           options,
@@ -1822,43 +1847,45 @@ handle_dht_p2p_put (void *cls,
  *
  * @param sender sender of the FIND PEER request
  * @param key peers close to this key are desired
- * @param bf peers matching this bf are excluded
- * @param bf_mutator mutator for bf
+ * @param bg group for filtering peers
  */
 static void
 handle_find_peer (const struct GNUNET_PeerIdentity *sender,
                   const struct GNUNET_HashCode *key,
-                  struct GNUNET_CONTAINER_BloomFilter *bf,
-                 uint32_t bf_mutator)
+                  struct GNUNET_BLOCK_Group *bg)
 {
   int bucket_idx;
   struct PeerBucket *bucket;
   struct PeerInfo *peer;
   unsigned int choice;
-  struct GNUNET_HashCode phash;
-  struct GNUNET_HashCode mhash;
   const struct GNUNET_HELLO_Message *hello;
+  size_t hello_size;
 
   /* first, check about our own HELLO */
   if (NULL != GDS_my_hello)
   {
-    GNUNET_BLOCK_mingle_hash (&my_identity_hash, bf_mutator, &mhash);
-    if ((NULL == bf) ||
-        (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (bf, &mhash)))
+    hello_size = GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) GDS_my_hello);
+    GNUNET_break (hello_size >= sizeof (struct GNUNET_MessageHeader));
+    if (GNUNET_BLOCK_EVALUATION_OK_MORE ==
+        GNUNET_BLOCK_evaluate (GDS_block_context,
+                               GNUNET_BLOCK_TYPE_DHT_HELLO,
+                               bg,
+                               GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO,
+                               &my_identity_hash,
+                               NULL, 0,
+                               GDS_my_hello,
+                               hello_size))
     {
       GDS_NEIGHBOURS_handle_reply (sender,
                                   GNUNET_BLOCK_TYPE_DHT_HELLO,
-                                   GNUNET_TIME_relative_to_absolute
-                                   (hello_expiration),
+                                   GNUNET_TIME_relative_to_absolute (hello_expiration),
                                    key,
                                   0,
                                   NULL,
                                   0,
                                   NULL,
                                   GDS_my_hello,
-                                   GNUNET_HELLO_size ((const struct
-                                                       GNUNET_HELLO_Message *)
-                                                      GDS_my_hello));
+                                   hello_size);
     }
     else
     {
@@ -1902,21 +1929,21 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
   do
   {
     peer = peer->next;
-    if (choice-- == 0)
+    if (0 == choice--)
       return;                   /* no non-masked peer available */
     if (NULL == peer)
       peer = bucket->head;
-    GNUNET_CRYPTO_hash (peer->id,
-                        sizeof (struct GNUNET_PeerIdentity),
-                        &phash);
-    GNUNET_BLOCK_mingle_hash (&phash,
-                              bf_mutator,
-                              &mhash);
     hello = GDS_HELLO_get (peer->id);
-  } while ( (hello == NULL) ||
-           (GNUNET_YES ==
-            GNUNET_CONTAINER_bloomfilter_test (bf,
-                                               &mhash)) );
+  } while ( (NULL == hello) ||
+            (GNUNET_BLOCK_EVALUATION_OK_MORE !=
+             GNUNET_BLOCK_evaluate (GDS_block_context,
+                                    GNUNET_BLOCK_TYPE_DHT_HELLO,
+                                    bg,
+                                    GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO,
+                                    &peer->phash,
+                                    NULL, 0,
+                                    hello,
+                                    (hello_size = GNUNET_HELLO_size (hello)))) );
   GDS_NEIGHBOURS_handle_reply (sender,
                               GNUNET_BLOCK_TYPE_DHT_HELLO,
                                GNUNET_TIME_relative_to_absolute
@@ -1927,7 +1954,53 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
                               0,
                               NULL,
                               hello,
-                               GNUNET_HELLO_size (hello));
+                               hello_size);
+}
+
+
+/**
+ * Handle a result from local datacache for a GET operation.
+ *
+ * @param cls the `struct PeerInfo` for which this is a reply
+ * @param type type of the block
+ * @param expiration_time when does the content expire
+ * @param key key for the content
+ * @param put_path_length number of entries in @a put_path
+ * @param put_path peers the original PUT traversed (if tracked)
+ * @param get_path_length number of entries in @a get_path
+ * @param get_path peers this reply has traversed so far (if tracked)
+ * @param data payload of the reply
+ * @param data_size number of bytes in @a data
+ */
+static void
+handle_local_result (void *cls,
+                     enum GNUNET_BLOCK_Type type,
+                     struct GNUNET_TIME_Absolute expiration_time,
+                     const struct GNUNET_HashCode *key,
+                     unsigned int put_path_length,
+                     const struct GNUNET_PeerIdentity *put_path,
+                     unsigned int get_path_length,
+                     const struct GNUNET_PeerIdentity *get_path,
+                     const void *data,
+                     size_t data_size)
+{
+  struct PeerInfo *peer = cls;
+  char *pp;
+
+  pp = GNUNET_STRINGS_pp2s (put_path,
+                            put_path_length);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Found local result for %s (PP: %s)\n",
+              GNUNET_h2s (key),
+              pp);
+  GNUNET_free (pp);
+  GDS_NEIGHBOURS_handle_reply (peer->id,
+                               type,
+                               expiration_time,
+                               key,
+                               put_path_length, put_path,
+                               get_path_length, get_path,
+                               data, data_size);
 }
 
 
@@ -1973,17 +2046,11 @@ handle_dht_p2p_get (void *cls,
   enum GNUNET_BLOCK_Type type;
   enum GNUNET_DHT_RouteOption options;
   enum GNUNET_BLOCK_EvaluationResult eval;
-  struct GNUNET_CONTAINER_BloomFilter *reply_bf;
+  struct GNUNET_BLOCK_Group *bg;
   struct GNUNET_CONTAINER_BloomFilter *peer_bf;
   const char *xquery;
-  struct GNUNET_HashCode phash;
   int forwarded;
 
-  if (NULL == peer)
-  {
-    GNUNET_break (0);
-    return;
-  }
   /* parse and validate message */
   msize = ntohs (get->header.size);
   xquery_size = ntohl (get->xquery_size);
@@ -1991,7 +2058,6 @@ handle_dht_p2p_get (void *cls,
   type = ntohl (get->type);
   options = ntohl (get->options);
   xquery = (const char *) &get[1];
-  reply_bf = NULL;
   GNUNET_STATISTICS_update (GDS_stats,
                             gettext_noop ("# P2P GET requests received"),
                            1,
@@ -2000,9 +2066,6 @@ handle_dht_p2p_get (void *cls,
                             gettext_noop ("# P2P GET bytes received"),
                            msize,
                             GNUNET_NO);
-  GNUNET_CRYPTO_hash (peer->id,
-                      sizeof (struct GNUNET_PeerIdentity),
-                      &phash);
   if (GNUNET_YES == log_route_details_stderr)
   {
     char *tmp;
@@ -2014,7 +2077,7 @@ handle_dht_p2p_get (void *cls,
                 GNUNET_i2s (peer->id),
                 tmp,
                  ntohl(get->hop_count),
-                 GNUNET_CRYPTO_hash_matching_bits (&phash,
+                 GNUNET_CRYPTO_hash_matching_bits (&peer->phash,
                                                   &get->key),
                  GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash,
                                                   &get->key),
@@ -2022,19 +2085,12 @@ handle_dht_p2p_get (void *cls,
                 xquery);
     GNUNET_free (tmp);
   }
-
-  if (reply_bf_size > 0)
-    reply_bf =
-        GNUNET_CONTAINER_bloomfilter_init (&xquery[xquery_size],
-                                          reply_bf_size,
-                                           GNUNET_CONSTANTS_BLOOMFILTER_K);
-  eval =
-      GNUNET_BLOCK_evaluate (GDS_block_context,
+  eval
+    = GNUNET_BLOCK_evaluate (GDS_block_context,
                              type,
+                             NULL,
                              GNUNET_BLOCK_EO_NONE,
                              &get->key,
-                             &reply_bf,
-                             get->bf_mutator,
                              xquery,
                              xquery_size,
                              NULL,
@@ -2043,8 +2099,6 @@ handle_dht_p2p_get (void *cls,
   {
     /* request invalid or block type not supported */
     GNUNET_break_op (eval == GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED);
-    if (NULL != reply_bf)
-      GNUNET_CONTAINER_bloomfilter_free (reply_bf);
     return;
   }
   peer_bf = GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter,
@@ -2052,16 +2106,15 @@ handle_dht_p2p_get (void *cls,
                                               GNUNET_CONSTANTS_BLOOMFILTER_K);
   GNUNET_break_op (GNUNET_YES ==
                    GNUNET_CONTAINER_bloomfilter_test (peer_bf,
-                                                      &phash));
-  /* remember request for routing replies */
-  GDS_ROUTING_add (peer->id,
-                  type,
-                  options,
-                  &get->key,
-                  xquery,
-                  xquery_size,
-                   reply_bf,
-                  get->bf_mutator);
+                                                      &peer->phash));
+  bg = GNUNET_BLOCK_group_create (GDS_block_context,
+                                  type,
+                                  get->bf_mutator,
+                                  &xquery[xquery_size],
+                                  reply_bf_size,
+                                  "filter-size",
+                                  reply_bf_size,
+                                  NULL);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "GET for %s at %s after %u hops\n",
               GNUNET_h2s (&get->key),
@@ -2080,8 +2133,7 @@ handle_dht_p2p_get (void *cls,
                                 GNUNET_NO);
       handle_find_peer (peer->id,
                        &get->key,
-                       reply_bf,
-                       get->bf_mutator);
+                       bg);
     }
     else
     {
@@ -2089,8 +2141,9 @@ handle_dht_p2p_get (void *cls,
                                       type,
                                       xquery,
                                       xquery_size,
-                                      &reply_bf,
-                                      get->bf_mutator);
+                                       bg,
+                                       &handle_local_result,
+                                       peer);
     }
   }
   else
@@ -2101,6 +2154,15 @@ handle_dht_p2p_get (void *cls,
                              GNUNET_NO);
   }
 
+  /* remember request for routing replies */
+  GDS_ROUTING_add (peer->id,
+                        type,
+                        bg, /* bg now owned by routing, but valid at least until end of this function! */
+                        options,
+                        &get->key,
+                        xquery,
+                        xquery_size);
+
   /* P2P forwarding */
   forwarded = GNUNET_NO;
   if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
@@ -2111,8 +2173,7 @@ handle_dht_p2p_get (void *cls,
                                            &get->key,
                                            xquery,
                                            xquery_size,
-                                           reply_bf,
-                                           get->bf_mutator,
+                                           bg,
                                           peer_bf);
   GDS_CLIENTS_process_get (options
                            | (GNUNET_OK == forwarded)
@@ -2124,10 +2185,7 @@ handle_dht_p2p_get (void *cls,
                           NULL,
                            &get->key);
 
-
-  /* clean up */
-  if (NULL != reply_bf)
-    GNUNET_CONTAINER_bloomfilter_free (reply_bf);
+  /* clean up; note that 'bg' is owned by routing now! */
   GNUNET_CONTAINER_bloomfilter_free (peer_bf);
 }
 
@@ -2164,7 +2222,82 @@ check_dht_p2p_result (void *cls,
   }
   return GNUNET_OK;
 }
-  
+
+
+/**
+ * Process a reply, after the @a get_path has been updated.
+ *
+ * @param expiration_time when does the reply expire
+ * @param key key matching the query
+ * @param get_path_length number of entries in @a get_path
+ * @param get_path path the reply has taken
+ * @param put_path_length number of entries in @a put_path
+ * @param put_path path the PUT has taken
+ * @param type type of the block
+ * @param data_size number of bytes in @a data
+ * @param data payload of the reply
+ */
+static void
+process_reply_with_path (struct GNUNET_TIME_Absolute expiration_time,
+                         const struct GNUNET_HashCode *key,
+                         unsigned int get_path_length,
+                         const struct GNUNET_PeerIdentity *get_path,
+                         unsigned int put_path_length,
+                         const struct GNUNET_PeerIdentity *put_path,
+                         enum GNUNET_BLOCK_Type type,
+                         size_t data_size,
+                         const void *data)
+{
+  /* forward to local clients */
+  GDS_CLIENTS_handle_reply (expiration_time,
+                            key,
+                            get_path_length,
+                            get_path,
+                            put_path_length,
+                            put_path,
+                            type,
+                            data_size,
+                            data);
+  GDS_CLIENTS_process_get_resp (type,
+                                get_path,
+                                get_path_length,
+                                put_path,
+                                put_path_length,
+                                expiration_time,
+                                key,
+                                data,
+                                data_size);
+  if (GNUNET_YES == cache_results)
+  {
+    struct GNUNET_PeerIdentity xput_path[get_path_length + 1 + put_path_length];
+
+    GNUNET_memcpy (xput_path,
+                   put_path,
+                   put_path_length * sizeof (struct GNUNET_PeerIdentity));
+    GNUNET_memcpy (&xput_path[put_path_length],
+                   get_path,
+                   get_path_length * sizeof (struct GNUNET_PeerIdentity));
+
+    GDS_DATACACHE_handle_put (expiration_time,
+                              key,
+                              get_path_length + put_path_length,
+                              xput_path,
+                              type,
+                              data_size,
+                              data);
+  }
+  /* forward to other peers */
+  GDS_ROUTING_process (type,
+                       expiration_time,
+                       key,
+                       put_path_length,
+                       put_path,
+                       get_path_length,
+                       get_path,
+                       data,
+                       data_size);
+}
+
 
 /**
  * Core handler for p2p result messages.
@@ -2208,14 +2341,23 @@ handle_dht_p2p_result (void *cls,
   if (GNUNET_YES == log_route_details_stderr)
   {
     char *tmp;
+    char *pp;
+    char *gp;
 
+    gp = GNUNET_STRINGS_pp2s (get_path,
+                              get_path_length);
+    pp = GNUNET_STRINGS_pp2s (put_path,
+                              put_path_length);
     tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
     LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
-                 "R5N RESULT %s: %s->%s (%u)\n",
+                 "R5N RESULT %s: %s->%s (GP: %s, PP: %s)\n",
                  GNUNET_h2s (&prm->key),
                  GNUNET_i2s (peer->id),
                  tmp,
-                 get_path_length + 1);
+                 gp,
+                 pp);
+    GNUNET_free (gp);
+    GNUNET_free (pp);
     GNUNET_free (tmp);
   }
   /* if we got a HELLO, consider it for our own routing table */
@@ -2251,7 +2393,27 @@ handle_dht_p2p_result (void *cls,
                    h);
   }
 
-  /* append 'peer' to 'get_path' */
+
+  /* First, check if 'peer' is already on the path, and if
+     so, truncate it instead of expanding. */
+  for (unsigned int i=0;i<=get_path_length;i++)
+    if (0 == memcmp (&get_path[i],
+                     peer->id,
+                     sizeof (struct GNUNET_PeerIdentity)))
+    {
+      process_reply_with_path (GNUNET_TIME_absolute_ntoh (prm->expiration_time),
+                               &prm->key,
+                               i,
+                               get_path,
+                               put_path_length,
+                               put_path,
+                               type,
+                               data_size,
+                               data);
+      return;
+    }
+
+  /* Need to append 'peer' to 'get_path' (normal case) */
   {
     struct GNUNET_PeerIdentity xget_path[get_path_length + 1];
 
@@ -2259,55 +2421,16 @@ handle_dht_p2p_result (void *cls,
                   get_path,
                   get_path_length * sizeof (struct GNUNET_PeerIdentity));
     xget_path[get_path_length] = *peer->id;
-    get_path_length++;
-
-    /* forward to local clients */
-    GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (prm->expiration_time),
-                              &prm->key,
-                              get_path_length,
-                              xget_path,
-                              put_path_length,
-                              put_path,
-                              type,
-                              data_size,
-                              data);
-    GDS_CLIENTS_process_get_resp (type,
-                                  xget_path,
-                                  get_path_length,
-                                  put_path, put_path_length,
-                                  GNUNET_TIME_absolute_ntoh (prm->expiration_time),
-                                  &prm->key,
-                                  data,
-                                  data_size);
-    if (GNUNET_YES == cache_results)
-    {
-      struct GNUNET_PeerIdentity xput_path[get_path_length + 1 + put_path_length];
 
-      GNUNET_memcpy (xput_path,
-                    put_path,
-                    put_path_length * sizeof (struct GNUNET_PeerIdentity));
-      GNUNET_memcpy (&xput_path[put_path_length],
-                    xget_path,
-                    get_path_length * sizeof (struct GNUNET_PeerIdentity));
-
-      GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (prm->expiration_time),
-                               &prm->key,
-                               get_path_length + put_path_length,
-                                xput_path,
-                               type,
-                                data_size,
-                                data);
-    }
-    /* forward to other peers */
-    GDS_ROUTING_process (type,
-                         GNUNET_TIME_absolute_ntoh (prm->expiration_time),
-                         &prm->key,
-                         put_path_length,
-                         put_path,
-                         get_path_length,
-                         xget_path,
-                         data,
-                         data_size);
+    process_reply_with_path (GNUNET_TIME_absolute_ntoh (prm->expiration_time),
+                             &prm->key,
+                             get_path_length + 1,
+                             xget_path,
+                             put_path_length,
+                             put_path,
+                             type,
+                             data_size,
+                             data);
   }
 }
 
@@ -2320,19 +2443,19 @@ handle_dht_p2p_result (void *cls,
 int
 GDS_NEIGHBOURS_init ()
 {
-  GNUNET_MQ_hd_var_size (dht_p2p_get,
-                        GNUNET_MESSAGE_TYPE_DHT_P2P_GET,
-                        struct PeerGetMessage);
-  GNUNET_MQ_hd_var_size (dht_p2p_put,
-                        GNUNET_MESSAGE_TYPE_DHT_P2P_PUT,
-                        struct PeerPutMessage);
-  GNUNET_MQ_hd_var_size (dht_p2p_result,
-                        GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT,
-                        struct PeerResultMessage);
   struct GNUNET_MQ_MessageHandler core_handlers[] = {
-    make_dht_p2p_get_handler (NULL),
-    make_dht_p2p_put_handler (NULL),
-    make_dht_p2p_result_handler (NULL),
+    GNUNET_MQ_hd_var_size (dht_p2p_get,
+                           GNUNET_MESSAGE_TYPE_DHT_P2P_GET,
+                           struct PeerGetMessage,
+                           NULL),
+    GNUNET_MQ_hd_var_size (dht_p2p_put,
+                           GNUNET_MESSAGE_TYPE_DHT_P2P_PUT,
+                           struct PeerPutMessage,
+                           NULL),
+    GNUNET_MQ_hd_var_size (dht_p2p_result,
+                           GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT,
+                           struct PeerResultMessage,
+                           NULL),
     GNUNET_MQ_handler_end ()
   };
   unsigned long long temp_config_num;
@@ -2355,7 +2478,7 @@ GDS_NEIGHBOURS_init ()
   log_route_details_stderr =
     (NULL != getenv("GNUNET_DHT_ROUTE_DEBUG")) ? GNUNET_YES : GNUNET_NO;
   ats_ch = GNUNET_ATS_connectivity_init (GDS_cfg);
-  core_api = GNUNET_CORE_connecT (GDS_cfg,
+  core_api = GNUNET_CORE_connect (GDS_cfg,
                                  NULL,
                                  &core_init,
                                  &handle_core_connect,
@@ -2379,7 +2502,7 @@ GDS_NEIGHBOURS_done ()
 {
   if (NULL == core_api)
     return;
-  GNUNET_CORE_disconnecT (core_api);
+  GNUNET_CORE_disconnect (core_api);
   core_api = NULL;
   GNUNET_assert (0 ==
                 GNUNET_CONTAINER_multipeermap_size (all_connected_peers));