aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/gnunet-service-messenger_ego_store.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/gnunet-service-messenger_ego_store.c')
-rw-r--r--src/messenger/gnunet-service-messenger_ego_store.c215
1 files changed, 130 insertions, 85 deletions
diff --git a/src/messenger/gnunet-service-messenger_ego_store.c b/src/messenger/gnunet-service-messenger_ego_store.c
index 3eb313b08..eb094cfd7 100644
--- a/src/messenger/gnunet-service-messenger_ego_store.c
+++ b/src/messenger/gnunet-service-messenger_ego_store.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2020--2022 GNUnet e.V. 3 Copyright (C) 2020--2023 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -34,7 +34,7 @@ callback_update_ego (void *cls,
34 void **ctx, 34 void **ctx,
35 const char *identifier) 35 const char *identifier)
36{ 36{
37 if ((!ctx) || (!identifier)) 37 if ((! ctx) || (! identifier))
38 return; 38 return;
39 39
40 struct GNUNET_MESSENGER_EgoStore *store = cls; 40 struct GNUNET_MESSENGER_EgoStore *store = cls;
@@ -42,7 +42,8 @@ callback_update_ego (void *cls,
42 if (ego) 42 if (ego)
43 { 43 {
44 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New ego in use: '%s'\n", identifier); 44 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New ego in use: '%s'\n", identifier);
45 update_store_ego (store, identifier, GNUNET_IDENTITY_ego_get_private_key (ego)); 45 update_store_ego (store, identifier,
46 GNUNET_IDENTITY_ego_get_private_key (ego));
46 } 47 }
47 else 48 else
48 { 49 {
@@ -51,14 +52,16 @@ callback_update_ego (void *cls,
51 } 52 }
52} 53}
53 54
55
54void 56void
55init_ego_store(struct GNUNET_MESSENGER_EgoStore *store, 57init_ego_store (struct GNUNET_MESSENGER_EgoStore *store,
56 const struct GNUNET_CONFIGURATION_Handle *config) 58 const struct GNUNET_CONFIGURATION_Handle *config)
57{ 59{
58 GNUNET_assert ((store) && (config)); 60 GNUNET_assert ((store) && (config));
59 61
60 store->cfg = config; 62 store->cfg = config;
61 store->identity = GNUNET_IDENTITY_connect (config, &callback_update_ego, store); 63 store->identity = GNUNET_IDENTITY_connect (config, &callback_update_ego,
64 store);
62 store->egos = GNUNET_CONTAINER_multihashmap_create (8, GNUNET_NO); 65 store->egos = GNUNET_CONTAINER_multihashmap_create (8, GNUNET_NO);
63 store->handles = GNUNET_CONTAINER_multihashmap_create (8, GNUNET_NO); 66 store->handles = GNUNET_CONTAINER_multihashmap_create (8, GNUNET_NO);
64 67
@@ -69,18 +72,20 @@ init_ego_store(struct GNUNET_MESSENGER_EgoStore *store,
69 store->op_end = NULL; 72 store->op_end = NULL;
70} 73}
71 74
75
72static int 76static int
73iterate_destroy_egos (void *cls, 77iterate_destroy_egos (void *cls,
74 const struct GNUNET_HashCode *key, 78 const struct GNUNET_HashCode *key,
75 void *value) 79 void *value)
76{ 80{
77 struct GNUNET_MESSENGER_Ego *ego = value; 81 struct GNUNET_MESSENGER_Ego *ego = value;
78 GNUNET_free(ego); 82 GNUNET_free (ego);
79 return GNUNET_YES; 83 return GNUNET_YES;
80} 84}
81 85
86
82void 87void
83clear_ego_store(struct GNUNET_MESSENGER_EgoStore *store) 88clear_ego_store (struct GNUNET_MESSENGER_EgoStore *store)
84{ 89{
85 GNUNET_assert (store); 90 GNUNET_assert (store);
86 91
@@ -105,18 +110,19 @@ clear_ego_store(struct GNUNET_MESSENGER_EgoStore *store)
105 { 110 {
106 lu = store->lu_start; 111 lu = store->lu_start;
107 112
108 GNUNET_IDENTITY_ego_lookup_cancel(lu->lookup); 113 GNUNET_IDENTITY_ego_lookup_cancel (lu->lookup);
109 GNUNET_CONTAINER_DLL_remove (store->lu_start, store->lu_end, lu); 114 GNUNET_CONTAINER_DLL_remove (store->lu_start, store->lu_end, lu);
110 115
111 if (lu->identifier) 116 if (lu->identifier)
112 GNUNET_free(lu->identifier); 117 GNUNET_free (lu->identifier);
113 118
114 GNUNET_free (lu); 119 GNUNET_free (lu);
115 } 120 }
116 121
117 GNUNET_CONTAINER_multihashmap_iterate (store->egos, iterate_destroy_egos, NULL); 122 GNUNET_CONTAINER_multihashmap_iterate (store->egos,
123 iterate_destroy_egos,
124 NULL);
118 GNUNET_CONTAINER_multihashmap_destroy (store->egos); 125 GNUNET_CONTAINER_multihashmap_destroy (store->egos);
119
120 GNUNET_CONTAINER_multihashmap_destroy (store->handles); 126 GNUNET_CONTAINER_multihashmap_destroy (store->handles);
121 127
122 if (store->identity) 128 if (store->identity)
@@ -127,6 +133,7 @@ clear_ego_store(struct GNUNET_MESSENGER_EgoStore *store)
127 } 133 }
128} 134}
129 135
136
130static int 137static int
131iterate_create_ego (void *cls, 138iterate_create_ego (void *cls,
132 const struct GNUNET_HashCode *key, 139 const struct GNUNET_HashCode *key,
@@ -137,6 +144,7 @@ iterate_create_ego (void *cls,
137 return GNUNET_YES; 144 return GNUNET_YES;
138} 145}
139 146
147
140static void 148static void
141callback_ego_create (void *cls, 149callback_ego_create (void *cls,
142 const struct GNUNET_IDENTITY_PrivateKey *key, 150 const struct GNUNET_IDENTITY_PrivateKey *key,
@@ -156,12 +164,16 @@ callback_ego_create (void *cls,
156 164
157 if (key) 165 if (key)
158 { 166 {
159 struct GNUNET_MESSENGER_Ego *msg_ego = update_store_ego (store, element->identifier, key); 167 struct GNUNET_MESSENGER_Ego *msg_ego = update_store_ego (store,
168 element->identifier,
169 key);
160 170
161 struct GNUNET_HashCode hash; 171 struct GNUNET_HashCode hash;
162 GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier), &hash); 172 GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier),
173 &hash);
163 174
164 GNUNET_CONTAINER_multihashmap_get_multiple (store->handles, &hash, iterate_create_ego, msg_ego); 175 GNUNET_CONTAINER_multihashmap_get_multiple (store->handles, &hash,
176 iterate_create_ego, msg_ego);
165 } 177 }
166 else 178 else
167 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating ego failed!\n"); 179 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating ego failed!\n");
@@ -171,15 +183,17 @@ callback_ego_create (void *cls,
171 GNUNET_free (element); 183 GNUNET_free (element);
172} 184}
173 185
186
174void 187void
175create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, 188create_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
176 const char *identifier) 189 const char *identifier)
177{ 190{
178 GNUNET_assert ((store) && (identifier)); 191 GNUNET_assert ((store) && (identifier));
179 192
180 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store create ego: %s\n", identifier); 193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store create ego: %s\n", identifier);
181 194
182 struct GNUNET_MESSENGER_EgoOperation *element = GNUNET_new (struct GNUNET_MESSENGER_EgoOperation); 195 struct GNUNET_MESSENGER_EgoOperation *element = GNUNET_new (struct
196 GNUNET_MESSENGER_EgoOperation);
183 197
184 element->store = store; 198 element->store = store;
185 element->cls = NULL; 199 element->cls = NULL;
@@ -187,17 +201,18 @@ create_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
187 element->identifier = GNUNET_strdup (identifier); 201 element->identifier = GNUNET_strdup (identifier);
188 202
189 element->operation = GNUNET_IDENTITY_create ( 203 element->operation = GNUNET_IDENTITY_create (
190 store->identity, 204 store->identity,
191 identifier, 205 identifier,
192 NULL, 206 NULL,
193 GNUNET_IDENTITY_TYPE_ECDSA, 207 GNUNET_IDENTITY_TYPE_ECDSA,
194 callback_ego_create, 208 callback_ego_create,
195 element 209 element
196 ); 210 );
197 211
198 GNUNET_CONTAINER_DLL_insert (store->op_start, store->op_end, element); 212 GNUNET_CONTAINER_DLL_insert (store->op_start, store->op_end, element);
199} 213}
200 214
215
201void 216void
202bind_store_ego (struct GNUNET_MESSENGER_EgoStore *store, 217bind_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
203 const char *identifier, 218 const char *identifier,
@@ -205,19 +220,23 @@ bind_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
205{ 220{
206 GNUNET_assert ((store) && (identifier) && (handle)); 221 GNUNET_assert ((store) && (identifier) && (handle));
207 222
208 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store bind ego: %s\n", identifier); 223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store bind ego: %s\n", identifier);
209 224
210 struct GNUNET_HashCode hash; 225 struct GNUNET_HashCode hash;
211 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash); 226 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
212 227
213 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value(store->handles, &hash, handle)) 228 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value (
229 store->handles, &hash, handle))
214 return; 230 return;
215 231
216 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(store->handles, &hash, handle, 232 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (store->handles, &hash,
217 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)) 233 handle,
218 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Putting handle binding to ego store failed!\n"); 234 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE))
235 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
236 "Putting handle binding to ego store failed!\n");
219} 237}
220 238
239
221void 240void
222unbind_store_ego (struct GNUNET_MESSENGER_EgoStore *store, 241unbind_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
223 const char *identifier, 242 const char *identifier,
@@ -225,18 +244,22 @@ unbind_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
225{ 244{
226 GNUNET_assert ((store) && (identifier) && (handle)); 245 GNUNET_assert ((store) && (identifier) && (handle));
227 246
228 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store unbind ego: %s\n", identifier); 247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store unbind ego: %s\n", identifier);
229 248
230 struct GNUNET_HashCode hash; 249 struct GNUNET_HashCode hash;
231 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash); 250 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
232 251
233 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_contains_value(store->handles, &hash, handle)) 252 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_contains_value (
253 store->handles, &hash, handle))
234 return; 254 return;
235 255
236 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove(store->handles, &hash, handle)) 256 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (store->handles, &hash,
237 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Removing handle binding from ego store failed!\n"); 257 handle))
258 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
259 "Removing handle binding from ego store failed!\n");
238} 260}
239 261
262
240static void 263static void
241callback_ego_lookup (void *cls, 264callback_ego_lookup (void *cls,
242 struct GNUNET_IDENTITY_Ego *ego) 265 struct GNUNET_IDENTITY_Ego *ego)
@@ -250,50 +273,55 @@ callback_ego_lookup (void *cls,
250 273
251 if (ego) 274 if (ego)
252 { 275 {
253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New ego looked up: '%s'\n", element->identifier); 276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New ego looked up: '%s'\n",
277 element->identifier);
254 msg_ego = update_store_ego ( 278 msg_ego = update_store_ego (
255 store, 279 store,
256 element->identifier, 280 element->identifier,
257 GNUNET_IDENTITY_ego_get_private_key(ego) 281 GNUNET_IDENTITY_ego_get_private_key (ego)
258 ); 282 );
259 } 283 }
260 else 284 else
261 { 285 {
262 struct GNUNET_HashCode hash; 286 struct GNUNET_HashCode hash;
263 GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier), &hash); 287 GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier),
288 &hash);
264 289
265 if (GNUNET_CONTAINER_multihashmap_get (store->egos, &hash)) 290 if (GNUNET_CONTAINER_multihashmap_get (store->egos, &hash))
266 { 291 {
267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looked up ego got deleted: '%s'\n", element->identifier); 292 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looked up ego got deleted: '%s'\n",
268 delete_store_ego(store, element->identifier); 293 element->identifier);
294 delete_store_ego (store, element->identifier);
269 } 295 }
270 } 296 }
271 297
272 if (element->cb) 298 if (element->cb)
273 element->cb(element->cls, element->identifier, msg_ego); 299 element->cb (element->cls, element->identifier, msg_ego);
274 300
275 GNUNET_CONTAINER_DLL_remove (store->lu_start, store->lu_end, element); 301 GNUNET_CONTAINER_DLL_remove (store->lu_start, store->lu_end, element);
276 GNUNET_free (element->identifier); 302 GNUNET_free (element->identifier);
277 GNUNET_free (element); 303 GNUNET_free (element);
278} 304}
279 305
306
280void 307void
281lookup_store_ego(struct GNUNET_MESSENGER_EgoStore *store, 308lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
282 const char *identifier, 309 const char *identifier,
283 GNUNET_MESSENGER_EgoLookupCallback lookup, 310 GNUNET_MESSENGER_EgoLookupCallback lookup,
284 void *cls) 311 void *cls)
285{ 312{
286 GNUNET_assert (store); 313 GNUNET_assert (store);
287 314
288 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store lookup ego: %s\n", identifier); 315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store lookup ego: %s\n", identifier);
289 316
290 if (!identifier) 317 if (! identifier)
291 { 318 {
292 lookup(cls, identifier, NULL); 319 lookup (cls, identifier, NULL);
293 return; 320 return;
294 } 321 }
295 322
296 struct GNUNET_MESSENGER_EgoLookup *element = GNUNET_new (struct GNUNET_MESSENGER_EgoLookup); 323 struct GNUNET_MESSENGER_EgoLookup *element = GNUNET_new (struct
324 GNUNET_MESSENGER_EgoLookup);
297 325
298 element->store = store; 326 element->store = store;
299 327
@@ -302,11 +330,13 @@ lookup_store_ego(struct GNUNET_MESSENGER_EgoStore *store,
302 330
303 element->identifier = GNUNET_strdup (identifier); 331 element->identifier = GNUNET_strdup (identifier);
304 332
305 element->lookup = GNUNET_IDENTITY_ego_lookup(store->cfg, identifier, callback_ego_lookup, element); 333 element->lookup = GNUNET_IDENTITY_ego_lookup (store->cfg, identifier,
334 callback_ego_lookup, element);
306 335
307 GNUNET_CONTAINER_DLL_insert (store->lu_start, store->lu_end, element); 336 GNUNET_CONTAINER_DLL_insert (store->lu_start, store->lu_end, element);
308} 337}
309 338
339
310struct GNUNET_MESSENGER_Ego* 340struct GNUNET_MESSENGER_Ego*
311update_store_ego (struct GNUNET_MESSENGER_EgoStore *store, 341update_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
312 const char *identifier, 342 const char *identifier,
@@ -314,55 +344,62 @@ update_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
314{ 344{
315 GNUNET_assert ((store) && (identifier) && (key)); 345 GNUNET_assert ((store) && (identifier) && (key));
316 346
317 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store update ego: %s\n", identifier); 347 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store update ego: %s\n", identifier);
318 348
319 struct GNUNET_HashCode hash; 349 struct GNUNET_HashCode hash;
320 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash); 350 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
321 351
322 struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (store->egos, &hash); 352 struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (
353 store->egos, &hash);
323 354
324 if (!ego) 355 if (! ego)
325 { 356 {
326 ego = GNUNET_new(struct GNUNET_MESSENGER_Ego); 357 ego = GNUNET_new (struct GNUNET_MESSENGER_Ego);
327 GNUNET_CONTAINER_multihashmap_put (store->egos, &hash, ego, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 358 GNUNET_CONTAINER_multihashmap_put (store->egos, &hash, ego,
359 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
328 } 360 }
329 361
330 GNUNET_memcpy(&(ego->priv), key, sizeof(*key)); 362 GNUNET_memcpy (&(ego->priv), key, sizeof(*key));
331 363
332 if (GNUNET_OK != GNUNET_IDENTITY_key_get_public (key, &(ego->pub))) 364 if (GNUNET_OK != GNUNET_IDENTITY_key_get_public (key, &(ego->pub)))
333 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Updating invalid ego key failed!\n"); 365 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
366 "Updating invalid ego key failed!\n");
334 367
335 return ego; 368 return ego;
336} 369}
337 370
371
338void 372void
339delete_store_ego (struct GNUNET_MESSENGER_EgoStore *store, 373delete_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
340 const char *identifier) 374 const char *identifier)
341{ 375{
342 GNUNET_assert ((store) && (identifier)); 376 GNUNET_assert ((store) && (identifier));
343 377
344 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store delete ego: %s\n", identifier); 378 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store delete ego: %s\n", identifier);
345 379
346 struct GNUNET_HashCode hash; 380 struct GNUNET_HashCode hash;
347 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash); 381 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
348 382
349 struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (store->egos, &hash); 383 struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (
384 store->egos, &hash);
350 385
351 if (ego) 386 if (ego)
352 { 387 {
353 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ego is not stored!\n"); 388 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Ego is not stored!\n");
354 return; 389 return;
355 } 390 }
356 391
357 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (store->egos, &hash, ego)) 392 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (store->egos, &hash,
393 ego))
358 { 394 {
359 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Removing ego from store failed!\n"); 395 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Removing ego from store failed!\n");
360 return; 396 return;
361 } 397 }
362 398
363 GNUNET_free(ego); 399 GNUNET_free (ego);
364} 400}
365 401
402
366static void 403static void
367callback_ego_rename (void *cls, 404callback_ego_rename (void *cls,
368 enum GNUNET_ErrorCode ec) 405 enum GNUNET_ErrorCode ec)
@@ -382,14 +419,16 @@ callback_ego_rename (void *cls,
382 struct GNUNET_HashCode hash; 419 struct GNUNET_HashCode hash;
383 GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier), &hash); 420 GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier), &hash);
384 421
385 struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (store->egos, &hash); 422 struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (
423 store->egos, &hash);
386 424
387 if (!ego) 425 if (! ego)
388 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ego is not stored!\n"); 426 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Ego is not stored!\n");
389 427
390 char *identifier = (char*) element->cls; 428 char *identifier = (char*) element->cls;
391 429
392 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (store->egos, &hash, ego)) 430 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (store->egos, &hash,
431 ego))
393 { 432 {
394 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash); 433 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
395 434
@@ -397,7 +436,7 @@ callback_ego_rename (void *cls,
397 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 436 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
398 } 437 }
399 else 438 else
400 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Renaming ego failed!\n"); 439 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Renaming ego failed!\n");
401 440
402 GNUNET_free (identifier); 441 GNUNET_free (identifier);
403 442
@@ -406,6 +445,7 @@ callback_ego_rename (void *cls,
406 GNUNET_free (element); 445 GNUNET_free (element);
407} 446}
408 447
448
409void 449void
410rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store, 450rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
411 const char *old_identifier, 451 const char *old_identifier,
@@ -413,9 +453,11 @@ rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
413{ 453{
414 GNUNET_assert ((store) && (old_identifier) && (new_identifier)); 454 GNUNET_assert ((store) && (old_identifier) && (new_identifier));
415 455
416 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store rename ego: %s -> %s\n", old_identifier, new_identifier); 456 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store rename ego: %s -> %s\n",
457 old_identifier, new_identifier);
417 458
418 struct GNUNET_MESSENGER_EgoOperation *element = GNUNET_new (struct GNUNET_MESSENGER_EgoOperation); 459 struct GNUNET_MESSENGER_EgoOperation *element = GNUNET_new (struct
460 GNUNET_MESSENGER_EgoOperation);
419 461
420 element->store = store; 462 element->store = store;
421 element->cls = GNUNET_strdup (new_identifier); 463 element->cls = GNUNET_strdup (new_identifier);
@@ -423,16 +465,17 @@ rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
423 element->identifier = GNUNET_strdup (old_identifier); 465 element->identifier = GNUNET_strdup (old_identifier);
424 466
425 element->operation = GNUNET_IDENTITY_rename ( 467 element->operation = GNUNET_IDENTITY_rename (
426 store->identity, 468 store->identity,
427 old_identifier, 469 old_identifier,
428 new_identifier, 470 new_identifier,
429 callback_ego_rename, 471 callback_ego_rename,
430 element 472 element
431 ); 473 );
432 474
433 GNUNET_CONTAINER_DLL_insert (store->op_start, store->op_end, element); 475 GNUNET_CONTAINER_DLL_insert (store->op_start, store->op_end, element);
434} 476}
435 477
478
436static void 479static void
437callback_ego_delete (void *cls, 480callback_ego_delete (void *cls,
438 enum GNUNET_ErrorCode ec) 481 enum GNUNET_ErrorCode ec)
@@ -456,27 +499,29 @@ callback_ego_delete (void *cls,
456 GNUNET_free (element); 499 GNUNET_free (element);
457} 500}
458 501
502
459void 503void
460renew_store_ego (struct GNUNET_MESSENGER_EgoStore *store, 504renew_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
461 const char *identifier) 505 const char *identifier)
462{ 506{
463 GNUNET_assert ((store) && (identifier)); 507 GNUNET_assert ((store) && (identifier));
464 508
465 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store renew ego: %s\n", identifier); 509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store renew ego: %s\n", identifier);
466 510
467 struct GNUNET_MESSENGER_EgoOperation *element = GNUNET_new (struct GNUNET_MESSENGER_EgoOperation); 511 struct GNUNET_MESSENGER_EgoOperation *element = GNUNET_new (struct
512 GNUNET_MESSENGER_EgoOperation);
468 513
469 element->store = store; 514 element->store = store;
470 element->cls = NULL; 515 element->cls = NULL;
471 516
472 element->identifier = GNUNET_strdup (identifier); 517 element->identifier = GNUNET_strdup (identifier);
473 518
474 element->operation = GNUNET_IDENTITY_delete( 519 element->operation = GNUNET_IDENTITY_delete (
475 store->identity, 520 store->identity,
476 identifier, 521 identifier,
477 callback_ego_delete, 522 callback_ego_delete,
478 element 523 element
479 ); 524 );
480 525
481 GNUNET_CONTAINER_DLL_insert (store->op_start, store->op_end, element); 526 GNUNET_CONTAINER_DLL_insert (store->op_start, store->op_end, element);
482} 527}