aboutsummaryrefslogtreecommitdiff
path: root/src/dht
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
parentf0149c5430f42a8bad422e9c51754af59c7bfa2f (diff)
downloadgnunet-a3882b58f1c5976677aa65b0af8a48e8e946b06e.tar.gz
gnunet-a3882b58f1c5976677aa65b0af8a48e8e946b06e.zip
first half of new BLOCK API to generalize duplicate detection beyond BFs
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/Makefile.am1
-rw-r--r--src/dht/plugin_block_dht.c36
2 files changed, 36 insertions, 1 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am
index 26beb300b..93dae9f6e 100644
--- a/src/dht/Makefile.am
+++ b/src/dht/Makefile.am
@@ -40,6 +40,7 @@ libgnunet_plugin_block_dht_la_SOURCES = \
40libgnunet_plugin_block_dht_la_LIBADD = \ 40libgnunet_plugin_block_dht_la_LIBADD = \
41 $(top_builddir)/src/hello/libgnunethello.la \ 41 $(top_builddir)/src/hello/libgnunethello.la \
42 $(top_builddir)/src/block/libgnunetblock.la \ 42 $(top_builddir)/src/block/libgnunetblock.la \
43 $(top_builddir)/src/block/libgnunetblockgroup.la \
43 $(top_builddir)/src/util/libgnunetutil.la \ 44 $(top_builddir)/src/util/libgnunetutil.la \
44 $(LTLIBINTL) 45 $(LTLIBINTL)
45libgnunet_plugin_block_dht_la_LDFLAGS = \ 46libgnunet_plugin_block_dht_la_LDFLAGS = \
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 @@
25 * DHT (see fs block plugin) 25 * DHT (see fs block plugin)
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 */ 27 */
28
29#include "platform.h" 28#include "platform.h"
30#include "gnunet_constants.h" 29#include "gnunet_constants.h"
31#include "gnunet_hello_lib.h" 30#include "gnunet_hello_lib.h"
32#include "gnunet_block_plugin.h" 31#include "gnunet_block_plugin.h"
32#include "gnunet_block_group_lib.h"
33 33
34#define DEBUG_DHT GNUNET_EXTRA_LOGGING 34#define DEBUG_DHT GNUNET_EXTRA_LOGGING
35 35
36/**
37 * How big is the BF we use for DHT blocks?
38 */
39#define DHT_BF_SIZE 8
40
41
42/**
43 * Create a new block group.
44 *
45 * @param ctx block context in which the block group is created
46 * @param type type of the block for which we are creating the group
47 * @param nonce random value used to seed the group creation
48 * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh
49 * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh
50 * @return block group handle, NULL if block groups are not supported
51 * by this @a type of block (this is not an error)
52 */
53static struct GNUNET_BLOCK_Group *
54block_plugin_dht_create_group (void *cls,
55 enum GNUNET_BLOCK_Type type,
56 uint32_t nonce,
57 const void *raw_data,
58 size_t raw_data_size)
59{
60 return GNUNET_BLOCK_GROUP_bf_create (cls,
61 DHT_BF_SIZE,
62 GNUNET_CONSTANTS_BLOOMFILTER_K,
63 type,
64 nonce,
65 raw_data,
66 raw_data_size);
67}
68
36 69
37/** 70/**
38 * Function called to validate a reply or a request. For 71 * Function called to validate a reply or a request. For
@@ -182,6 +215,7 @@ libgnunet_plugin_block_dht_init (void *cls)
182 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); 215 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
183 api->evaluate = &block_plugin_dht_evaluate; 216 api->evaluate = &block_plugin_dht_evaluate;
184 api->get_key = &block_plugin_dht_get_key; 217 api->get_key = &block_plugin_dht_get_key;
218 api->create_group = &block_plugin_dht_create_group;
185 api->types = types; 219 api->types = types;
186 return api; 220 return api;
187} 221}