aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-23 08:35:49 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-23 08:35:49 +0000
commitc00ade9abf751ea2157f1f78dd834257fe19ed6c (patch)
tree0eebb88f356ba98fce52398dcea22a89011d7e6d /src/fs
parent8f850cddd40436aa9f5a3ec82606dd5bceebef3d (diff)
downloadgnunet-c00ade9abf751ea2157f1f78dd834257fe19ed6c.tar.gz
gnunet-c00ade9abf751ea2157f1f78dd834257fe19ed6c.zip
-passing total trust offered along (fixing #1369)
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs.h14
-rw-r--r--src/fs/fs_download.c27
-rw-r--r--src/fs/fs_search.c3
-rw-r--r--src/fs/gnunet-service-fs_lc.c2
-rw-r--r--src/fs/gnunet-service-fs_pr.c2
-rw-r--r--src/fs/gnunet-service-fs_pr.h16
6 files changed, 58 insertions, 6 deletions
diff --git a/src/fs/fs.h b/src/fs/fs.h
index 3aa9fcc1b..ffd448d2b 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2003--2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -321,6 +321,18 @@ struct ClientPutMessage
321 */ 321 */
322 struct GNUNET_TIME_AbsoluteNBO last_transmission; 322 struct GNUNET_TIME_AbsoluteNBO last_transmission;
323 323
324 /**
325 * How often did we transmit this query before getting an
326 * answer (estimate).
327 */
328 uint32_t num_transmissions;
329
330 /**
331 * How much respect did we offer (in total) before getting an
332 * answer (estimate).
333 */
334 uint32_t respect_offered;
335
324 /* this is followed by the actual encrypted content */ 336 /* this is followed by the actual encrypted content */
325 337
326}; 338};
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 2e1633c8e..3434a9553 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -166,6 +166,11 @@ struct ProcessResultClosure
166 struct GNUNET_FS_DownloadContext *dc; 166 struct GNUNET_FS_DownloadContext *dc;
167 167
168 /** 168 /**
169 * When did we last transmit the request?
170 */
171 struct GNUNET_TIME_Absolute last_transmission;
172
173 /**
169 * Number of bytes in data. 174 * Number of bytes in data.
170 */ 175 */
171 size_t size; 176 size_t size;
@@ -181,9 +186,14 @@ struct ProcessResultClosure
181 int do_store; 186 int do_store;
182 187
183 /** 188 /**
184 * When did we last transmit the request? 189 * how much respect did we offer to get this reply?
185 */ 190 */
186 struct GNUNET_TIME_Absolute last_transmission; 191 uint32_t respect_offered;
192
193 /**
194 * how often did we transmit the query?
195 */
196 uint32_t num_transmissions;
187 197
188}; 198};
189 199
@@ -1069,7 +1079,8 @@ process_result_with_request (void *cls, const struct GNUNET_HashCode * key,
1069 pi.value.download.specifics.progress.offset = dr->offset; 1079 pi.value.download.specifics.progress.offset = dr->offset;
1070 pi.value.download.specifics.progress.data_len = prc->size; 1080 pi.value.download.specifics.progress.data_len = prc->size;
1071 pi.value.download.specifics.progress.depth = dr->depth; 1081 pi.value.download.specifics.progress.depth = dr->depth;
1072 pi.value.download.specifics.progress.respect_offered = 0; 1082 pi.value.download.specifics.progress.respect_offered = prc->respect_offered;
1083 pi.value.download.specifics.progress.num_transmissions = prc->num_transmissions;
1073 if (prc->last_transmission.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) 1084 if (prc->last_transmission.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
1074 pi.value.download.specifics.progress.block_download_duration 1085 pi.value.download.specifics.progress.block_download_duration
1075 = GNUNET_TIME_absolute_get_duration (prc->last_transmission); 1086 = GNUNET_TIME_absolute_get_duration (prc->last_transmission);
@@ -1195,6 +1206,8 @@ signal_error:
1195 * 1206 *
1196 * @param dc our download context 1207 * @param dc our download context
1197 * @param type type of the result 1208 * @param type type of the result
1209 * @param respect_offered how much respect did we offer to get this reply?
1210 * @param num_transmissions how often did we transmit the query?
1198 * @param last_transmission when was this block requested the last time? (FOREVER if unknown/not applicable) 1211 * @param last_transmission when was this block requested the last time? (FOREVER if unknown/not applicable)
1199 * @param data the (encrypted) response 1212 * @param data the (encrypted) response
1200 * @param size size of data 1213 * @param size size of data
@@ -1202,6 +1215,8 @@ signal_error:
1202static void 1215static void
1203process_result (struct GNUNET_FS_DownloadContext *dc, 1216process_result (struct GNUNET_FS_DownloadContext *dc,
1204 enum GNUNET_BLOCK_Type type, 1217 enum GNUNET_BLOCK_Type type,
1218 uint32_t respect_offered,
1219 uint32_t num_transmissions,
1205 struct GNUNET_TIME_Absolute last_transmission, 1220 struct GNUNET_TIME_Absolute last_transmission,
1206 const void *data, size_t size) 1221 const void *data, size_t size)
1207{ 1222{
@@ -1209,10 +1224,12 @@ process_result (struct GNUNET_FS_DownloadContext *dc,
1209 1224
1210 prc.dc = dc; 1225 prc.dc = dc;
1211 prc.data = data; 1226 prc.data = data;
1227 prc.last_transmission = last_transmission;
1212 prc.size = size; 1228 prc.size = size;
1213 prc.type = type; 1229 prc.type = type;
1214 prc.do_store = GNUNET_YES; 1230 prc.do_store = GNUNET_YES;
1215 prc.last_transmission = last_transmission; 1231 prc.respect_offered = respect_offered;
1232 prc.num_transmissions = num_transmissions;
1216 GNUNET_CRYPTO_hash (data, size, &prc.query); 1233 GNUNET_CRYPTO_hash (data, size, &prc.query);
1217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1218 "Received result for query `%s' from `%s'-service\n", 1235 "Received result for query `%s' from `%s'-service\n",
@@ -1247,6 +1264,8 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg)
1247 msize = ntohs (msg->size); 1264 msize = ntohs (msg->size);
1248 cm = (const struct ClientPutMessage *) msg; 1265 cm = (const struct ClientPutMessage *) msg;
1249 process_result (dc, ntohl (cm->type), 1266 process_result (dc, ntohl (cm->type),
1267 ntohl (cm->respect_offered),
1268 ntohl (cm->num_transmissions),
1250 GNUNET_TIME_absolute_ntoh (cm->last_transmission), &cm[1], 1269 GNUNET_TIME_absolute_ntoh (cm->last_transmission), &cm[1],
1251 msize - sizeof (struct ClientPutMessage)); 1270 msize - sizeof (struct ClientPutMessage));
1252 if (NULL == dc->client) 1271 if (NULL == dc->client)
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 542d8f2e9..d3ceead77 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -762,7 +762,8 @@ process_sblock (struct GNUNET_FS_SearchContext *sc, const struct SBlock *sb,
762 */ 762 */
763static void 763static void
764process_result (struct GNUNET_FS_SearchContext *sc, enum GNUNET_BLOCK_Type type, 764process_result (struct GNUNET_FS_SearchContext *sc, enum GNUNET_BLOCK_Type type,
765 struct GNUNET_TIME_Absolute expiration, const void *data, 765 struct GNUNET_TIME_Absolute expiration,
766 const void *data,
766 size_t size) 767 size_t size)
767{ 768{
768 if (GNUNET_TIME_absolute_get_duration (expiration).rel_value > 0) 769 if (GNUNET_TIME_absolute_get_duration (expiration).rel_value > 0)
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c
index f3b18256b..b37858028 100644
--- a/src/fs/gnunet-service-fs_lc.c
+++ b/src/fs/gnunet-service-fs_lc.c
@@ -267,6 +267,8 @@ client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
267 pm->type = htonl (type); 267 pm->type = htonl (type);
268 pm->expiration = GNUNET_TIME_absolute_hton (expiration); 268 pm->expiration = GNUNET_TIME_absolute_hton (expiration);
269 pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission); 269 pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission);
270 pm->num_transmissions = htonl (prd->num_transmissions);
271 pm->respect_offered = htonl (prd->respect_offered);
270 memcpy (&pm[1], data, data_len); 272 memcpy (&pm[1], data, data_len);
271 GSF_local_client_transmit_ (lc, &pm->header); 273 GSF_local_client_transmit_ (lc, &pm->header);
272 } 274 }
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index 2893481f2..3c12edfb9 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -530,6 +530,8 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
530 else 530 else
531 prio = 0; 531 prio = 0;
532 pr->public_data.priority -= prio; 532 pr->public_data.priority -= prio;
533 pr->public_data.num_transmissions++;
534 pr->public_data.respect_offered += prio;
533 gm->priority = htonl (prio); 535 gm->priority = htonl (prio);
534 now = GNUNET_TIME_absolute_get (); 536 now = GNUNET_TIME_absolute_get ();
535 ttl = (int64_t) (pr->public_data.ttl.abs_value - now.abs_value); 537 ttl = (int64_t) (pr->public_data.ttl.abs_value - now.abs_value);
diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h
index ab088f88f..10bc5c1f3 100644
--- a/src/fs/gnunet-service-fs_pr.h
+++ b/src/fs/gnunet-service-fs_pr.h
@@ -133,6 +133,22 @@ struct GSF_PendingRequestData
133 uint32_t original_priority; 133 uint32_t original_priority;
134 134
135 /** 135 /**
136 * Counter for how often this request has been transmitted (estimate,
137 * because we might have the same request pending for multiple clients,
138 * and of course because a transmission may have failed at a lower
139 * layer).
140 */
141 uint32_t num_transmissions;
142
143 /**
144 * How much respect did we (in total) offer for this request so far (estimate,
145 * because we might have the same request pending for multiple clients,
146 * and of course because a transmission may have failed at a lower
147 * layer).
148 */
149 uint32_t respect_offered;
150
151 /**
136 * Options for the request. 152 * Options for the request.
137 */ 153 */
138 enum GSF_PendingRequestOptions options; 154 enum GSF_PendingRequestOptions options;