aboutsummaryrefslogtreecommitdiff
path: root/src/escrow/escrow_api.c
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-08-06 14:33:34 +0200
committerjospaeth <spaethj@in.tum.de>2020-08-06 14:33:34 +0200
commit7359d93752bfe39d1154ea0e67f556dab0020cff (patch)
tree207713d099a540a9b247320089f52fb82cc6f8e3 /src/escrow/escrow_api.c
parentf7272dfc42de5b4cd0f9b27308e82e91d5f64ee3 (diff)
downloadgnunet-7359d93752bfe39d1154ea0e67f556dab0020cff.tar.gz
gnunet-7359d93752bfe39d1154ea0e67f556dab0020cff.zip
add unique operation ID for distinction in the cb
Diffstat (limited to 'src/escrow/escrow_api.c')
-rw-r--r--src/escrow/escrow_api.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/escrow/escrow_api.c b/src/escrow/escrow_api.c
index 510f6a898..7714152c0 100644
--- a/src/escrow/escrow_api.c
+++ b/src/escrow/escrow_api.c
@@ -115,6 +115,20 @@ init_plugin (struct GNUNET_ESCROW_Handle *h,
115 115
116 116
117/** 117/**
118 * Get a fresh operation id to distinguish between escrow operations
119 *
120 * @param h the escrow handle
121 *
122 * @return next operation id to use
123 */
124static uint32_t
125get_op_id (struct GNUNET_ESCROW_Handle *h)
126{
127 return h->last_op_id_used++;
128}
129
130
131/**
118 * Initialize the escrow component. 132 * Initialize the escrow component.
119 * 133 *
120 * @param cfg the configuration to use 134 * @param cfg the configuration to use
@@ -191,7 +205,7 @@ handle_start_escrow_result (void *cls)
191 struct GNUNET_ESCROW_Operation *op; 205 struct GNUNET_ESCROW_Operation *op;
192 206
193 for (op = w->h->op_head; NULL != op; op = op->next) 207 for (op = w->h->op_head; NULL != op; op = op->next)
194 if (1) // TODO: find condition (e.g. unique ID) 208 if (op->id == w->op_id)
195 break; 209 break;
196 210
197 if (NULL == op) 211 if (NULL == op)
@@ -229,13 +243,14 @@ GNUNET_ESCROW_put (struct GNUNET_ESCROW_Handle *h,
229 243
230 op = GNUNET_new (struct GNUNET_ESCROW_Operation); 244 op = GNUNET_new (struct GNUNET_ESCROW_Operation);
231 op->h = h; 245 op->h = h;
246 op->id = get_op_id (h);
232 op->method = method; 247 op->method = method;
233 op->cb_put = cb; 248 op->cb_put = cb;
234 op->cb_cls = cb_cls; 249 op->cb_cls = cb_cls;
235 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 250 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
236 251
237 api = init_plugin (h, method); 252 api = init_plugin (h, method);
238 op->plugin_op_wrap = api->start_key_escrow (h, ego, &handle_start_escrow_result); 253 op->plugin_op_wrap = api->start_key_escrow (h, ego, &handle_start_escrow_result, op->id);
239 254
240 return op; 255 return op;
241} 256}
@@ -248,7 +263,7 @@ handle_restore_key_result (void *cls)
248 struct GNUNET_ESCROW_Operation *op; 263 struct GNUNET_ESCROW_Operation *op;
249 264
250 for (op = w->h->op_head; NULL != op; op = op->next) 265 for (op = w->h->op_head; NULL != op; op = op->next)
251 if (1) // TODO: find condition (e.g. unique ID) 266 if (op->id == w->op_id)
252 break; 267 break;
253 268
254 if (NULL == op) 269 if (NULL == op)
@@ -288,13 +303,14 @@ GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h,
288 303
289 op = GNUNET_new (struct GNUNET_ESCROW_Operation); 304 op = GNUNET_new (struct GNUNET_ESCROW_Operation);
290 op->h = h; 305 op->h = h;
306 op->id = get_op_id (h);
291 op->method = method; 307 op->method = method;
292 op->cb_get = cb; 308 op->cb_get = cb;
293 op->cb_cls = cb_cls; 309 op->cb_cls = cb_cls;
294 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 310 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
295 311
296 api = init_plugin (h, method); 312 api = init_plugin (h, method);
297 op->plugin_op_wrap = api->restore_key (h, escrowAnchor, egoName, &handle_restore_key_result); 313 op->plugin_op_wrap = api->restore_key (h, escrowAnchor, egoName, &handle_restore_key_result, op->id);
298 314
299 return op; 315 return op;
300} 316}
@@ -307,7 +323,7 @@ handle_verify_escrow_result (void *cls)
307 struct GNUNET_ESCROW_Operation *op; 323 struct GNUNET_ESCROW_Operation *op;
308 324
309 for (op = w->h->op_head; NULL != op; op = op->next) 325 for (op = w->h->op_head; NULL != op; op = op->next)
310 if (1) // TODO: find condition (e.g. unique ID) 326 if (op->id == w->op_id)
311 break; 327 break;
312 328
313 if (NULL == op) 329 if (NULL == op)
@@ -318,8 +334,6 @@ handle_verify_escrow_result (void *cls)
318 GNUNET_CONTAINER_DLL_remove (w->h->op_head, w->h->op_tail, op); 334 GNUNET_CONTAINER_DLL_remove (w->h->op_head, w->h->op_tail, op);
319 if (NULL != op->cb_verify) 335 if (NULL != op->cb_verify)
320 op->cb_verify (op->cb_cls, w->verificationResult); 336 op->cb_verify (op->cb_cls, w->verificationResult);
321 GNUNET_free (op->plugin_op_wrap->plugin_op);
322 GNUNET_free (op->plugin_op_wrap);
323 GNUNET_free (op); 337 GNUNET_free (op);
324} 338}
325 339
@@ -349,13 +363,14 @@ GNUNET_ESCROW_verify (struct GNUNET_ESCROW_Handle *h,
349 363
350 op = GNUNET_new (struct GNUNET_ESCROW_Operation); 364 op = GNUNET_new (struct GNUNET_ESCROW_Operation);
351 op->h = h; 365 op->h = h;
366 op->id = get_op_id (h);
352 op->method = method; 367 op->method = method;
353 op->cb_verify = cb; 368 op->cb_verify = cb;
354 op->cb_cls = cb_cls; 369 op->cb_cls = cb_cls;
355 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 370 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
356 371
357 api = init_plugin (h, method); 372 api = init_plugin (h, method);
358 op->plugin_op_wrap = api->verify_key_escrow (h, ego, escrowAnchor, &handle_verify_escrow_result); 373 op->plugin_op_wrap = api->verify_key_escrow (h, ego, escrowAnchor, &handle_verify_escrow_result, op->id);
359 374
360 return op; 375 return op;
361} 376}