aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_block_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-20 17:19:47 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-20 17:19:47 +0100
commitf6f7fbbe98c110867febbcca647da8308be123c7 (patch)
treeaf69447cf4f08c417197685855c097c132aea8a1 /src/include/gnunet_block_lib.h
parenta3882b58f1c5976677aa65b0af8a48e8e946b06e (diff)
downloadgnunet-f6f7fbbe98c110867febbcca647da8308be123c7.tar.gz
gnunet-f6f7fbbe98c110867febbcca647da8308be123c7.zip
completed big block refactoring in preparation for SET-BLOCK integration
Diffstat (limited to 'src/include/gnunet_block_lib.h')
-rw-r--r--src/include/gnunet_block_lib.h49
1 files changed, 34 insertions, 15 deletions
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index 0f0fee499..a40f33699 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -245,6 +245,7 @@ struct GNUNET_BLOCK_Group;
245 * @param nonce random value used to seed the group creation 245 * @param nonce random value used to seed the group creation
246 * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh 246 * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh
247 * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh 247 * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh
248 * @param ... type-specific additional data, can be empty
248 * @return block group handle, NULL if block groups are not supported 249 * @return block group handle, NULL if block groups are not supported
249 * by this @a type of block (this is not an error) 250 * by this @a type of block (this is not an error)
250 */ 251 */
@@ -253,13 +254,15 @@ GNUNET_BLOCK_group_create (struct GNUNET_BLOCK_Context *ctx,
253 enum GNUNET_BLOCK_Type type, 254 enum GNUNET_BLOCK_Type type,
254 uint32_t nonce, 255 uint32_t nonce,
255 const void *raw_data, 256 const void *raw_data,
256 size_t raw_data_size); 257 size_t raw_data_size,
258 ...);
257 259
258 260
259/** 261/**
260 * Serialize state of a block group. 262 * Serialize state of a block group.
261 * 263 *
262 * @param bg group to serialize 264 * @param bg group to serialize
265 * @param[out] nonce set to the nonce of the @a bg
263 * @param[out] raw_data set to the serialized state 266 * @param[out] raw_data set to the serialized state
264 * @param[out] raw_data_size set to the number of bytes in @a raw_data 267 * @param[out] raw_data_size set to the number of bytes in @a raw_data
265 * @return #GNUNET_OK on success, #GNUNET_NO if serialization is not 268 * @return #GNUNET_OK on success, #GNUNET_NO if serialization is not
@@ -267,6 +270,7 @@ GNUNET_BLOCK_group_create (struct GNUNET_BLOCK_Context *ctx,
267 */ 270 */
268int 271int
269GNUNET_BLOCK_group_serialize (struct GNUNET_BLOCK_Group *bg, 272GNUNET_BLOCK_group_serialize (struct GNUNET_BLOCK_Group *bg,
273 uint32_t *nonce,
270 void **raw_data, 274 void **raw_data,
271 size_t *raw_data_size); 275 size_t *raw_data_size);
272 276
@@ -289,10 +293,9 @@ GNUNET_BLOCK_group_destroy (struct GNUNET_BLOCK_Group *bg);
289 * 293 *
290 * @param ctx block contxt 294 * @param ctx block contxt
291 * @param type block type 295 * @param type block type
296 * @param group block group to use for evaluation
292 * @param eo evaluation options to control evaluation 297 * @param eo evaluation options to control evaluation
293 * @param query original query (hash) 298 * @param query original query (hash)
294 * @param bf pointer to bloom filter associated with query; possibly updated (!)
295 * @param bf_mutator mutation value for @a bf
296 * @param xquery extrended query data (can be NULL, depending on type) 299 * @param xquery extrended query data (can be NULL, depending on type)
297 * @param xquery_size number of bytes in @a xquery 300 * @param xquery_size number of bytes in @a xquery
298 * @param reply_block response to validate 301 * @param reply_block response to validate
@@ -302,10 +305,9 @@ GNUNET_BLOCK_group_destroy (struct GNUNET_BLOCK_Group *bg);
302enum GNUNET_BLOCK_EvaluationResult 305enum GNUNET_BLOCK_EvaluationResult
303GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, 306GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx,
304 enum GNUNET_BLOCK_Type type, 307 enum GNUNET_BLOCK_Type type,
308 struct GNUNET_BLOCK_Group *group,
305 enum GNUNET_BLOCK_EvaluationOptions eo, 309 enum GNUNET_BLOCK_EvaluationOptions eo,
306 const struct GNUNET_HashCode *query, 310 const struct GNUNET_HashCode *query,
307 struct GNUNET_CONTAINER_BloomFilter **bf,
308 int32_t bf_mutator,
309 const void *xquery, 311 const void *xquery,
310 size_t xquery_size, 312 size_t xquery_size,
311 const void *reply_block, 313 const void *reply_block,
@@ -330,24 +332,41 @@ GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx,
330 enum GNUNET_BLOCK_Type type, 332 enum GNUNET_BLOCK_Type type,
331 const void *block, 333 const void *block,
332 size_t block_size, 334 size_t block_size,
333 struct GNUNET_HashCode * key); 335 struct GNUNET_HashCode *key);
334
335 336
336 337
337/** 338/**
338 * Construct a bloom filter that would filter out the given 339 * Update block group to filter out the given results. Note that the
339 * results. 340 * use of a hash for seen results implies that the caller magically
341 * knows how the specific block engine hashes for filtering
342 * duplicates, so this API may not always apply.
340 * 343 *
341 * @param bf_mutator mutation value to use 344 * @param bf_mutator mutation value to use
342 * @param seen_results results already seen 345 * @param seen_results results already seen
343 * @param seen_results_count number of entries in @a seen_results 346 * @param seen_results_count number of entries in @a seen_results
344 * @return NULL if seen_results_count is 0, otherwise a BF 347 * @return #GNUNET_SYSERR if not supported, #GNUNET_OK on success
345 * that would match the given results. 348 */
349int
350GNUNET_BLOCK_group_set_seen (struct GNUNET_BLOCK_Group *bg,
351 const struct GNUNET_HashCode *seen_results,
352 unsigned int seen_results_count);
353
354
355/**
356 * Try merging two block groups. Afterwards, @a bg1 should remain
357 * valid and contain the rules from both @a bg1 and @bg2, and
358 * @a bg2 should be destroyed (as part of this call). The latter
359 * should happen even if merging is not supported.
360 *
361 * @param[in,out] bg1 first group to merge, is updated
362 * @param bg2 second group to merge, is destroyed
363 * @return #GNUNET_OK on success,
364 * #GNUNET_NO if merge failed due to different nonce
365 * #GNUNET_SYSERR if merging is not supported
346 */ 366 */
347struct GNUNET_CONTAINER_BloomFilter * 367int
348GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator, 368GNUNET_BLOCK_group_merge (struct GNUNET_BLOCK_Group *bg1,
349 const struct GNUNET_HashCode *seen_results, 369 struct GNUNET_BLOCK_Group *bg2);
350 unsigned int seen_results_count);
351 370
352 371
353#if 0 /* keep Emacsens' auto-indent happy */ 372#if 0 /* keep Emacsens' auto-indent happy */