/**
- * Iterator over edges in a regex block retrieved from the DHT.
+ * Jump to the next edge, with the longest matching token.
*
- * @param cls Closure.
- * @param token Token that follows to next state.
- * @param len Lenght of token.
- * @param key Hash of next state.
+ * @param block Block found in the DHT.
+ * @param size Size of the block.
+ * @param ctx Context of the search.
*
* @return GNUNET_YES if should keep iterating, GNUNET_NO otherwise.
*/
-static int
-regex_edge_iterator (void *cls,
- const char *token,
- size_t len,
- const struct GNUNET_HashCode *key);
+static void
+regex_next_edge (const struct MeshRegexBlock *block,
+ size_t size,
+ struct MeshRegexSearchContext *ctx);
/**
ntohl(block->accepting));
}
- (void) GNUNET_MESH_regex_block_iterate (block, SIZE_MAX,
- ®ex_edge_iterator, ctx);
+ regex_next_edge(block, SIZE_MAX, ctx);
return GNUNET_YES;
}
ctx->longest_match = len;
ctx->hash = *key;
}
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Token is not longer, IGNORE\n");
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* End of regex edge iterator\n");
return GNUNET_YES;
struct MeshRegexSearchInfo *info = ctx->info;
struct GNUNET_DHT_GetHandle *get_h;
+ /* Find the longest match for the current string position,
+ * among tokens in the given block */
GNUNET_break (GNUNET_OK ==
GNUNET_MESH_regex_block_iterate (block, size,
®ex_edge_iterator, ctx));
new_ctx->info = info;
new_ctx->position = ctx->position + ctx->longest_match;
GNUNET_array_append (info->contexts, info->n_contexts, new_ctx);
+
+ /* Check whether we already have a DHT GET running for it */
if (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_contains(info->dht_get_handles, &ctx->hash))
{
new_ctx);
return; // We are already looking for it
}
+
/* Start search in DHT */
get_h =
GNUNET_DHT_get_start (dht_handle, /* handle */
const struct GNUNET_PeerIdentity *get_path,
unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ unsigned int put_path_length,
+ enum GNUNET_BLOCK_Type type,
size_t size, const void *data)
{
const struct MeshRegexBlock *block = data;