-passing total trust offered along (fixing #1369)
authorChristian Grothoff <christian@grothoff.org>
Sat, 23 Jun 2012 08:35:49 +0000 (08:35 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 23 Jun 2012 08:35:49 +0000 (08:35 +0000)
src/fs/fs.h
src/fs/fs_download.c
src/fs/fs_search.c
src/fs/gnunet-service-fs_lc.c
src/fs/gnunet-service-fs_pr.c
src/fs/gnunet-service-fs_pr.h
src/include/gnunet_fs_service.h

index 3aa9fcc1b0efef97d6ff9df623e60926a931a1c2..ffd448d2b88b6858426bde1b2b6f8f1751bf820f 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
+     (C) 2003--2012 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -321,6 +321,18 @@ struct ClientPutMessage
    */
   struct GNUNET_TIME_AbsoluteNBO last_transmission;
 
+  /**
+   * How often did we transmit this query before getting an
+   * answer (estimate).
+   */
+  uint32_t num_transmissions;
+
+  /**
+   * How much respect did we offer (in total) before getting an
+   * answer (estimate).
+   */
+  uint32_t respect_offered;
+
   /* this is followed by the actual encrypted content */
 
 };
index 2e1633c8e430735850a586bed71c8e92778ad9a8..3434a95537f479b2903343f4c60fdb10877972b8 100644 (file)
@@ -165,6 +165,11 @@ struct ProcessResultClosure
    */
   struct GNUNET_FS_DownloadContext *dc;
 
+  /**
+   * When did we last transmit the request?
+   */
+  struct GNUNET_TIME_Absolute last_transmission;
+
   /**
    * Number of bytes in data.
    */
@@ -181,9 +186,14 @@ struct ProcessResultClosure
   int do_store;
 
   /**
-   * When did we last transmit the request?
+   * how much respect did we offer to get this reply?
    */
-  struct GNUNET_TIME_Absolute last_transmission;
+  uint32_t respect_offered;
+
+  /**
+   * how often did we transmit the query?
+   */
+  uint32_t num_transmissions;
 
 };
 
