From a3882b58f1c5976677aa65b0af8a48e8e946b06e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 20 Feb 2017 15:09:00 +0100 Subject: first half of new BLOCK API to generalize duplicate detection beyond BFs --- src/dht/plugin_block_dht.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/dht/plugin_block_dht.c') diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index 4256a0fe6..4c5f122a4 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c @@ -25,14 +25,47 @@ * DHT (see fs block plugin) * @author Christian Grothoff */ - #include "platform.h" #include "gnunet_constants.h" #include "gnunet_hello_lib.h" #include "gnunet_block_plugin.h" +#include "gnunet_block_group_lib.h" #define DEBUG_DHT GNUNET_EXTRA_LOGGING +/** + * How big is the BF we use for DHT blocks? + */ +#define DHT_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_dht_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, + DHT_BF_SIZE, + GNUNET_CONSTANTS_BLOOMFILTER_K, + type, + nonce, + raw_data, + raw_data_size); +} + /** * Function called to validate a reply or a request. For @@ -182,6 +215,7 @@ libgnunet_plugin_block_dht_init (void *cls) api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); api->evaluate = &block_plugin_dht_evaluate; api->get_key = &block_plugin_dht_get_key; + api->create_group = &block_plugin_dht_create_group; api->types = types; return api; } -- cgit v1.2.3