diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-20 17:19:47 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-20 17:19:47 +0100 |
commit | f6f7fbbe98c110867febbcca647da8308be123c7 (patch) | |
tree | af69447cf4f08c417197685855c097c132aea8a1 /src/gns | |
parent | a3882b58f1c5976677aa65b0af8a48e8e946b06e (diff) | |
download | gnunet-f6f7fbbe98c110867febbcca647da8308be123c7.tar.gz gnunet-f6f7fbbe98c110867febbcca647da8308be123c7.zip |
completed big block refactoring in preparation for SET-BLOCK integration
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/plugin_block_gns.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index 8d3e84042..94222e32b 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c | |||
@@ -51,6 +51,7 @@ | |||
51 | * @param nonce random value used to seed the group creation | 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 | 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 | 53 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh |
54 | * @param va variable arguments specific to @a type | ||
54 | * @return block group handle, NULL if block groups are not supported | 55 | * @return block group handle, NULL if block groups are not supported |
55 | * by this @a type of block (this is not an error) | 56 | * by this @a type of block (this is not an error) |
56 | */ | 57 | */ |
@@ -59,7 +60,8 @@ block_plugin_gns_create_group (void *cls, | |||
59 | enum GNUNET_BLOCK_Type type, | 60 | enum GNUNET_BLOCK_Type type, |
60 | uint32_t nonce, | 61 | uint32_t nonce, |
61 | const void *raw_data, | 62 | const void *raw_data, |
62 | size_t raw_data_size) | 63 | size_t raw_data_size, |
64 | va_list va) | ||
63 | { | 65 | { |
64 | return GNUNET_BLOCK_GROUP_bf_create (cls, | 66 | return GNUNET_BLOCK_GROUP_bf_create (cls, |
65 | GNS_BF_SIZE, | 67 | GNS_BF_SIZE, |
@@ -80,10 +82,9 @@ block_plugin_gns_create_group (void *cls, | |||
80 | * | 82 | * |
81 | * @param cls closure | 83 | * @param cls closure |
82 | * @param type block type | 84 | * @param type block type |
85 | * @param bg block group to use for evaluation | ||
83 | * @param eo control flags | 86 | * @param eo control flags |
84 | * @param query original query (hash) | 87 | * @param query original query (hash) |
85 | * @param bf pointer to bloom filter associated with @a query; possibly updated (!) | ||
86 | * @param bf_mutator mutation value for @a bf | ||
87 | * @param xquery extrended query data (can be NULL, depending on @a type) | 88 | * @param xquery extrended query data (can be NULL, depending on @a type) |
88 | * @param xquery_size number of bytes in @a xquery | 89 | * @param xquery_size number of bytes in @a xquery |
89 | * @param reply_block response to validate | 90 | * @param reply_block response to validate |
@@ -93,10 +94,9 @@ block_plugin_gns_create_group (void *cls, | |||
93 | static enum GNUNET_BLOCK_EvaluationResult | 94 | static enum GNUNET_BLOCK_EvaluationResult |
94 | block_plugin_gns_evaluate (void *cls, | 95 | block_plugin_gns_evaluate (void *cls, |
95 | enum GNUNET_BLOCK_Type type, | 96 | enum GNUNET_BLOCK_Type type, |
97 | struct GNUNET_BLOCK_Group *bg, | ||
96 | enum GNUNET_BLOCK_EvaluationOptions eo, | 98 | enum GNUNET_BLOCK_EvaluationOptions eo, |
97 | const struct GNUNET_HashCode *query, | 99 | const struct GNUNET_HashCode *query, |
98 | struct GNUNET_CONTAINER_BloomFilter **bf, | ||
99 | int32_t bf_mutator, | ||
100 | const void *xquery, | 100 | const void *xquery, |
101 | size_t xquery_size, | 101 | size_t xquery_size, |
102 | const void *reply_block, | 102 | const void *reply_block, |
@@ -105,7 +105,6 @@ block_plugin_gns_evaluate (void *cls, | |||
105 | const struct GNUNET_GNSRECORD_Block *block; | 105 | const struct GNUNET_GNSRECORD_Block *block; |
106 | struct GNUNET_HashCode h; | 106 | struct GNUNET_HashCode h; |
107 | struct GNUNET_HashCode chash; | 107 | struct GNUNET_HashCode chash; |
108 | struct GNUNET_HashCode mhash; | ||
109 | 108 | ||
110 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) | 109 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) |
111 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 110 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
@@ -146,21 +145,13 @@ block_plugin_gns_evaluate (void *cls, | |||
146 | GNUNET_break_op (0); | 145 | GNUNET_break_op (0); |
147 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 146 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
148 | } | 147 | } |
149 | if (NULL != bf) | 148 | GNUNET_CRYPTO_hash (reply_block, |
150 | { | 149 | reply_block_size, |
151 | GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); | 150 | &chash); |
152 | GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); | 151 | if (GNUNET_YES == |
153 | if (NULL != *bf) | 152 | GNUNET_BLOCK_GROUP_bf_test_and_set (bg, |
154 | { | 153 | &chash)) |
155 | if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test(*bf, &mhash)) | 154 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; |
156 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | *bf = GNUNET_CONTAINER_bloomfilter_init(NULL, 8, BLOOMFILTER_K); | ||
161 | } | ||
162 | GNUNET_CONTAINER_bloomfilter_add(*bf, &mhash); | ||
163 | } | ||
164 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 155 | return GNUNET_BLOCK_EVALUATION_OK_MORE; |
165 | } | 156 | } |
166 | 157 | ||