aboutsummaryrefslogtreecommitdiff
path: root/src/dht/plugin_block_dht.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-20 15:09:00 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-20 15:09:19 +0100
commita3882b58f1c5976677aa65b0af8a48e8e946b06e (patch)
treebd841d8e78052a05821e194d002ca843693fb2c9 /src/dht/plugin_block_dht.c
parentf0149c5430f42a8bad422e9c51754af59c7bfa2f (diff)
first half of new BLOCK API to generalize duplicate detection beyond BFs
Diffstat (limited to 'src/dht/plugin_block_dht.c')
-rw-r--r--src/dht/plugin_block_dht.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c
index 4256a0fe64..4c5f122a4f 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;
}