@@ -1069,7 +1079,8 @@ process_result_with_request (void *cls, const struct GNUNET_HashCode * key,
   pi.value.download.specifics.progress.offset = dr->offset;
   pi.value.download.specifics.progress.data_len = prc->size;
   pi.value.download.specifics.progress.depth = dr->depth;
-  pi.value.download.specifics.progress.respect_offered = 0;
+  pi.value.download.specifics.progress.respect_offered = prc->respect_offered;
+  pi.value.download.specifics.progress.num_transmissions = prc->num_transmissions;
   if (prc->last_transmission.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
     pi.value.download.specifics.progress.block_download_duration 
       = GNUNET_TIME_absolute_get_duration (prc->last_transmission);
@@ -1195,6 +1206,8 @@ signal_error:
  *
  * @param dc our download context
  * @param type type of the result
+ * @param respect_offered how much respect did we offer to get this reply?
+ * @param num_transmissions how often did we transmit the query?
  * @param last_transmission when was this block requested the last time? (FOREVER if unknown/not applicable)
  * @param data the (encrypted) response
  * @param size size of data
@@ -1202,6 +1215,8 @@ signal_error:
 static void
 process_result (struct GNUNET_FS_DownloadContext *dc,
                 enum GNUNET_BLOCK_Type type,
+               uint32_t respect_offered,
+               uint32_t num_transmissions,
                 struct GNUNET_TIME_Absolute last_transmission,
                 const void *data, size_t size)
 {
@@ -1209,10 +1224,12 @@ process_result (struct GNUNET_FS_DownloadContext *dc,
 
   prc.dc = dc;
   prc.data = data;
+  prc.last_transmission = last_transmission;
   prc.size = size;
   prc.type = type;
   prc.do_store = GNUNET_YES;
-  prc.last_transmission = last_transmission;
+  prc.respect_offered = respect_offered;
+  prc.num_transmissions = num_transmissions;
   GNUNET_CRYPTO_hash (data, size, &prc.query);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received result for query `%s' from `%s'-service\n",
@@ -1247,6 +1264,8 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg)
   msize = ntohs (msg->size);
   cm = (const struct ClientPutMessage *) msg;
   process_result (dc, ntohl (cm->type),
+                 ntohl (cm->respect_offered),
+                 ntohl (cm->num_transmissions),
                   GNUNET_TIME_absolute_ntoh (cm->last_transmission), &cm[1],
                   msize - sizeof (struct ClientPutMessage));
   if (NULL == dc->client)
index 542d8f2e9908e4b6ad5cd9abee79638bdb9eb3cb..d3ceead77e00df8cb60cda82ed1905da467a53e3 100644 (file)
@@ -762,7 +762,8 @@ process_sblock (struct GNUNET_FS_SearchContext *sc, const struct SBlock *sb,
  */
 static void
 process_result (struct GNUNET_FS_SearchContext *sc, enum GNUNET_BLOCK_Type type,
-                struct GNUNET_TIME_Absolute expiration, const void *data,
+                struct GNUNET_TIME_Absolute expiration, 
+               const void *data,
                 size_t size)
 {
   if (GNUNET_TIME_absolute_get_duration (expiration).rel_value > 0)
index f3b18256b1b1e320ee333c6c559097d084c2c607..b378580286568e1ac1865846a516347f93c3e1f9 100644 (file)
@@ -267,6 +267,8 @@ client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
     pm->type = htonl (type);
     pm->expiration = GNUNET_TIME_absolute_hton (expiration);
     pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission);
+    pm->num_transmissions = htonl (prd->num_transmissions);
+    pm->respect_offered = htonl (prd->respect_offered);
     memcpy (&pm[1], data, data_len);
     GSF_local_client_transmit_ (lc, &pm->header);
   }
index 2893481f2a28252fa2cc4390c3b159c9ca0f80cf..3c12edfb9b1e7b8dfa241210f5f82be5b0f91166 100644 (file)
@@ -530,6 +530,8 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
   else
     prio = 0;
   pr->public_data.priority -= prio;
+  pr->public_data.num_transmissions++;
+  pr->public_data.respect_offered += prio;
   gm->priority = htonl (prio);
   now = GNUNET_TIME_absolute_get ();
   ttl = (int64_t) (pr->public_data.ttl.abs_value - now.abs_value);
index ab088f88f413275f6ef43d1a1fb3bce036b98bf3..10bc5c1f3d9eb26c8e8b8f8bf005902ed2c554fa 100644 (file)
@@ -132,6 +132,22 @@ struct GSF_PendingRequestData
    */
   uint32_t original_priority;
 
+  /**
+   * Counter for how often this request has been transmitted (estimate,
+   * because we might have the same request pending for multiple clients,
+   * and of course because a transmission may have failed at a lower
+   * layer).
+   */
+  uint32_t num_transmissions;
+
+  /**
+   * How much respect did we (in total) offer for this request so far (estimate,
+   * because we might have the same request pending for multiple clients,
+   * and of course because a transmission may have failed at a lower
+   * layer).
+   */
+  uint32_t respect_offered;
+
   /**
    * Options for the request.
    */
index 4b7e726ddf144c21f418545b0abde358b3e982be..f93f4e856a710513a459008d5ba5a42f22a2df65 100644 (file)
@@ -1017,6 +1017,12 @@ struct GNUNET_FS_ProgressInfo
           */
           uint64_t data_len;
 
+          /**
+          * How much time passed between us asking for this block and
+           * actually getting it? GNUNET_TIME_UNIT_FOREVER_REL if unknown.
+          */
+          struct GNUNET_TIME_Relative block_download_duration;
+
           /**
           * Depth of the given block in the tree;
           * 0 would be the lowest level (DBLOCKS).
@@ -1024,15 +1030,20 @@ struct GNUNET_FS_ProgressInfo
           unsigned int depth;
 
           /**
-          * How much respect did we offer for downloading this block?
+          * How much respect did we offer for downloading this block? (estimate,
+          * because we might have the same request pending for multiple clients,
+          * and of course because a transmission may have failed at a lower
+          * layer).
           */
-          unsigned int respect_offered;
+          uint32_t respect_offered;
 
           /**
-          * How much time passed between us asking for this block and
-           * actually getting it? GNUNET_TIME_UNIT_FOREVER_REL if unknown.
+          * How often did we transmit the request? (estimate,
+          * because we might have the same request pending for multiple clients,
+          * and of course because a transmission may have failed at a lower
+          * layer).
           */
-          struct GNUNET_TIME_Relative block_download_duration;
+          uint32_t num_transmissions;
 
         } progress;