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/fs | |
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/fs')
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 139 | ||||
-rw-r--r-- | src/fs/plugin_block_fs.c | 95 | ||||
-rw-r--r-- | src/fs/test_plugin_block_fs.c | 6 |
3 files changed, 142 insertions, 98 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 63462f7dc..87e2d2ee1 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -97,9 +97,9 @@ struct GSF_PendingRequest | |||
97 | struct GNUNET_HashCode *replies_seen; | 97 | struct GNUNET_HashCode *replies_seen; |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Bloomfilter masking replies we've already seen. | 100 | * Block group for filtering replies we've already seen. |
101 | */ | 101 | */ |
102 | struct GNUNET_CONTAINER_BloomFilter *bf; | 102 | struct GNUNET_BLOCK_Group *bg; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * Entry for this pending request in the expiration heap, or NULL. | 105 | * Entry for this pending request in the expiration heap, or NULL. |
@@ -190,11 +190,6 @@ struct GSF_PendingRequest | |||
190 | unsigned int replies_seen_size; | 190 | unsigned int replies_seen_size; |
191 | 191 | ||
192 | /** | 192 | /** |
193 | * Mingle value we currently use for the bf. | ||
194 | */ | ||
195 | uint32_t mingle; | ||
196 | |||
197 | /** | ||
198 | * Do we have a first UID yet? | 193 | * Do we have a first UID yet? |
199 | */ | 194 | */ |
200 | unsigned int have_first_uid; | 195 | unsigned int have_first_uid; |
@@ -248,18 +243,35 @@ static unsigned long long max_pending_requests = (32 * 1024); | |||
248 | * fresh one of minimal size without problems) OR if our peer is the | 243 | * fresh one of minimal size without problems) OR if our peer is the |
249 | * initiator (in which case we may resize to larger than mimimum size). | 244 | * initiator (in which case we may resize to larger than mimimum size). |
250 | * | 245 | * |
246 | * @param type type of the request | ||
251 | * @param pr request for which the BF is to be recomputed | 247 | * @param pr request for which the BF is to be recomputed |
252 | */ | 248 | */ |
253 | static void | 249 | static void |
254 | refresh_bloomfilter (struct GSF_PendingRequest *pr) | 250 | refresh_bloomfilter (enum GNUNET_BLOCK_Type type, |
251 | struct GSF_PendingRequest *pr) | ||
255 | { | 252 | { |
256 | if (pr->bf != NULL) | 253 | if (NULL != pr->bg) |
257 | GNUNET_CONTAINER_bloomfilter_free (pr->bf); | 254 | { |
258 | pr->mingle = | 255 | GNUNET_BLOCK_group_destroy (pr->bg); |
259 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); | 256 | pr->bg = NULL; |
260 | pr->bf = | 257 | } |
261 | GNUNET_BLOCK_construct_bloomfilter (pr->mingle, pr->replies_seen, | 258 | if (GNUNET_BLOCK_TYPE_FS_UBLOCK != type) |
262 | pr->replies_seen_count); | 259 | return; /* no need */ |
260 | pr->bg | ||
261 | = GNUNET_BLOCK_group_create (GSF_block_ctx, | ||
262 | type, | ||
263 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
264 | UINT32_MAX), | ||
265 | NULL, | ||
266 | 0, | ||
267 | "fs-seen-set-size", | ||
268 | pr->replies_seen_count); | ||
269 | if (NULL == pr->bg) | ||
270 | return; | ||
271 | GNUNET_break (GNUNET_OK == | ||
272 | GNUNET_BLOCK_group_set_seen (pr->bg, | ||
273 | pr->replies_seen, | ||
274 | pr->replies_seen_count)); | ||
263 | } | 275 | } |
264 | 276 | ||
265 | 277 | ||
@@ -355,25 +367,30 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, | |||
355 | if (replies_seen_count > 0) | 367 | if (replies_seen_count > 0) |
356 | { | 368 | { |
357 | pr->replies_seen_size = replies_seen_count; | 369 | pr->replies_seen_size = replies_seen_count; |
358 | pr->replies_seen = | 370 | pr->replies_seen = GNUNET_new_array (pr->replies_seen_size, |
359 | GNUNET_malloc (sizeof (struct GNUNET_HashCode) * pr->replies_seen_size); | 371 | struct GNUNET_HashCode); |
360 | GNUNET_memcpy (pr->replies_seen, | 372 | GNUNET_memcpy (pr->replies_seen, |
361 | replies_seen, | 373 | replies_seen, |
362 | replies_seen_count * sizeof (struct GNUNET_HashCode)); | 374 | replies_seen_count * sizeof (struct GNUNET_HashCode)); |
363 | pr->replies_seen_count = replies_seen_count; | 375 | pr->replies_seen_count = replies_seen_count; |
364 | } | 376 | } |
365 | if (NULL != bf_data) | 377 | if ( (NULL != bf_data) && |
378 | (GNUNET_BLOCK_TYPE_FS_UBLOCK == pr->public_data.type) ) | ||
366 | { | 379 | { |
367 | pr->bf = | 380 | pr->bg |
368 | GNUNET_CONTAINER_bloomfilter_init (bf_data, | 381 | = GNUNET_BLOCK_group_create (GSF_block_ctx, |
369 | bf_size, | 382 | pr->public_data.type, |
370 | GNUNET_CONSTANTS_BLOOMFILTER_K); | 383 | mingle, |
371 | pr->mingle = mingle; | 384 | bf_data, |
385 | bf_size, | ||
386 | "fs-seen-set-size", | ||
387 | 0); | ||
372 | } | 388 | } |
373 | else if ((replies_seen_count > 0) && | 389 | else if ((replies_seen_count > 0) && |
374 | (0 != (options & GSF_PRO_BLOOMFILTER_FULL_REFRESH))) | 390 | (0 != (options & GSF_PRO_BLOOMFILTER_FULL_REFRESH))) |
375 | { | 391 | { |
376 | refresh_bloomfilter (pr); | 392 | refresh_bloomfilter (pr->public_data.type, |
393 | pr); | ||
377 | } | 394 | } |
378 | GNUNET_CONTAINER_multihashmap_put (pr_map, | 395 | GNUNET_CONTAINER_multihashmap_put (pr_map, |
379 | &pr->public_data.query, | 396 | &pr->public_data.query, |
@@ -461,46 +478,37 @@ GSF_pending_request_update_ (struct GSF_PendingRequest *pr, | |||
461 | const struct GNUNET_HashCode * replies_seen, | 478 | const struct GNUNET_HashCode * replies_seen, |
462 | unsigned int replies_seen_count) | 479 | unsigned int replies_seen_count) |
463 | { | 480 | { |
464 | unsigned int i; | ||
465 | struct GNUNET_HashCode mhash; | ||
466 | |||
467 | if (replies_seen_count + pr->replies_seen_count < pr->replies_seen_count) | 481 | if (replies_seen_count + pr->replies_seen_count < pr->replies_seen_count) |
468 | return; /* integer overflow */ | 482 | return; /* integer overflow */ |
469 | if (0 != (pr->public_data.options & GSF_PRO_BLOOMFILTER_FULL_REFRESH)) | 483 | if (0 != (pr->public_data.options & GSF_PRO_BLOOMFILTER_FULL_REFRESH)) |
470 | { | 484 | { |
471 | /* we're responsible for the BF, full refresh */ | 485 | /* we're responsible for the BF, full refresh */ |
472 | if (replies_seen_count + pr->replies_seen_count > pr->replies_seen_size) | 486 | if (replies_seen_count + pr->replies_seen_count > pr->replies_seen_size) |
473 | GNUNET_array_grow (pr->replies_seen, pr->replies_seen_size, | 487 | GNUNET_array_grow (pr->replies_seen, |
488 | pr->replies_seen_size, | ||
474 | replies_seen_count + pr->replies_seen_count); | 489 | replies_seen_count + pr->replies_seen_count); |
475 | GNUNET_memcpy (&pr->replies_seen[pr->replies_seen_count], replies_seen, | 490 | GNUNET_memcpy (&pr->replies_seen[pr->replies_seen_count], |
476 | sizeof (struct GNUNET_HashCode) * replies_seen_count); | 491 | replies_seen, |
492 | sizeof (struct GNUNET_HashCode) * replies_seen_count); | ||
477 | pr->replies_seen_count += replies_seen_count; | 493 | pr->replies_seen_count += replies_seen_count; |
478 | refresh_bloomfilter (pr); | 494 | refresh_bloomfilter (pr->public_data.type, |
495 | pr); | ||
479 | } | 496 | } |
480 | else | 497 | else |
481 | { | 498 | { |
482 | if (NULL == pr->bf) | 499 | if (NULL == pr->bg) |
483 | { | 500 | { |
484 | /* we're not the initiator, but the initiator did not give us | 501 | /* we're not the initiator, but the initiator did not give us |
485 | * any bloom-filter, so we need to create one on-the-fly */ | 502 | * any bloom-filter, so we need to create one on-the-fly */ |
486 | pr->mingle = | 503 | refresh_bloomfilter (pr->public_data.type, |
487 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 504 | pr); |
488 | UINT32_MAX); | ||
489 | pr->bf = | ||
490 | GNUNET_BLOCK_construct_bloomfilter (pr->mingle, | ||
491 | replies_seen, | ||
492 | replies_seen_count); | ||
493 | } | 505 | } |
494 | else | 506 | else |
495 | { | 507 | { |
496 | for (i = 0; i < pr->replies_seen_count; i++) | 508 | GNUNET_break (GNUNET_OK == |
497 | { | 509 | GNUNET_BLOCK_group_set_seen (pr->bg, |
498 | GNUNET_BLOCK_mingle_hash (&replies_seen[i], | 510 | replies_seen, |
499 | pr->mingle, | 511 | pr->replies_seen_count)); |
500 | &mhash); | ||
501 | GNUNET_CONTAINER_bloomfilter_add (pr->bf, | ||
502 | &mhash); | ||
503 | } | ||
504 | } | 512 | } |
505 | } | 513 | } |
506 | if (NULL != pr->gh) | 514 | if (NULL != pr->gh) |
@@ -530,6 +538,8 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr) | |||
530 | struct GNUNET_TIME_Absolute now; | 538 | struct GNUNET_TIME_Absolute now; |
531 | int64_t ttl; | 539 | int64_t ttl; |
532 | int do_route; | 540 | int do_route; |
541 | void *bf_data; | ||
542 | uint32_t bf_nonce; | ||
533 | 543 | ||
534 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 544 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
535 | "Building request message for `%s' of type %d\n", | 545 | "Building request message for `%s' of type %d\n", |
@@ -553,7 +563,15 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr) | |||
553 | bm |= GET_MESSAGE_BIT_TRANSMIT_TO; | 563 | bm |= GET_MESSAGE_BIT_TRANSMIT_TO; |
554 | k++; | 564 | k++; |
555 | } | 565 | } |
556 | bf_size = GNUNET_CONTAINER_bloomfilter_get_size (pr->bf); | 566 | if (GNUNET_OK != |
567 | GNUNET_BLOCK_group_serialize (pr->bg, | ||
568 | &bf_nonce, | ||
569 | &bf_data, | ||
570 | &bf_size)) | ||
571 | { | ||
572 | bf_size = 0; | ||
573 | bf_data = NULL; | ||
574 | } | ||
557 | env = GNUNET_MQ_msg_extra (gm, | 575 | env = GNUNET_MQ_msg_extra (gm, |
558 | bf_size + k * sizeof (struct GNUNET_PeerIdentity), | 576 | bf_size + k * sizeof (struct GNUNET_PeerIdentity), |
559 | GNUNET_MESSAGE_TYPE_FS_GET); | 577 | GNUNET_MESSAGE_TYPE_FS_GET); |
@@ -571,7 +589,7 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr) | |||
571 | now = GNUNET_TIME_absolute_get (); | 589 | now = GNUNET_TIME_absolute_get (); |
572 | ttl = (int64_t) (pr->public_data.ttl.abs_value_us - now.abs_value_us); | 590 | ttl = (int64_t) (pr->public_data.ttl.abs_value_us - now.abs_value_us); |
573 | gm->ttl = htonl (ttl / 1000LL / 1000LL); | 591 | gm->ttl = htonl (ttl / 1000LL / 1000LL); |
574 | gm->filter_mutator = htonl (pr->mingle); | 592 | gm->filter_mutator = htonl (bf_nonce); |
575 | gm->hash_bitmap = htonl (bm); | 593 | gm->hash_bitmap = htonl (bm); |
576 | gm->query = pr->public_data.query; | 594 | gm->query = pr->public_data.query; |
577 | ext = (struct GNUNET_PeerIdentity *) &gm[1]; | 595 | ext = (struct GNUNET_PeerIdentity *) &gm[1]; |
@@ -581,11 +599,10 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr) | |||
581 | &ext[k++]); | 599 | &ext[k++]); |
582 | if (NULL != pr->public_data.target) | 600 | if (NULL != pr->public_data.target) |
583 | ext[k++] = *pr->public_data.target; | 601 | ext[k++] = *pr->public_data.target; |
584 | if (NULL != pr->bf) | 602 | GNUNET_memcpy (&ext[k], |
585 | GNUNET_assert (GNUNET_SYSERR != | 603 | bf_data, |
586 | GNUNET_CONTAINER_bloomfilter_get_raw_data (pr->bf, | 604 | bf_size); |
587 | (char *) &ext[k], | 605 | GNUNET_free_non_null (bf_data); |
588 | bf_size)); | ||
589 | return env; | 606 | return env; |
590 | } | 607 | } |
591 | 608 | ||
@@ -624,11 +641,8 @@ clean_request (void *cls, | |||
624 | } | 641 | } |
625 | GSF_plan_notify_request_done_ (pr); | 642 | GSF_plan_notify_request_done_ (pr); |
626 | GNUNET_free_non_null (pr->replies_seen); | 643 | GNUNET_free_non_null (pr->replies_seen); |
627 | if (NULL != pr->bf) | 644 | GNUNET_BLOCK_group_destroy (pr->bg); |
628 | { | 645 | pr->bg = NULL; |
629 | GNUNET_CONTAINER_bloomfilter_free (pr->bf); | ||
630 | pr->bf = NULL; | ||
631 | } | ||
632 | GNUNET_PEER_change_rc (pr->sender_pid, -1); | 646 | GNUNET_PEER_change_rc (pr->sender_pid, -1); |
633 | pr->sender_pid = 0; | 647 | pr->sender_pid = 0; |
634 | GNUNET_PEER_change_rc (pr->origin_pid, -1); | 648 | GNUNET_PEER_change_rc (pr->origin_pid, -1); |
@@ -844,10 +858,9 @@ process_reply (void *cls, | |||
844 | prq->eval = | 858 | prq->eval = |
845 | GNUNET_BLOCK_evaluate (GSF_block_ctx, | 859 | GNUNET_BLOCK_evaluate (GSF_block_ctx, |
846 | prq->type, | 860 | prq->type, |
861 | pr->bg, | ||
847 | prq->eo, | 862 | prq->eo, |
848 | key, | 863 | key, |
849 | &pr->bf, | ||
850 | pr->mingle, | ||
851 | NULL, | 864 | NULL, |
852 | 0, | 865 | 0, |
853 | prq->data, | 866 | prq->data, |
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c index 038734082..6c574fca2 100644 --- a/src/fs/plugin_block_fs.c +++ b/src/fs/plugin_block_fs.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "gnunet_fs_service.h" | 28 | #include "gnunet_fs_service.h" |
29 | #include "block_fs.h" | 29 | #include "block_fs.h" |
30 | #include "gnunet_signatures.h" | 30 | #include "gnunet_signatures.h" |
31 | #include "gnunet_constants.h" | ||
31 | #include "gnunet_block_group_lib.h" | 32 | #include "gnunet_block_group_lib.h" |
32 | 33 | ||
33 | 34 | ||
@@ -37,10 +38,36 @@ | |||
37 | */ | 38 | */ |
38 | #define BLOOMFILTER_K 16 | 39 | #define BLOOMFILTER_K 16 |
39 | 40 | ||
41 | |||
40 | /** | 42 | /** |
41 | * How big is the BF we use for FS blocks? | 43 | * How many bytes should a bloomfilter be if we have already seen |
44 | * entry_count responses? Note that #GNUNET_CONSTANTS_BLOOMFILTER_K | ||
45 | * gives us the number of bits set per entry. Furthermore, we should | ||
46 | * not re-size the filter too often (to keep it cheap). | ||
47 | * | ||
48 | * Since other peers will also add entries but not resize the filter, | ||
49 | * we should generally pick a slightly larger size than what the | ||
50 | * strict math would suggest. | ||
51 | * | ||
52 | * @param entry_count expected number of entries in the Bloom filter | ||
53 | * @return must be a power of two and smaller or equal to 2^15. | ||
42 | */ | 54 | */ |
43 | #define FS_BF_SIZE 8 | 55 | static size_t |
56 | compute_bloomfilter_size (unsigned int entry_count) | ||
57 | { | ||
58 | size_t size; | ||
59 | unsigned int ideal = (entry_count * GNUNET_CONSTANTS_BLOOMFILTER_K) / 4; | ||
60 | uint16_t max = 1 << 15; | ||
61 | |||
62 | if (entry_count > max) | ||
63 | return max; | ||
64 | size = 8; | ||
65 | while ((size < max) && (size < ideal)) | ||
66 | size *= 2; | ||
67 | if (size > max) | ||
68 | return max; | ||
69 | return size; | ||
70 | } | ||
44 | 71 | ||
45 | 72 | ||
46 | /** | 73 | /** |
@@ -51,16 +78,21 @@ | |||
51 | * @param nonce random value used to seed the group creation | 78 | * @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 | 79 | * @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 | 80 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh |
81 | * @param va variable arguments specific to @a type | ||
54 | * @return block group handle, NULL if block groups are not supported | 82 | * @return block group handle, NULL if block groups are not supported |
55 | * by this @a type of block (this is not an error) | 83 | * by this @a type of block (this is not an error) |
56 | */ | 84 | */ |
57 | static struct GNUNET_BLOCK_Group * | 85 | static struct GNUNET_BLOCK_Group * |
58 | block_plugin_fs_create_group (void *cls, | 86 | block_plugin_fs_create_group (void *cls, |
59 | enum GNUNET_BLOCK_Type type, | 87 | enum GNUNET_BLOCK_Type type, |
60 | uint32_t nonce, | 88 | uint32_t nonce, |
61 | const void *raw_data, | 89 | const void *raw_data, |
62 | size_t raw_data_size) | 90 | size_t raw_data_size, |
91 | va_list va) | ||
63 | { | 92 | { |
93 | unsigned int size; | ||
94 | const char *guard; | ||
95 | |||
64 | switch (type) | 96 | switch (type) |
65 | { | 97 | { |
66 | case GNUNET_BLOCK_TYPE_FS_DBLOCK: | 98 | case GNUNET_BLOCK_TYPE_FS_DBLOCK: |
@@ -68,8 +100,23 @@ block_plugin_fs_create_group (void *cls, | |||
68 | case GNUNET_BLOCK_TYPE_FS_IBLOCK: | 100 | case GNUNET_BLOCK_TYPE_FS_IBLOCK: |
69 | return NULL; | 101 | return NULL; |
70 | case GNUNET_BLOCK_TYPE_FS_UBLOCK: | 102 | case GNUNET_BLOCK_TYPE_FS_UBLOCK: |
103 | guard = va_arg (va, const char *); | ||
104 | if (0 != memcmp (guard, | ||
105 | "fs-seen-set-size", | ||
106 | strlen ("fs-seen-set-size"))) | ||
107 | { | ||
108 | /* va-args invalid! bad bug, complain! */ | ||
109 | GNUNET_break (0); | ||
110 | size = 8; | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | size = compute_bloomfilter_size (va_arg (va, unsigned int)); | ||
115 | } | ||
116 | if (0 == size) | ||
117 | size = raw_data_size; /* not for us to determine, use what we got! */ | ||
71 | return GNUNET_BLOCK_GROUP_bf_create (cls, | 118 | return GNUNET_BLOCK_GROUP_bf_create (cls, |
72 | FS_BF_SIZE, | 119 | size, |
73 | BLOOMFILTER_K, | 120 | BLOOMFILTER_K, |
74 | type, | 121 | type, |
75 | nonce, | 122 | nonce, |
@@ -91,10 +138,9 @@ block_plugin_fs_create_group (void *cls, | |||
91 | * | 138 | * |
92 | * @param cls closure | 139 | * @param cls closure |
93 | * @param type block type | 140 | * @param type block type |
141 | * @param bg group to use for evaluation | ||
94 | * @param eo control flags | 142 | * @param eo control flags |
95 | * @param query original query (hash) | 143 | * @param query original query (hash) |
96 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | ||
97 | * @param bf_mutator mutation value for @a bf | ||
98 | * @param xquery extrended query data (can be NULL, depending on type) | 144 | * @param xquery extrended query data (can be NULL, depending on type) |
99 | * @param xquery_size number of bytes in @a xquery | 145 | * @param xquery_size number of bytes in @a xquery |
100 | * @param reply_block response to validate | 146 | * @param reply_block response to validate |
@@ -104,10 +150,9 @@ block_plugin_fs_create_group (void *cls, | |||
104 | static enum GNUNET_BLOCK_EvaluationResult | 150 | static enum GNUNET_BLOCK_EvaluationResult |
105 | block_plugin_fs_evaluate (void *cls, | 151 | block_plugin_fs_evaluate (void *cls, |
106 | enum GNUNET_BLOCK_Type type, | 152 | enum GNUNET_BLOCK_Type type, |
153 | struct GNUNET_BLOCK_Group *bg, | ||
107 | enum GNUNET_BLOCK_EvaluationOptions eo, | 154 | enum GNUNET_BLOCK_EvaluationOptions eo, |
108 | const struct GNUNET_HashCode *query, | 155 | const struct GNUNET_HashCode *query, |
109 | struct GNUNET_CONTAINER_BloomFilter **bf, | ||
110 | int32_t bf_mutator, | ||
111 | const void *xquery, | 156 | const void *xquery, |
112 | size_t xquery_size, | 157 | size_t xquery_size, |
113 | const void *reply_block, | 158 | const void *reply_block, |
@@ -116,7 +161,6 @@ block_plugin_fs_evaluate (void *cls, | |||
116 | const struct UBlock *ub; | 161 | const struct UBlock *ub; |
117 | struct GNUNET_HashCode hc; | 162 | struct GNUNET_HashCode hc; |
118 | struct GNUNET_HashCode chash; | 163 | struct GNUNET_HashCode chash; |
119 | struct GNUNET_HashCode mhash; | ||
120 | 164 | ||
121 | switch (type) | 165 | switch (type) |
122 | { | 166 | { |
@@ -170,26 +214,13 @@ block_plugin_fs_evaluate (void *cls, | |||
170 | GNUNET_break_op (0); | 214 | GNUNET_break_op (0); |
171 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 215 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
172 | } | 216 | } |
173 | if (NULL != bf) | 217 | GNUNET_CRYPTO_hash (reply_block, |
174 | { | 218 | reply_block_size, |
175 | GNUNET_CRYPTO_hash (reply_block, | 219 | &chash); |
176 | reply_block_size, | 220 | if (GNUNET_YES == |
177 | &chash); | 221 | GNUNET_BLOCK_GROUP_bf_test_and_set (bg, |
178 | GNUNET_BLOCK_mingle_hash (&chash, | 222 | &chash)) |
179 | bf_mutator, | 223 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; |
180 | &mhash); | ||
181 | if (NULL != *bf) | ||
182 | { | ||
183 | if (GNUNET_YES == | ||
184 | GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash)) | ||
185 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
186 | } | ||
187 | else | ||
188 | { | ||
189 | *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K); | ||
190 | } | ||
191 | GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); | ||
192 | } | ||
193 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 224 | return GNUNET_BLOCK_EVALUATION_OK_MORE; |
194 | default: | 225 | default: |
195 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 226 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
diff --git a/src/fs/test_plugin_block_fs.c b/src/fs/test_plugin_block_fs.c index 1fc9f2110..ba4f28bc5 100644 --- a/src/fs/test_plugin_block_fs.c +++ b/src/fs/test_plugin_block_fs.c | |||
@@ -40,28 +40,28 @@ test_fs (struct GNUNET_BLOCK_Context *ctx) | |||
40 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != | 40 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != |
41 | GNUNET_BLOCK_evaluate (ctx, | 41 | GNUNET_BLOCK_evaluate (ctx, |
42 | GNUNET_BLOCK_TYPE_FS_DBLOCK, | 42 | GNUNET_BLOCK_TYPE_FS_DBLOCK, |
43 | NULL, | ||
43 | GNUNET_BLOCK_EO_NONE, | 44 | GNUNET_BLOCK_EO_NONE, |
44 | &key, | 45 | &key, |
45 | NULL, 0, | 46 | NULL, 0, |
46 | NULL, 0, | ||
47 | block, sizeof (block))) | 47 | block, sizeof (block))) |
48 | return 2; | 48 | return 2; |
49 | if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID != | 49 | if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID != |
50 | GNUNET_BLOCK_evaluate (ctx, | 50 | GNUNET_BLOCK_evaluate (ctx, |
51 | GNUNET_BLOCK_TYPE_FS_DBLOCK, | 51 | GNUNET_BLOCK_TYPE_FS_DBLOCK, |
52 | NULL, | ||
52 | GNUNET_BLOCK_EO_NONE, | 53 | GNUNET_BLOCK_EO_NONE, |
53 | &key, | 54 | &key, |
54 | NULL, 0, | 55 | NULL, 0, |
55 | NULL, 0, | ||
56 | NULL, 0)) | 56 | NULL, 0)) |
57 | return 4; | 57 | return 4; |
58 | GNUNET_log_skip (1, GNUNET_NO); | 58 | GNUNET_log_skip (1, GNUNET_NO); |
59 | if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID != | 59 | if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID != |
60 | GNUNET_BLOCK_evaluate (ctx, | 60 | GNUNET_BLOCK_evaluate (ctx, |
61 | GNUNET_BLOCK_TYPE_FS_DBLOCK, | 61 | GNUNET_BLOCK_TYPE_FS_DBLOCK, |
62 | NULL, | ||
62 | GNUNET_BLOCK_EO_NONE, | 63 | GNUNET_BLOCK_EO_NONE, |
63 | &key, | 64 | &key, |
64 | NULL, 0, | ||
65 | "bogus", 5, | 65 | "bogus", 5, |
66 | NULL, 0)) | 66 | NULL, 0)) |
67 | return 8; | 67 | return 8; |