diff options
Diffstat (limited to 'src/fs/gnunet-service-fs_put.c')
-rw-r--r-- | src/fs/gnunet-service-fs_put.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c index bb4cb4ecb..e8c7f586d 100644 --- a/src/fs/gnunet-service-fs_put.c +++ b/src/fs/gnunet-service-fs_put.c | |||
@@ -72,9 +72,14 @@ struct PutOperator | |||
72 | uint64_t zero_anonymity_count_estimate; | 72 | uint64_t zero_anonymity_count_estimate; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * Current offset when iterating the database. | 75 | * Count of results received from the database. |
76 | */ | 76 | */ |
77 | uint64_t current_offset; | 77 | uint64_t result_count; |
78 | |||
79 | /** | ||
80 | * Next UID to request when iterating the database. | ||
81 | */ | ||
82 | uint64_t next_uid; | ||
78 | }; | 83 | }; |
79 | 84 | ||
80 | 85 | ||
@@ -171,43 +176,51 @@ delay_dht_put_task (void *cls) | |||
171 | * @param type type of the content | 176 | * @param type type of the content |
172 | * @param priority priority of the content | 177 | * @param priority priority of the content |
173 | * @param anonymity anonymity-level for the content | 178 | * @param anonymity anonymity-level for the content |
179 | * @param replication replication-level for the content | ||
174 | * @param expiration expiration time for the content | 180 | * @param expiration expiration time for the content |
175 | * @param uid unique identifier for the datum; | 181 | * @param uid unique identifier for the datum; |
176 | * maybe 0 if no unique identifier is available | 182 | * maybe 0 if no unique identifier is available |
177 | */ | 183 | */ |
178 | static void | 184 | static void |
179 | process_dht_put_content (void *cls, | 185 | process_dht_put_content (void *cls, |
180 | const struct GNUNET_HashCode * key, | 186 | const struct GNUNET_HashCode * key, |
181 | size_t size, | 187 | size_t size, |
182 | const void *data, | 188 | const void *data, |
183 | enum GNUNET_BLOCK_Type type, | 189 | enum GNUNET_BLOCK_Type type, |
184 | uint32_t priority, uint32_t anonymity, | 190 | uint32_t priority, |
185 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | 191 | uint32_t anonymity, |
192 | uint32_t replication, | ||
193 | struct GNUNET_TIME_Absolute expiration, | ||
194 | uint64_t uid) | ||
186 | { | 195 | { |
187 | struct PutOperator *po = cls; | 196 | struct PutOperator *po = cls; |
188 | 197 | ||
189 | po->dht_qe = NULL; | 198 | po->dht_qe = NULL; |
190 | if (key == NULL) | 199 | if (key == NULL) |
191 | { | 200 | { |
192 | po->zero_anonymity_count_estimate = po->current_offset - 1; | 201 | po->zero_anonymity_count_estimate = po->result_count; |
193 | po->current_offset = 0; | 202 | po->result_count = 0; |
203 | po->next_uid = 0; | ||
194 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); | 204 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); |
195 | return; | 205 | return; |
196 | } | 206 | } |
207 | po->result_count++; | ||
208 | po->next_uid = uid + 1; | ||
197 | po->zero_anonymity_count_estimate = | 209 | po->zero_anonymity_count_estimate = |
198 | GNUNET_MAX (po->current_offset, po->zero_anonymity_count_estimate); | 210 | GNUNET_MAX (po->result_count, po->zero_anonymity_count_estimate); |
199 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 211 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
200 | "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key), | 212 | "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key), |
201 | type); | 213 | type); |
202 | po->dht_put = GNUNET_DHT_put (GSF_dht, | 214 | po->dht_put = GNUNET_DHT_put (GSF_dht, |
203 | key, | 215 | key, |
204 | DEFAULT_PUT_REPLICATION, | 216 | DEFAULT_PUT_REPLICATION, |
205 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | 217 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, |
206 | type, | 218 | type, |
207 | size, | 219 | size, |
208 | data, | 220 | data, |
209 | expiration, | 221 | expiration, |
210 | &delay_dht_put_blocks, po); | 222 | &delay_dht_put_blocks, |
223 | po); | ||
211 | } | 224 | } |
212 | 225 | ||
213 | 226 | ||
@@ -223,10 +236,13 @@ gather_dht_put_blocks (void *cls) | |||
223 | 236 | ||
224 | po->dht_task = NULL; | 237 | po->dht_task = NULL; |
225 | po->dht_qe = | 238 | po->dht_qe = |
226 | GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, po->current_offset++, 0, | 239 | GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, |
240 | po->next_uid, | ||
241 | 0, | ||
227 | UINT_MAX, | 242 | UINT_MAX, |
228 | po->dht_put_type, | 243 | po->dht_put_type, |
229 | &process_dht_put_content, po); | 244 | &process_dht_put_content, |
245 | po); | ||
230 | if (NULL == po->dht_qe) | 246 | if (NULL == po->dht_qe) |
231 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); | 247 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); |
232 | } | 248 | } |