diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-28 21:12:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-28 21:12:03 +0000 |
commit | 3a2737d76679c68331fad0be0b89d8efdcde5079 (patch) | |
tree | 5bd4ef163438954cdcb75558e6368a297629b56d /src/block | |
parent | 9c46ed792caae948fd99cca44deaf5a265af7614 (diff) | |
download | gnunet-3a2737d76679c68331fad0be0b89d8efdcde5079.tar.gz gnunet-3a2737d76679c68331fad0be0b89d8efdcde5079.zip |
-extend block API to allow specifying flags, use this to allow reducing checks for replies from local DB
Diffstat (limited to 'src/block')
-rw-r--r-- | src/block/block.c | 36 | ||||
-rw-r--r-- | src/block/plugin_block_template.c | 13 | ||||
-rw-r--r-- | src/block/plugin_block_test.c | 13 |
3 files changed, 43 insertions, 19 deletions
diff --git a/src/block/block.c b/src/block/block.c index e4ce585e7..0e7b4a6ba 100644 --- a/src/block/block.c +++ b/src/block/block.c | |||
@@ -197,6 +197,7 @@ find_plugin (struct GNUNET_BLOCK_Context *ctx, | |||
197 | * | 197 | * |
198 | * @param ctx block contxt | 198 | * @param ctx block contxt |
199 | * @param type block type | 199 | * @param type block type |
200 | * @param eo control flags | ||
200 | * @param query original query (hash) | 201 | * @param query original query (hash) |
201 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | 202 | * @param bf pointer to bloom filter associated with query; possibly updated (!) |
202 | * @param bf_mutator mutation value for @a bf | 203 | * @param bf_mutator mutation value for @a bf |
@@ -209,18 +210,29 @@ find_plugin (struct GNUNET_BLOCK_Context *ctx, | |||
209 | enum GNUNET_BLOCK_EvaluationResult | 210 | enum GNUNET_BLOCK_EvaluationResult |
210 | GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, | 211 | GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, |
211 | enum GNUNET_BLOCK_Type type, | 212 | enum GNUNET_BLOCK_Type type, |
212 | const struct GNUNET_HashCode * query, | 213 | enum GNUNET_BLOCK_EvaluationOptions eo, |
214 | const struct GNUNET_HashCode *query, | ||
213 | struct GNUNET_CONTAINER_BloomFilter **bf, | 215 | struct GNUNET_CONTAINER_BloomFilter **bf, |
214 | int32_t bf_mutator, const void *xquery, | 216 | int32_t bf_mutator, |
215 | size_t xquery_size, const void *reply_block, | 217 | const void *xquery, |
218 | size_t xquery_size, | ||
219 | const void *reply_block, | ||
216 | size_t reply_block_size) | 220 | size_t reply_block_size) |
217 | { | 221 | { |
218 | struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type); | 222 | struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type); |
219 | 223 | ||
220 | if (plugin == NULL) | 224 | if (plugin == NULL) |
221 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 225 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
222 | return plugin->evaluate (plugin->cls, type, query, bf, bf_mutator, xquery, | 226 | return plugin->evaluate (plugin->cls, |
223 | xquery_size, reply_block, reply_block_size); | 227 | type, |
228 | eo, | ||
229 | query, | ||
230 | bf, | ||
231 | bf_mutator, | ||
232 | xquery, | ||
233 | xquery_size, | ||
234 | reply_block, | ||
235 | reply_block_size); | ||
224 | } | 236 | } |
225 | 237 | ||
226 | 238 | ||
@@ -237,8 +249,10 @@ GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, | |||
237 | */ | 249 | */ |
238 | int | 250 | int |
239 | GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, | 251 | GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, |
240 | enum GNUNET_BLOCK_Type type, const void *block, | 252 | enum GNUNET_BLOCK_Type type, |
241 | size_t block_size, struct GNUNET_HashCode * key) | 253 | const void *block, |
254 | size_t block_size, | ||
255 | struct GNUNET_HashCode *key) | ||
242 | { | 256 | { |
243 | struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type); | 257 | struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type); |
244 | 258 | ||
@@ -250,9 +264,9 @@ GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, | |||
250 | 264 | ||
251 | /** | 265 | /** |
252 | * How many bytes should a bloomfilter be if we have already seen | 266 | * How many bytes should a bloomfilter be if we have already seen |
253 | * entry_count responses? Note that GNUNET_CONSTANTS_BLOOMFILTER_K gives us the number | 267 | * entry_count responses? Note that #GNUNET_CONSTANTS_BLOOMFILTER_K |
254 | * of bits set per entry. Furthermore, we should not re-size the | 268 | * gives us the number of bits set per entry. Furthermore, we should |
255 | * filter too often (to keep it cheap). | 269 | * not re-size the filter too often (to keep it cheap). |
256 | * | 270 | * |
257 | * Since other peers will also add entries but not resize the filter, | 271 | * Since other peers will also add entries but not resize the filter, |
258 | * we should generally pick a slightly larger size than what the | 272 | * we should generally pick a slightly larger size than what the |
@@ -291,7 +305,7 @@ compute_bloomfilter_size (unsigned int entry_count) | |||
291 | */ | 305 | */ |
292 | struct GNUNET_CONTAINER_BloomFilter * | 306 | struct GNUNET_CONTAINER_BloomFilter * |
293 | GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator, | 307 | GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator, |
294 | const struct GNUNET_HashCode * seen_results, | 308 | const struct GNUNET_HashCode *seen_results, |
295 | unsigned int seen_results_count) | 309 | unsigned int seen_results_count) |
296 | { | 310 | { |
297 | struct GNUNET_CONTAINER_BloomFilter *bf; | 311 | struct GNUNET_CONTAINER_BloomFilter *bf; |
diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c index 9132d7557..3cb648db7 100644 --- a/src/block/plugin_block_template.c +++ b/src/block/plugin_block_template.c | |||
@@ -36,6 +36,7 @@ | |||
36 | * | 36 | * |
37 | * @param cls closure | 37 | * @param cls closure |
38 | * @param type block type | 38 | * @param type block type |
39 | * @param eo control flags | ||
39 | * @param query original query (hash) | 40 | * @param query original query (hash) |
40 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | 41 | * @param bf pointer to bloom filter associated with query; possibly updated (!) |
41 | * @param bf_mutator mutation value for bf | 42 | * @param bf_mutator mutation value for bf |
@@ -46,11 +47,15 @@ | |||
46 | * @return characterization of result | 47 | * @return characterization of result |
47 | */ | 48 | */ |
48 | static enum GNUNET_BLOCK_EvaluationResult | 49 | static enum GNUNET_BLOCK_EvaluationResult |
49 | block_plugin_template_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | 50 | block_plugin_template_evaluate (void *cls, |
50 | const struct GNUNET_HashCode * query, | 51 | enum GNUNET_BLOCK_Type type, |
52 | enum GNUNET_BLOCK_EvaluationOptions eo, | ||
53 | const struct GNUNET_HashCode *query, | ||
51 | struct GNUNET_CONTAINER_BloomFilter **bf, | 54 | struct GNUNET_CONTAINER_BloomFilter **bf, |
52 | int32_t bf_mutator, const void *xquery, | 55 | int32_t bf_mutator, |
53 | size_t xquery_size, const void *reply_block, | 56 | const void *xquery, |
57 | size_t xquery_size, | ||
58 | const void *reply_block, | ||
54 | size_t reply_block_size) | 59 | size_t reply_block_size) |
55 | { | 60 | { |
56 | struct GNUNET_HashCode chash; | 61 | struct GNUNET_HashCode chash; |
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c index 8c476aaa3..6859f4f67 100644 --- a/src/block/plugin_block_test.c +++ b/src/block/plugin_block_test.c | |||
@@ -41,6 +41,7 @@ | |||
41 | * | 41 | * |
42 | * @param cls closure | 42 | * @param cls closure |
43 | * @param type block type | 43 | * @param type block type |
44 | * @param eo control flags | ||
44 | * @param query original query (hash) | 45 | * @param query original query (hash) |
45 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | 46 | * @param bf pointer to bloom filter associated with query; possibly updated (!) |
46 | * @param bf_mutator mutation value for @a bf | 47 | * @param bf_mutator mutation value for @a bf |
@@ -51,11 +52,15 @@ | |||
51 | * @return characterization of result | 52 | * @return characterization of result |
52 | */ | 53 | */ |
53 | static enum GNUNET_BLOCK_EvaluationResult | 54 | static enum GNUNET_BLOCK_EvaluationResult |
54 | block_plugin_test_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | 55 | block_plugin_test_evaluate (void *cls, |
55 | const struct GNUNET_HashCode * query, | 56 | enum GNUNET_BLOCK_Type type, |
57 | enum GNUNET_BLOCK_EvaluationOptions eo, | ||
58 | const struct GNUNET_HashCode *query, | ||
56 | struct GNUNET_CONTAINER_BloomFilter **bf, | 59 | struct GNUNET_CONTAINER_BloomFilter **bf, |
57 | int32_t bf_mutator, const void *xquery, | 60 | int32_t bf_mutator, |
58 | size_t xquery_size, const void *reply_block, | 61 | const void *xquery, |
62 | size_t xquery_size, | ||
63 | const void *reply_block, | ||
59 | size_t reply_block_size) | 64 | size_t reply_block_size) |
60 | { | 65 | { |
61 | struct GNUNET_HashCode chash; | 66 | struct GNUNET_HashCode chash; |