diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-20 15:09:00 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-20 15:09:19 +0100 |
commit | a3882b58f1c5976677aa65b0af8a48e8e946b06e (patch) | |
tree | bd841d8e78052a05821e194d002ca843693fb2c9 /src/regex | |
parent | f0149c5430f42a8bad422e9c51754af59c7bfa2f (diff) |
first half of new BLOCK API to generalize duplicate detection beyond BFs
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/Makefile.am | 1 | ||||
-rw-r--r-- | src/regex/plugin_block_regex.c | 37 |
2 files changed, 37 insertions, 1 deletions
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am index 70f612485a..80997db40f 100644 --- a/src/regex/Makefile.am +++ b/src/regex/Makefile.am @@ -80,6 +80,7 @@ libgnunet_plugin_block_regex_la_SOURCES = \ libgnunet_plugin_block_regex_la_LIBADD = \ libgnunetregexblock.la \ $(top_builddir)/src/block/libgnunetblock.la \ + $(top_builddir)/src/block/libgnunetblockgroup.la \ $(top_builddir)/src/util/libgnunetutil.la libgnunet_plugin_block_regex_la_LDFLAGS = \ $(GN_PLUGIN_LDFLAGS) 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; } |