diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-23 08:35:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-23 08:35:49 +0000 |
commit | c00ade9abf751ea2157f1f78dd834257fe19ed6c (patch) | |
tree | 0eebb88f356ba98fce52398dcea22a89011d7e6d /src/fs/fs_download.c | |
parent | 8f850cddd40436aa9f5a3ec82606dd5bceebef3d (diff) | |
download | gnunet-c00ade9abf751ea2157f1f78dd834257fe19ed6c.tar.gz gnunet-c00ade9abf751ea2157f1f78dd834257fe19ed6c.zip |
-passing total trust offered along (fixing #1369)
Diffstat (limited to 'src/fs/fs_download.c')
-rw-r--r-- | src/fs/fs_download.c | 27 |
1 files changed, 23 insertions, 4 deletions
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: | |||
1202 | static void | 1215 | static void |
1203 | process_result (struct GNUNET_FS_DownloadContext *dc, | 1216 | process_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) |