- update default values, eliminate obsolete ones
[oweals/gnunet.git] / src / dht / gnunet-service-xdht_datacache.c
index df2e17187a75597ec87c6cbbe1f051c0357a162a..6d13e344dc6a49365ca81f00c147ae2e640ea2c9 100644 (file)
@@ -148,22 +148,22 @@ struct GetRequestContext
   enum GNUNET_BLOCK_EvaluationResult eval;
   
   /**
-   *
+   * Peeer which has the data for the key.
    */
-  unsigned int current_trail_index;
+  struct GNUNET_PeerIdentity source_peer;
   
   /**
-   *
+   * Next hop to forward the get result to.
    */
   struct GNUNET_PeerIdentity next_hop;
   
   /**
-   * Head of trail to reach this finger.
+   * Head of get path.
    */
   struct GetPath *head;
   
   /**
-   * Tail of trail to reach this finger.
+   * Tail of get path.
    */
   struct GetPath *tail;
   /* get_path */
@@ -188,9 +188,9 @@ static int
 datacache_get_iterator (void *cls,
                         const struct GNUNET_HashCode * key, size_t size,
                         const char *data, enum GNUNET_BLOCK_Type type,
-                       struct GNUNET_TIME_Absolute exp,
-                       unsigned int put_path_length,
-                       const struct GNUNET_PeerIdentity *put_path)
+                                         struct GNUNET_TIME_Absolute exp,
+                                         unsigned int put_path_length,
+                                         const struct GNUNET_PeerIdentity *put_path)
 {
   struct GetRequestContext *ctx = cls;
   enum GNUNET_BLOCK_EvaluationResult eval;
@@ -223,13 +223,10 @@ datacache_get_iterator (void *cls,
       i++;
       iterator = iterator->next;
     }
-    GDS_NEIGHBOURS_send_get_result (exp, key, put_path_length, put_path,
-                                    type, size, data, get_path, ctx->get_path_length,
-                                    ctx->current_trail_index, &(ctx->next_hop));
+    GDS_NEIGHBOURS_send_get_result (key,type, &(ctx->next_hop),&(ctx->source_peer),
+                                    put_path_length, put_path, ctx->get_path_length,
+                                    get_path, exp, data, size );
     
-    /* forward to other peers */
-    GDS_ROUTING_process (type, exp, key, put_path_length, put_path, 0, NULL,
-                         data, size);
     break;
   case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
     GNUNET_STATISTICS_update (GDS_stats,
@@ -289,8 +286,8 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key,
                           uint32_t reply_bf_mutator,
                           uint32_t get_path_length,
                           struct GNUNET_PeerIdentity *get_path,
-                          unsigned int current_trail_index,
-                          struct GNUNET_PeerIdentity *next_hop)
+                          struct GNUNET_PeerIdentity *next_hop,
+                          struct GNUNET_PeerIdentity *source_peer)
 {
   struct GetRequestContext ctx;
   unsigned int r;
@@ -307,20 +304,24 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key,
   ctx.reply_bf = reply_bf;
   ctx.reply_bf_mutator = reply_bf_mutator;
   ctx.get_path_length = get_path_length;
-  memcpy (&(ctx.next_hop), next_hop, sizeof (struct GNUNET_PeerIdentity));
-  ctx.current_trail_index = current_trail_index;
-  /* FIXME: add the get path into ctx and then call gds_neighbours_handle_get*/
+  if (next_hop != NULL)
+    memcpy (&(ctx.next_hop), next_hop, sizeof (struct GNUNET_PeerIdentity));
   int i = 0;
-  while (i < get_path_length)
+
+  if(get_path != NULL)
   {
-    struct GetPath *element;
-    element = GNUNET_malloc (sizeof (struct GetPath));
-    element->next = NULL;
-    element->prev = NULL;
+    while (i < get_path_length)
+    {
+      struct GetPath *element;
+      element = GNUNET_malloc (sizeof (struct GetPath));
+      element->next = NULL;
+      element->prev = NULL;
     
-    memcpy (&(element->peer), &get_path[i], sizeof(struct GNUNET_PeerIdentity));
-    GNUNET_CONTAINER_DLL_insert_tail(ctx.head, ctx.tail, element);
-    i++;
+      memcpy (&(element->peer), &get_path[i], sizeof(struct GNUNET_PeerIdentity));
+      GNUNET_CONTAINER_DLL_insert (ctx.head, ctx.tail, element); 
+      i++;
+    }
   }
   
   r = GNUNET_DATACACHE_get (datacache, key, type, &datacache_get_iterator,