diff options
Diffstat (limited to 'src/dht/plugin_block_dht.c')
-rw-r--r-- | src/dht/plugin_block_dht.c | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index 4c5f122a4..0304dad87 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c | |||
@@ -47,6 +47,7 @@ | |||
47 | * @param nonce random value used to seed the group creation | 47 | * @param nonce random value used to seed the group creation |
48 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh | 48 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh |
49 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh | 49 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh |
50 | * @param va variable arguments specific to @a type | ||
50 | * @return block group handle, NULL if block groups are not supported | 51 | * @return block group handle, NULL if block groups are not supported |
51 | * by this @a type of block (this is not an error) | 52 | * by this @a type of block (this is not an error) |
52 | */ | 53 | */ |
@@ -55,7 +56,8 @@ block_plugin_dht_create_group (void *cls, | |||
55 | enum GNUNET_BLOCK_Type type, | 56 | enum GNUNET_BLOCK_Type type, |
56 | uint32_t nonce, | 57 | uint32_t nonce, |
57 | const void *raw_data, | 58 | const void *raw_data, |
58 | size_t raw_data_size) | 59 | size_t raw_data_size, |
60 | va_list va) | ||
59 | { | 61 | { |
60 | return GNUNET_BLOCK_GROUP_bf_create (cls, | 62 | return GNUNET_BLOCK_GROUP_bf_create (cls, |
61 | DHT_BF_SIZE, | 63 | DHT_BF_SIZE, |
@@ -73,10 +75,9 @@ block_plugin_dht_create_group (void *cls, | |||
73 | * | 75 | * |
74 | * @param cls closure | 76 | * @param cls closure |
75 | * @param type block type | 77 | * @param type block type |
78 | * @param group block group to check against | ||
76 | * @param eo control flags | 79 | * @param eo control flags |
77 | * @param query original query (hash) | 80 | * @param query original query (hash) |
78 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | ||
79 | * @param bf_mutator mutation value for @a bf | ||
80 | * @param xquery extended query data (can be NULL, depending on type) | 81 | * @param xquery extended query data (can be NULL, depending on type) |
81 | * @param xquery_size number of bytes in @a xquery | 82 | * @param xquery_size number of bytes in @a xquery |
82 | * @param reply_block response to validate | 83 | * @param reply_block response to validate |
@@ -86,16 +87,14 @@ block_plugin_dht_create_group (void *cls, | |||
86 | static enum GNUNET_BLOCK_EvaluationResult | 87 | static enum GNUNET_BLOCK_EvaluationResult |
87 | block_plugin_dht_evaluate (void *cls, | 88 | block_plugin_dht_evaluate (void *cls, |
88 | enum GNUNET_BLOCK_Type type, | 89 | enum GNUNET_BLOCK_Type type, |
90 | struct GNUNET_BLOCK_Group *group, | ||
89 | enum GNUNET_BLOCK_EvaluationOptions eo, | 91 | enum GNUNET_BLOCK_EvaluationOptions eo, |
90 | const struct GNUNET_HashCode *query, | 92 | const struct GNUNET_HashCode *query, |
91 | struct GNUNET_CONTAINER_BloomFilter **bf, | ||
92 | int32_t bf_mutator, | ||
93 | const void *xquery, | 93 | const void *xquery, |
94 | size_t xquery_size, | 94 | size_t xquery_size, |
95 | const void *reply_block, | 95 | const void *reply_block, |
96 | size_t reply_block_size) | 96 | size_t reply_block_size) |
97 | { | 97 | { |
98 | struct GNUNET_HashCode mhash; | ||
99 | const struct GNUNET_HELLO_Message *hello; | 98 | const struct GNUNET_HELLO_Message *hello; |
100 | struct GNUNET_PeerIdentity pid; | 99 | struct GNUNET_PeerIdentity pid; |
101 | const struct GNUNET_MessageHeader *msg; | 100 | const struct GNUNET_MessageHeader *msg; |
@@ -127,22 +126,13 @@ block_plugin_dht_evaluate (void *cls, | |||
127 | GNUNET_break_op (0); | 126 | GNUNET_break_op (0); |
128 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 127 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
129 | } | 128 | } |
130 | if (NULL != bf) | 129 | GNUNET_CRYPTO_hash (&pid, |
131 | { | 130 | sizeof (pid), |
132 | GNUNET_CRYPTO_hash (&pid, sizeof (pid), &phash); | 131 | &phash); |
133 | GNUNET_BLOCK_mingle_hash (&phash, bf_mutator, &mhash); | 132 | if (GNUNET_YES == |
134 | if (NULL != *bf) | 133 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, |
135 | { | 134 | &phash)) |
136 | if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash)) | 135 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; |
137 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, | ||
142 | GNUNET_CONSTANTS_BLOOMFILTER_K); | ||
143 | } | ||
144 | GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); | ||
145 | } | ||
146 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 136 | return GNUNET_BLOCK_EVALUATION_OK_MORE; |
147 | } | 137 | } |
148 | 138 | ||