diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-12 19:02:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-12 19:02:54 +0000 |
commit | 16bcbbea7133fd2265d46bd2ae1dc70e8c9ba96f (patch) | |
tree | d2c0623207ca6a42bb0c42ff46b1f3124c37776c /src/block/plugin_block_template.c | |
parent | 8130491b698c5e7972c46072476f4cf0af94e82b (diff) | |
download | gnunet-16bcbbea7133fd2265d46bd2ae1dc70e8c9ba96f.tar.gz gnunet-16bcbbea7133fd2265d46bd2ae1dc70e8c9ba96f.zip |
-adding block duplicating detection to template for block plugins
Diffstat (limited to 'src/block/plugin_block_template.c')
-rw-r--r-- | src/block/plugin_block_template.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c index 6ed675dc9..ca5b8744f 100644 --- a/src/block/plugin_block_template.c +++ b/src/block/plugin_block_template.c | |||
@@ -53,6 +53,27 @@ block_plugin_template_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
53 | size_t xquery_size, const void *reply_block, | 53 | size_t xquery_size, const void *reply_block, |
54 | size_t reply_block_size) | 54 | size_t reply_block_size) |
55 | { | 55 | { |
56 | struct GNUNET_HashCode chash; | ||
57 | struct GNUNET_HashCode mhash; | ||
58 | /* FIXME: check validity first... */ | ||
59 | |||
60 | /* mandatory duplicate-detection code... */ | ||
61 | if (NULL != bf) | ||
62 | { | ||
63 | GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); | ||
64 | GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); | ||
65 | if (NULL != *bf) | ||
66 | { | ||
67 | if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash)) | ||
68 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, 64 /* BLOOMFILTER_K */); | ||
73 | } | ||
74 | GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); | ||
75 | } | ||
76 | /* FIXME: other stuff here... */ | ||
56 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 77 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
57 | } | 78 | } |
58 | 79 | ||