diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-16 21:52:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-16 21:52:04 +0000 |
commit | dbc823a07a03e1085172038125b0edf15b0dc6fe (patch) | |
tree | 4e7c3bf60ce83e801c69a6566ea36d514b571cba /src/namestore/gnunet-namestore.c | |
parent | eec0e5088ec9437f5c0cf9d3ffef87603ad2777a (diff) | |
download | gnunet-dbc823a07a03e1085172038125b0edf15b0dc6fe.tar.gz gnunet-dbc823a07a03e1085172038125b0edf15b0dc6fe.zip |
-finishing split of namestore into namestore and namecache (#3065) -- in theory; in practice, somehow something broke badly, so the tests are now failing
Diffstat (limited to 'src/namestore/gnunet-namestore.c')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 134 |
1 files changed, 14 insertions, 120 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 45e721b89..3fa20a5e6 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -75,11 +75,6 @@ static struct GNUNET_NAMESTORE_QueueEntry *add_qe_uri; | |||
75 | static struct GNUNET_NAMESTORE_QueueEntry *add_qe; | 75 | static struct GNUNET_NAMESTORE_QueueEntry *add_qe; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Queue entry for the 'list' operation (in combination with a name). | ||
79 | */ | ||
80 | static struct GNUNET_NAMESTORE_QueueEntry *list_qe; | ||
81 | |||
82 | /** | ||
83 | * Queue entry for the 'reverse lookup' operation (in combination with a name). | 78 | * Queue entry for the 'reverse lookup' operation (in combination with a name). |
84 | */ | 79 | */ |
85 | static struct GNUNET_NAMESTORE_QueueEntry *reverse_qe; | 80 | static struct GNUNET_NAMESTORE_QueueEntry *reverse_qe; |
@@ -215,11 +210,6 @@ do_shutdown (void *cls, | |||
215 | GNUNET_NAMESTORE_cancel (add_qe); | 210 | GNUNET_NAMESTORE_cancel (add_qe); |
216 | add_qe = NULL; | 211 | add_qe = NULL; |
217 | } | 212 | } |
218 | if (NULL != list_qe) | ||
219 | { | ||
220 | GNUNET_NAMESTORE_cancel (list_qe); | ||
221 | list_qe = NULL; | ||
222 | } | ||
223 | if (NULL != add_qe_uri) | 213 | if (NULL != add_qe_uri) |
224 | { | 214 | { |
225 | GNUNET_NAMESTORE_cancel (add_qe_uri); | 215 | GNUNET_NAMESTORE_cancel (add_qe_uri); |
@@ -261,7 +251,6 @@ static void | |||
261 | test_finished () | 251 | test_finished () |
262 | { | 252 | { |
263 | if ( (NULL == add_qe) && | 253 | if ( (NULL == add_qe) && |
264 | (NULL == list_qe) && | ||
265 | (NULL == add_qe_uri) && | 254 | (NULL == add_qe_uri) && |
266 | (NULL == del_qe) && | 255 | (NULL == del_qe) && |
267 | (NULL == reverse_qe) && | 256 | (NULL == reverse_qe) && |
@@ -329,14 +318,14 @@ del_continuation (void *cls, | |||
329 | * | 318 | * |
330 | * @param cls closure | 319 | * @param cls closure |
331 | * @param zone_key private key of the zone | 320 | * @param zone_key private key of the zone |
332 | * @param name name that is being mapped (at most 255 characters long) | 321 | * @param rname name that is being mapped (at most 255 characters long) |
333 | * @param rd_len number of entries in @a rd array | 322 | * @param rd_len number of entries in @a rd array |
334 | * @param rd array of records with data to store | 323 | * @param rd array of records with data to store |
335 | */ | 324 | */ |
336 | static void | 325 | static void |
337 | display_record (void *cls, | 326 | display_record (void *cls, |
338 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 327 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
339 | const char *name, | 328 | const char *rname, |
340 | unsigned int rd_len, | 329 | unsigned int rd_len, |
341 | const struct GNUNET_GNSRECORD_Data *rd) | 330 | const struct GNUNET_GNSRECORD_Data *rd) |
342 | { | 331 | { |
@@ -347,15 +336,21 @@ display_record (void *cls, | |||
347 | struct GNUNET_TIME_Absolute at; | 336 | struct GNUNET_TIME_Absolute at; |
348 | struct GNUNET_TIME_Relative rt; | 337 | struct GNUNET_TIME_Relative rt; |
349 | 338 | ||
350 | if (NULL == name) | 339 | if (NULL == rname) |
351 | { | 340 | { |
352 | list_it = NULL; | 341 | list_it = NULL; |
353 | test_finished (); | 342 | test_finished (); |
354 | return; | 343 | return; |
355 | } | 344 | } |
345 | if ( (NULL != name) && | ||
346 | (0 != strcmp (name, rname)) ) | ||
347 | { | ||
348 | GNUNET_NAMESTORE_zone_iterator_next (list_it); | ||
349 | return; | ||
350 | } | ||
356 | FPRINTF (stdout, | 351 | FPRINTF (stdout, |
357 | "%s:\n", | 352 | "%s:\n", |
358 | name); | 353 | rname); |
359 | for (i=0;i<rd_len;i++) | 354 | for (i=0;i<rd_len;i++) |
360 | { | 355 | { |
361 | typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type); | 356 | typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type); |
@@ -466,89 +461,6 @@ get_existing_record (void *cls, | |||
466 | } | 461 | } |
467 | 462 | ||
468 | 463 | ||
469 | |||
470 | /** | ||
471 | * Process a record that was stored in the namestore in a block. | ||
472 | * | ||
473 | * @param cls closure, NULL | ||
474 | * @param rd_len number of entries in @a rd array | ||
475 | * @param rd array of records with data to store | ||
476 | */ | ||
477 | static void | ||
478 | display_records_from_block (void *cls, | ||
479 | unsigned int rd_len, | ||
480 | const struct GNUNET_GNSRECORD_Data *rd) | ||
481 | { | ||
482 | const char *typestring; | ||
483 | char *s; | ||
484 | unsigned int i; | ||
485 | |||
486 | if (0 == rd_len) | ||
487 | { | ||
488 | FPRINTF (stdout, | ||
489 | _("No records found for `%s'"), | ||
490 | name); | ||
491 | return; | ||
492 | } | ||
493 | FPRINTF (stdout, | ||
494 | "%s:\n", | ||
495 | name); | ||
496 | for (i=0;i<rd_len;i++) | ||
497 | { | ||
498 | typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type); | ||
499 | s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, | ||
500 | rd[i].data, | ||
501 | rd[i].data_size); | ||
502 | if (NULL == s) | ||
503 | { | ||
504 | FPRINTF (stdout, _("\tCorrupt or unsupported record of type %u\n"), | ||
505 | (unsigned int) rd[i].record_type); | ||
506 | continue; | ||
507 | } | ||
508 | FPRINTF (stdout, | ||
509 | "\t%s: %s\n", | ||
510 | typestring, | ||
511 | s); | ||
512 | GNUNET_free (s); | ||
513 | } | ||
514 | FPRINTF (stdout, "%s", "\n"); | ||
515 | } | ||
516 | |||
517 | |||
518 | /** | ||
519 | * Display block obtained from listing (by name). | ||
520 | * | ||
521 | * @param cls NULL | ||
522 | * @param block NULL if not found | ||
523 | */ | ||
524 | static void | ||
525 | handle_block (void *cls, | ||
526 | const struct GNUNET_GNSRECORD_Block *block) | ||
527 | { | ||
528 | struct GNUNET_CRYPTO_EcdsaPublicKey zone_pubkey; | ||
529 | |||
530 | list_qe = NULL; | ||
531 | GNUNET_CRYPTO_ecdsa_key_get_public (&zone_pkey, | ||
532 | &zone_pubkey); | ||
533 | if (NULL == block) | ||
534 | { | ||
535 | fprintf (stderr, | ||
536 | "No matching block found\n"); | ||
537 | } | ||
538 | else if (GNUNET_OK != | ||
539 | GNUNET_GNSRECORD_block_decrypt (block, | ||
540 | &zone_pubkey, | ||
541 | name, | ||
542 | &display_records_from_block, | ||
543 | NULL)) | ||
544 | { | ||
545 | fprintf (stderr, | ||
546 | "Failed to decrypt block!\n"); | ||
547 | } | ||
548 | test_finished (); | ||
549 | } | ||
550 | |||
551 | |||
552 | /** | 464 | /** |
553 | * Function called with the result of our attempt to obtain a name for a given | 465 | * Function called with the result of our attempt to obtain a name for a given |
554 | * public key. | 466 | * public key. |
@@ -729,28 +641,10 @@ testservice_task (void *cls, | |||
729 | } | 641 | } |
730 | if (list) | 642 | if (list) |
731 | { | 643 | { |
732 | if (NULL == name) | 644 | list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, |
733 | { | 645 | &zone_pkey, |
734 | list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, | 646 | &display_record, |
735 | &zone_pkey, | 647 | NULL); |
736 | &display_record, | ||
737 | NULL); | ||
738 | } | ||
739 | else | ||
740 | { | ||
741 | struct GNUNET_HashCode query; | ||
742 | struct GNUNET_CRYPTO_EcdsaPublicKey zone_pubkey; | ||
743 | |||
744 | GNUNET_CRYPTO_ecdsa_key_get_public (&zone_pkey, | ||
745 | &zone_pubkey); | ||
746 | GNUNET_GNSRECORD_query_from_public_key (&zone_pubkey, | ||
747 | name, | ||
748 | &query); | ||
749 | list_qe = GNUNET_NAMESTORE_lookup_block (ns, | ||
750 | &query, | ||
751 | &handle_block, | ||
752 | NULL); | ||
753 | } | ||
754 | } | 648 | } |
755 | if (NULL != reverse_pkey) | 649 | if (NULL != reverse_pkey) |
756 | { | 650 | { |