aboutsummaryrefslogtreecommitdiff
path: root/src/regex/regex_internal_dht.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-05-22 12:42:58 +0000
committerChristian Grothoff <christian@grothoff.org>2015-05-22 12:42:58 +0000
commit7b636c9e74039f14b25e70d1050432d9782efef9 (patch)
tree123c283ba01ca97ff885628c5bf62e8109e30cc3 /src/regex/regex_internal_dht.c
parent157f7872646546aa956e36b3c3629eed00013f45 (diff)
downloadgnunet-7b636c9e74039f14b25e70d1050432d9782efef9.tar.gz
gnunet-7b636c9e74039f14b25e70d1050432d9782efef9.zip
-improving testcase
Diffstat (limited to 'src/regex/regex_internal_dht.c')
-rw-r--r--src/regex/regex_internal_dht.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c
index 7b93fddca..7fa15ba45 100644
--- a/src/regex/regex_internal_dht.c
+++ b/src/regex/regex_internal_dht.c
@@ -122,7 +122,7 @@ regex_iterator (void *cls,
122 ab.expiration_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_DHT_MAX_EXPIRATION)); 122 ab.expiration_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_DHT_MAX_EXPIRATION));
123 ab.key = *key; 123 ab.key = *key;
124 GNUNET_CRYPTO_eddsa_key_get_public (h->priv, 124 GNUNET_CRYPTO_eddsa_key_get_public (h->priv,
125 &ab.peer.public_key); 125 &ab.peer.public_key);
126 GNUNET_assert (GNUNET_OK == 126 GNUNET_assert (GNUNET_OK ==
127 GNUNET_CRYPTO_eddsa_sign (h->priv, 127 GNUNET_CRYPTO_eddsa_sign (h->priv,
128 &ab.purpose, 128 &ab.purpose,
@@ -263,7 +263,7 @@ struct RegexSearchContext
263 263
264 264
265/** 265/**
266 * Type of values in 'dht_get_results'. 266 * Type of values in #dht_get_results().
267 */ 267 */
268struct Result 268struct Result
269{ 269{
@@ -393,7 +393,7 @@ dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp,
393 393
394 394
395/** 395/**
396 * Find a path to a peer that offers a regex servcie compatible 396 * Find a path to a peer that offers a regex service compatible
397 * with a given string. 397 * with a given string.
398 * 398 *
399 * @param key The key of the accepting state. 399 * @param key The key of the accepting state.
@@ -406,8 +406,9 @@ regex_find_path (const struct GNUNET_HashCode *key,
406 struct GNUNET_DHT_GetHandle *get_h; 406 struct GNUNET_DHT_GetHandle *get_h;
407 407
408 LOG (GNUNET_ERROR_TYPE_DEBUG, 408 LOG (GNUNET_ERROR_TYPE_DEBUG,
409 "regex finds path for %s\n", 409 "Accept state found, now searching for paths to %s\n",
410 GNUNET_h2s (key)); 410 GNUNET_h2s (key),
411 (unsigned int) ctx->position);
411 get_h = GNUNET_DHT_get_start (ctx->info->dht, /* handle */ 412 get_h = GNUNET_DHT_get_start (ctx->info->dht, /* handle */
412 GNUNET_BLOCK_TYPE_REGEX_ACCEPT, /* type */ 413 GNUNET_BLOCK_TYPE_REGEX_ACCEPT, /* type */
413 key, /* key to search */ 414 key, /* key to search */
@@ -432,9 +433,9 @@ regex_find_path (const struct GNUNET_HashCode *key,
432 * @param exp when will this value expire 433 * @param exp when will this value expire
433 * @param key key of the result 434 * @param key key of the result
434 * @param get_path path of the get request (not used) 435 * @param get_path path of the get request (not used)
435 * @param get_path_length lenght of get_path (not used) 436 * @param get_path_length length of @a get_path (not used)
436 * @param put_path path of the put request (not used) 437 * @param put_path path of the put request (not used)
437 * @param put_path_length length of the put_path (not used) 438 * @param put_path_length length of the @a put_path (not used)
438 * @param type type of the result 439 * @param type type of the result
439 * @param size number of bytes in data 440 * @param size number of bytes in data
440 * @param data pointer to the result data 441 * @param data pointer to the result data
@@ -492,7 +493,7 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp,
492 * @param cls Closure (current context)- 493 * @param cls Closure (current context)-
493 * @param key Current key code (key for cached block). 494 * @param key Current key code (key for cached block).
494 * @param value Value in the hash map (cached RegexBlock). 495 * @param value Value in the hash map (cached RegexBlock).
495 * @return GNUNET_YES: we should always continue to iterate. 496 * @return #GNUNET_YES: we should always continue to iterate.
496 */ 497 */
497static int 498static int
498regex_result_iterator (void *cls, 499regex_result_iterator (void *cls,
@@ -533,8 +534,7 @@ regex_result_iterator (void *cls,
533 * @param token Token that follows to next state. 534 * @param token Token that follows to next state.
534 * @param len Lenght of token. 535 * @param len Lenght of token.
535 * @param key Hash of next state. 536 * @param key Hash of next state.
536 * 537 * @return #GNUNET_YES if should keep iterating, #GNUNET_NO otherwise.
537 * @return GNUNET_YES if should keep iterating, GNUNET_NO otherwise.
538 */ 538 */
539static int 539static int
540regex_edge_iterator (void *cls, 540regex_edge_iterator (void *cls,
@@ -636,9 +636,11 @@ regex_next_edge (const struct RegexBlock *block,
636 GNUNET_STATISTICS_update (info->stats, "# regex nodes traversed", 636 GNUNET_STATISTICS_update (info->stats, "# regex nodes traversed",
637 1, GNUNET_NO); 637 1, GNUNET_NO);
638 638
639 LOG (GNUNET_ERROR_TYPE_INFO, 639 LOG (GNUNET_ERROR_TYPE_DEBUG,
640 "looking for %s\n", 640 "Following edges at %s for offset %u in `%s'\n",
641 GNUNET_h2s (hash)); 641 GNUNET_h2s (hash),
642 (unsigned int) ctx->position,
643 info->description);
642 rest = &new_ctx->info->description[new_ctx->position]; 644 rest = &new_ctx->info->description[new_ctx->position];
643 get_h = 645 get_h =
644 GNUNET_DHT_get_start (info->dht, /* handle */ 646 GNUNET_DHT_get_start (info->dht, /* handle */
@@ -663,7 +665,7 @@ regex_next_edge (const struct RegexBlock *block,
663 665
664/** 666/**
665 * Search for a peer offering a regex matching certain string in the DHT. 667 * Search for a peer offering a regex matching certain string in the DHT.
666 * The search runs until REGEX_INTERNAL_search_cancel is called, even if results 668 * The search runs until #REGEX_INTERNAL_search_cancel() is called, even if results
667 * are returned. 669 * are returned.
668 * 670 *
669 * @param dht An existing and valid DHT service handle. 671 * @param dht An existing and valid DHT service handle.
@@ -671,16 +673,15 @@ regex_next_edge (const struct RegexBlock *block,
671 * @param callback Callback for found peers. 673 * @param callback Callback for found peers.
672 * @param callback_cls Closure for @c callback. 674 * @param callback_cls Closure for @c callback.
673 * @param stats Optional statistics handle to report usage. Can be NULL. 675 * @param stats Optional statistics handle to report usage. Can be NULL.
674 *
675 * @return Handle to stop search and free resources. 676 * @return Handle to stop search and free resources.
676 * Must be freed by calling REGEX_INTERNAL_search_cancel. 677 * Must be freed by calling #REGEX_INTERNAL_search_cancel().
677 */ 678 */
678struct REGEX_INTERNAL_Search * 679struct REGEX_INTERNAL_Search *
679REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht, 680REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht,
680 const char *string, 681 const char *string,
681 REGEX_INTERNAL_Found callback, 682 REGEX_INTERNAL_Found callback,
682 void *callback_cls, 683 void *callback_cls,
683 struct GNUNET_STATISTICS_Handle *stats) 684 struct GNUNET_STATISTICS_Handle *stats)
684{ 685{
685 struct REGEX_INTERNAL_Search *h; 686 struct REGEX_INTERNAL_Search *h;
686 struct GNUNET_DHT_GetHandle *get_h; 687 struct GNUNET_DHT_GetHandle *get_h;
@@ -690,7 +691,6 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht,
690 size_t len; 691 size_t len;
691 692
692 /* Initialize handle */ 693 /* Initialize handle */
693 LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_INTERNAL_search: %s\n", string);
694 GNUNET_assert (NULL != dht); 694 GNUNET_assert (NULL != dht);
695 GNUNET_assert (NULL != callback); 695 GNUNET_assert (NULL != callback);
696 h = GNUNET_new (struct REGEX_INTERNAL_Search); 696 h = GNUNET_new (struct REGEX_INTERNAL_Search);
@@ -706,17 +706,17 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht,
706 len = strlen (string); 706 len = strlen (string);
707 size = REGEX_INTERNAL_get_first_key (string, len, &key); 707 size = REGEX_INTERNAL_get_first_key (string, len, &key);
708 LOG (GNUNET_ERROR_TYPE_INFO, 708 LOG (GNUNET_ERROR_TYPE_INFO,
709 " initial key for %s: %s (%.*s)\n", 709 "Initial key for `%s' is %s (based on `%.*s')\n",
710 string, GNUNET_h2s (&key), size, string); 710 string,
711 GNUNET_h2s (&key),
712 size,
713 string);
711 ctx = GNUNET_new (struct RegexSearchContext); 714 ctx = GNUNET_new (struct RegexSearchContext);
712 ctx->position = size; 715 ctx->position = size;
713 ctx->info = h; 716 ctx->info = h;
714 GNUNET_array_append (h->contexts, h->n_contexts, ctx); 717 GNUNET_array_append (h->contexts,
715 LOG (GNUNET_ERROR_TYPE_DEBUG, 718 h->n_contexts,
716 "consumed %u bits out of %u, now looking for %s\n", 719 ctx);
717 size, len,
718 GNUNET_h2s (&key));
719
720 /* Start search in DHT */ 720 /* Start search in DHT */
721 get_h = GNUNET_DHT_get_start (h->dht, /* handle */ 721 get_h = GNUNET_DHT_get_start (h->dht, /* handle */
722 GNUNET_BLOCK_TYPE_REGEX, /* type */ 722 GNUNET_BLOCK_TYPE_REGEX, /* type */
@@ -747,8 +747,8 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht,
747 * @param cls Closure (unused). 747 * @param cls Closure (unused).
748 * @param key Current key code (unused). 748 * @param key Current key code (unused).
749 * @param value Value in the hash map (get handle). 749 * @param value Value in the hash map (get handle).
750 * @return GNUNET_YES if we should continue to iterate, 750 * @return #GNUNET_YES if we should continue to iterate,
751 * GNUNET_NO if not. 751 * #GNUNET_NO if not.
752 */ 752 */
753static int 753static int
754regex_cancel_dht_get (void *cls, 754regex_cancel_dht_get (void *cls,
@@ -769,8 +769,8 @@ regex_cancel_dht_get (void *cls,
769 * @param cls Closure (unused). 769 * @param cls Closure (unused).
770 * @param key Current key code (unused). 770 * @param key Current key code (unused).
771 * @param value CadetRegexBlock in the hash map. 771 * @param value CadetRegexBlock in the hash map.
772 * @return GNUNET_YES if we should continue to iterate, 772 * @return #GNUNET_YES if we should continue to iterate,
773 * GNUNET_NO if not. 773 * #GNUNET_NO if not.
774 */ 774 */
775static int 775static int
776regex_free_result (void *cls, 776regex_free_result (void *cls,