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/fs/plugin_block_fs.c | |
parent | f0149c5430f42a8bad422e9c51754af59c7bfa2f (diff) | |
download | gnunet-a3882b58f1c5976677aa65b0af8a48e8e946b06e.tar.gz gnunet-a3882b58f1c5976677aa65b0af8a48e8e946b06e.zip |
first half of new BLOCK API to generalize duplicate detection beyond BFs
Diffstat (limited to 'src/fs/plugin_block_fs.c')
-rw-r--r-- | src/fs/plugin_block_fs.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c index 415a2e3ed..038734082 100644 --- a/src/fs/plugin_block_fs.c +++ b/src/fs/plugin_block_fs.c | |||
@@ -23,12 +23,12 @@ | |||
23 | * @brief blocks used for file-sharing | 23 | * @brief blocks used for file-sharing |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | |||
27 | #include "platform.h" | 26 | #include "platform.h" |
28 | #include "gnunet_block_plugin.h" | 27 | #include "gnunet_block_plugin.h" |
29 | #include "gnunet_fs_service.h" | 28 | #include "gnunet_fs_service.h" |
30 | #include "block_fs.h" | 29 | #include "block_fs.h" |
31 | #include "gnunet_signatures.h" | 30 | #include "gnunet_signatures.h" |
31 | #include "gnunet_block_group_lib.h" | ||
32 | 32 | ||
33 | 33 | ||
34 | /** | 34 | /** |
@@ -38,6 +38,51 @@ | |||
38 | #define BLOOMFILTER_K 16 | 38 | #define BLOOMFILTER_K 16 |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * How big is the BF we use for FS blocks? | ||
42 | */ | ||
43 | #define FS_BF_SIZE 8 | ||
44 | |||
45 | |||
46 | /** | ||
47 | * Create a new block group. | ||
48 | * | ||
49 | * @param ctx block context in which the block group is created | ||
50 | * @param type type of the block for which we are creating the group | ||
51 | * @param nonce random value used to seed the group creation | ||
52 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh | ||
53 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh | ||
54 | * @return block group handle, NULL if block groups are not supported | ||
55 | * by this @a type of block (this is not an error) | ||
56 | */ | ||
57 | static struct GNUNET_BLOCK_Group * | ||
58 | block_plugin_fs_create_group (void *cls, | ||
59 | enum GNUNET_BLOCK_Type type, | ||
60 | uint32_t nonce, | ||
61 | const void *raw_data, | ||
62 | size_t raw_data_size) | ||
63 | { | ||
64 | switch (type) | ||
65 | { | ||
66 | case GNUNET_BLOCK_TYPE_FS_DBLOCK: | ||
67 | return NULL; | ||
68 | case GNUNET_BLOCK_TYPE_FS_IBLOCK: | ||
69 | return NULL; | ||
70 | case GNUNET_BLOCK_TYPE_FS_UBLOCK: | ||
71 | return GNUNET_BLOCK_GROUP_bf_create (cls, | ||
72 | FS_BF_SIZE, | ||
73 | BLOOMFILTER_K, | ||
74 | type, | ||
75 | nonce, | ||
76 | raw_data, | ||
77 | raw_data_size); | ||
78 | default: | ||
79 | GNUNET_break (0); | ||
80 | return NULL; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | |||
85 | /** | ||
41 | * Function called to validate a reply or a request. For | 86 | * Function called to validate a reply or a request. For |
42 | * request evaluation, simply pass "NULL" for the reply_block. | 87 | * request evaluation, simply pass "NULL" for the reply_block. |
43 | * Note that it is assumed that the reply has already been | 88 | * Note that it is assumed that the reply has already been |
@@ -214,6 +259,7 @@ libgnunet_plugin_block_fs_init (void *cls) | |||
214 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | 259 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
215 | api->evaluate = &block_plugin_fs_evaluate; | 260 | api->evaluate = &block_plugin_fs_evaluate; |
216 | api->get_key = &block_plugin_fs_get_key; | 261 | api->get_key = &block_plugin_fs_get_key; |
262 | api->create_group = &block_plugin_fs_create_group; | ||
217 | api->types = types; | 263 | api->types = types; |
218 | return api; | 264 | return api; |
219 | } | 265 | } |