aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-xdht_datacache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-service-xdht_datacache.c')
-rw-r--r--src/dht/gnunet-service-xdht_datacache.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/dht/gnunet-service-xdht_datacache.c b/src/dht/gnunet-service-xdht_datacache.c
index 558832e5b..9fbff7dfb 100644
--- a/src/dht/gnunet-service-xdht_datacache.c
+++ b/src/dht/gnunet-service-xdht_datacache.c
@@ -64,7 +64,7 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration,
64 const void *data) 64 const void *data)
65{ 65{
66 int r; 66 int r;
67 67
68 if (NULL == datacache) 68 if (NULL == datacache)
69 { 69 {
70 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 70 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -76,12 +76,12 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration,
76 GNUNET_break (0); 76 GNUNET_break (0);
77 return; 77 return;
78 } 78 }
79 79
80 /* Put size is actual data size plus struct overhead plus path length (if any) */ 80 /* Put size is actual data size plus struct overhead plus path length (if any) */
81 GNUNET_STATISTICS_update (GDS_stats, 81 GNUNET_STATISTICS_update (GDS_stats,
82 gettext_noop ("# ITEMS stored in datacache"), 1, 82 gettext_noop ("# ITEMS stored in datacache"), 1,
83 GNUNET_NO); 83 GNUNET_NO);
84 84
85 struct GNUNET_PeerIdentity peer = GDS_NEIGHBOURS_get_my_id(); 85 struct GNUNET_PeerIdentity peer = GDS_NEIGHBOURS_get_my_id();
86 DEBUG("DATACACHE_PUT KEY = %s, peer = %s\n",GNUNET_h2s(key),GNUNET_i2s(&peer)); 86 DEBUG("DATACACHE_PUT KEY = %s, peer = %s\n",GNUNET_h2s(key),GNUNET_i2s(&peer));
87 r = GNUNET_DATACACHE_put (datacache, key, data_size, data, type, expiration, 87 r = GNUNET_DATACACHE_put (datacache, key, data_size, data, type, expiration,
@@ -180,32 +180,41 @@ struct GetRequestContext
180/** 180/**
181 * Iterator for local get request results, 181 * Iterator for local get request results,
182 * 182 *
183 * @param cls closure for iterator, a DatacacheGetContext 183 * @param cls closure for iterator, a `struct GetRequestContext`
184 * @param exp when does this value expire?
185 * @param key the key this data is stored under 184 * @param key the key this data is stored under
186 * @param size the size of the data identified by key 185 * @param size the size of the data identified by key
187 * @param data the actual data 186 * @param data the actual data
188 * @param type the type of the data 187 * @param type the type of the data
189 * @param put_path_length number of peers in 'put_path' 188 * @param exp when does this value expire?
189 * @param put_path_length number of peers in @a put_path
190 * @param put_path path the reply took on put 190 * @param put_path path the reply took on put
191 * @return GNUNET_OK to continue iteration, anything else 191 * @return #GNUNET_OK to continue iteration, anything else
192 * to stop iteration. 192 * to stop iteration.
193 */ 193 */
194static int 194static int
195datacache_get_iterator (void *cls, 195datacache_get_iterator (void *cls,
196 const struct GNUNET_HashCode * key, size_t size, 196 const struct GNUNET_HashCode *key,
197 const char *data, enum GNUNET_BLOCK_Type type, 197 size_t size,
198 struct GNUNET_TIME_Absolute exp, 198 const char *data,
199 unsigned int put_path_length, 199 enum GNUNET_BLOCK_Type type,
200 const struct GNUNET_PeerIdentity *put_path) 200 struct GNUNET_TIME_Absolute exp,
201 unsigned int put_path_length,
202 const struct GNUNET_PeerIdentity *put_path)
201{ 203{
202 struct GetRequestContext *ctx = cls; 204 struct GetRequestContext *ctx = cls;
203 enum GNUNET_BLOCK_EvaluationResult eval; 205 enum GNUNET_BLOCK_EvaluationResult eval;
204 206
205 eval = 207 eval =
206 GNUNET_BLOCK_evaluate (GDS_block_context, type, key, ctx->reply_bf, 208 GNUNET_BLOCK_evaluate (GDS_block_context,
207 ctx->reply_bf_mutator, ctx->xquery, 209 type,
208 ctx->xquery_size, data, size); 210 GNUNET_BLOCK_EO_NONE,
211 key,
212 ctx->reply_bf,
213 ctx->reply_bf_mutator,
214 ctx->xquery,
215 ctx->xquery_size,
216 data,
217 size);
209 LOG (GNUNET_ERROR_TYPE_DEBUG, 218 LOG (GNUNET_ERROR_TYPE_DEBUG,
210 "Found reply for query %s in datacache, evaluation result is %d\n", 219 "Found reply for query %s in datacache, evaluation result is %d\n",
211 GNUNET_h2s (key), (int) eval); 220 GNUNET_h2s (key), (int) eval);
@@ -221,7 +230,7 @@ datacache_get_iterator (void *cls,
221 ("# Good RESULTS found in datacache"), 1, 230 ("# Good RESULTS found in datacache"), 1,
222 GNUNET_NO); 231 GNUNET_NO);
223 struct GNUNET_PeerIdentity *get_path; 232 struct GNUNET_PeerIdentity *get_path;
224 get_path = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity) * 233 get_path = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity) *
225 ctx->get_path_length); 234 ctx->get_path_length);
226 struct GetPath *iterator; 235 struct GetPath *iterator;
227 iterator = ctx->head; 236 iterator = ctx->head;
@@ -271,7 +280,7 @@ datacache_get_iterator (void *cls,
271 _("Unsupported block type (%u) in local response!\n"), type); 280 _("Unsupported block type (%u) in local response!\n"), type);
272 break; 281 break;
273 } 282 }
274 283
275 return (eval == GNUNET_BLOCK_EVALUATION_OK_LAST) ? GNUNET_NO : GNUNET_OK; 284 return (eval == GNUNET_BLOCK_EVALUATION_OK_LAST) ? GNUNET_NO : GNUNET_OK;
276} 285}
277 286
@@ -315,13 +324,13 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key,
315 ctx.reply_bf = reply_bf; 324 ctx.reply_bf = reply_bf;
316 ctx.reply_bf_mutator = reply_bf_mutator; 325 ctx.reply_bf_mutator = reply_bf_mutator;
317 ctx.get_path_length = get_path_length; 326 ctx.get_path_length = get_path_length;
318 327
319 if (next_hop != NULL) 328 if (next_hop != NULL)
320 { 329 {
321 memcpy (&(ctx.next_hop), next_hop, sizeof (struct GNUNET_PeerIdentity)); 330 memcpy (&(ctx.next_hop), next_hop, sizeof (struct GNUNET_PeerIdentity));
322 } 331 }
323 unsigned int i = 0; 332 unsigned int i = 0;
324 333
325 ctx.head = NULL; 334 ctx.head = NULL;
326 ctx.tail = NULL; 335 ctx.tail = NULL;
327 if (get_path != NULL) 336 if (get_path != NULL)
@@ -337,7 +346,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key,
337 i++; 346 i++;
338 } 347 }
339 } 348 }
340 349
341 r = GNUNET_DATACACHE_get (datacache, key, type, &datacache_get_iterator, 350 r = GNUNET_DATACACHE_get (datacache, key, type, &datacache_get_iterator,
342 &ctx); 351 &ctx);
343 DEBUG ("DATACACHE_GET for key %s completed (%d). %u results found.\n",GNUNET_h2s (key), ctx.eval, r); 352 DEBUG ("DATACACHE_GET for key %s completed (%d). %u results found.\n",GNUNET_h2s (key), ctx.eval, r);