diff options
Diffstat (limited to 'src/regex/plugin_block_regex.c')
-rw-r--r-- | src/regex/plugin_block_regex.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c index 36926c25d5..11511a71b3 100644 --- a/src/regex/plugin_block_regex.c +++ b/src/regex/plugin_block_regex.c @@ -23,9 +23,9 @@ * @brief blocks used for regex storage and search * @author Bartlomiej Polot */ - #include "platform.h" #include "gnunet_block_plugin.h" +#include "gnunet_block_group_lib.h" #include "block_regex.h" #include "regex_block_lib.h" #include "gnunet_constants.h" @@ -33,6 +33,40 @@ /** + * How big is the BF we use for REGEX blocks? + */ +#define REGEX_BF_SIZE 8 + + +/** + * Create a new block group. + * + * @param ctx block context in which the block group is created + * @param type type of the block for which we are creating the group + * @param nonce random value used to seed the group creation + * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh + * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh + * @return block group handle, NULL if block groups are not supported + * by this @a type of block (this is not an error) + */ +static struct GNUNET_BLOCK_Group * +block_plugin_regex_create_group (void *cls, + enum GNUNET_BLOCK_Type type, + uint32_t nonce, + const void *raw_data, + size_t raw_data_size) +{ + return GNUNET_BLOCK_GROUP_bf_create (cls, + REGEX_BF_SIZE, + GNUNET_CONSTANTS_BLOOMFILTER_K, + type, + nonce, + raw_data, + raw_data_size); +} + + +/** * Function called to validate a reply or a request of type * #GNUNET_BLOCK_TYPE_REGEX. * For request evaluation, pass "NULL" for the reply_block. @@ -346,6 +380,7 @@ libgnunet_plugin_block_regex_init (void *cls) api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); api->evaluate = &block_plugin_regex_evaluate; api->get_key = &block_plugin_regex_get_key; + api->create_group = &block_plugin_regex_create_group; api->types = types; return api; } |