aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_block_plugin.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_plugin.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_plugin.h')
-rw-r--r--src/include/gnunet_block_plugin.h52
1 files changed, 47 insertions, 5 deletions
diff --git a/src/include/gnunet_block_plugin.h b/src/include/gnunet_block_plugin.h
index d7454b5d5..171b6cfc0 100644
--- a/src/include/gnunet_block_plugin.h
+++ b/src/include/gnunet_block_plugin.h
@@ -40,9 +40,38 @@
40 40
41 41
42/** 42/**
43 * Mark elements as "seen" using a hash of the element. Not supported
44 * by all block plugins.
45 *
46 * @param bg group to update
47 * @param seen_results results already seen
48 * @param seen_results_count number of entries in @a seen_results
49 */
50typedef void
51(*GNUNET_BLOCK_GroupMarkSeenFunction)(struct GNUNET_BLOCK_Group *bg,
52 const struct GNUNET_HashCode *seen_results,
53 unsigned int seen_results_count);
54
55
56/**
57 * Merge two groups, if possible. Not supported by all block plugins,
58 * can also fail if the nonces were different.
59 *
60 * @param bg1 group to update
61 * @param bg2 group to merge into @a bg1
62 * @return #GNUNET_OK on success, #GNUNET_NO if the nonces were different and thus
63 * we failed.
64 */
65typedef int
66(*GNUNET_BLOCK_GroupMergeFunction)(struct GNUNET_BLOCK_Group *bg1,
67 const struct GNUNET_BLOCK_Group *bg2);
68
69
70/**
43 * Serialize state of a block group. 71 * Serialize state of a block group.
44 * 72 *
45 * @param bg group to serialize 73 * @param bg group to serialize
74 * @param[out] nonce set to the nonce of the @a bg
46 * @param[out] raw_data set to the serialized state 75 * @param[out] raw_data set to the serialized state
47 * @param[out] raw_data_size set to the number of bytes in @a raw_data 76 * @param[out] raw_data_size set to the number of bytes in @a raw_data
48 * @return #GNUNET_OK on success, #GNUNET_NO if serialization is not 77 * @return #GNUNET_OK on success, #GNUNET_NO if serialization is not
@@ -50,6 +79,7 @@
50 */ 79 */
51typedef int 80typedef int
52(*GNUNET_BLOCK_GroupSerializeFunction)(struct GNUNET_BLOCK_Group *bg, 81(*GNUNET_BLOCK_GroupSerializeFunction)(struct GNUNET_BLOCK_Group *bg,
82 uint32_t *nonce,
53 void **raw_data, 83 void **raw_data,
54 size_t *raw_data_size); 84 size_t *raw_data_size);
55 85
@@ -87,6 +117,18 @@ struct GNUNET_BLOCK_Group
87 GNUNET_BLOCK_GroupSerializeFunction serialize_cb; 117 GNUNET_BLOCK_GroupSerializeFunction serialize_cb;
88 118
89 /** 119 /**
120 * Function to call to mark elements as seen in the group.
121 * Can be NULL if not supported.
122 */
123 GNUNET_BLOCK_GroupMarkSeenFunction mark_seen_cb;
124
125 /**
126 * Function to call to merge two groups.
127 * Can be NULL if not supported.
128 */
129 GNUNET_BLOCK_GroupMergeFunction merge_cb;
130
131 /**
90 * Function to call to destroy the block group. 132 * Function to call to destroy the block group.
91 * Must not be NULL. 133 * Must not be NULL.
92 */ 134 */
@@ -108,6 +150,7 @@ struct GNUNET_BLOCK_Group
108 * @param nonce random value used to seed the group creation 150 * @param nonce random value used to seed the group creation
109 * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh 151 * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh
110 * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh 152 * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh
153 * @param va variable arguments specific to @a type
111 * @return block group handle, NULL if block groups are not supported 154 * @return block group handle, NULL if block groups are not supported
112 * by this @a type of block (this is not an error) 155 * by this @a type of block (this is not an error)
113 */ 156 */
@@ -116,7 +159,8 @@ typedef struct GNUNET_BLOCK_Group *
116 enum GNUNET_BLOCK_Type type, 159 enum GNUNET_BLOCK_Type type,
117 uint32_t nonce, 160 uint32_t nonce,
118 const void *raw_data, 161 const void *raw_data,
119 size_t raw_data_size); 162 size_t raw_data_size,
163 va_list va);
120 164
121 165
122/** 166/**
@@ -128,10 +172,9 @@ typedef struct GNUNET_BLOCK_Group *
128 * 172 *
129 * @param cls closure 173 * @param cls closure
130 * @param type block type 174 * @param type block type
175 * @param group which block group to use for evaluation
131 * @param eo evaluation options to control evaluation 176 * @param eo evaluation options to control evaluation
132 * @param query original query (hash) 177 * @param query original query (hash)
133 * @param bf pointer to bloom filter associated with query; possibly updated (!)
134 * @param bf_mutator mutation value for @a bf
135 * @param xquery extrended query data (can be NULL, depending on type) 178 * @param xquery extrended query data (can be NULL, depending on type)
136 * @param xquery_size number of bytes in @a xquery 179 * @param xquery_size number of bytes in @a xquery
137 * @param reply_block response to validate 180 * @param reply_block response to validate
@@ -141,10 +184,9 @@ typedef struct GNUNET_BLOCK_Group *
141typedef enum GNUNET_BLOCK_EvaluationResult 184typedef enum GNUNET_BLOCK_EvaluationResult
142(*GNUNET_BLOCK_EvaluationFunction) (void *cls, 185(*GNUNET_BLOCK_EvaluationFunction) (void *cls,
143 enum GNUNET_BLOCK_Type type, 186 enum GNUNET_BLOCK_Type type,
187 struct GNUNET_BLOCK_Group *group,
144 enum GNUNET_BLOCK_EvaluationOptions eo, 188 enum GNUNET_BLOCK_EvaluationOptions eo,
145 const struct GNUNET_HashCode *query, 189 const struct GNUNET_HashCode *query,
146 struct GNUNET_CONTAINER_BloomFilter **bf,
147 int32_t bf_mutator,
148 const void *xquery, 190 const void *xquery,
149 size_t xquery_size, 191 size_t xquery_size,
150 const void *reply_block, 192 const void *reply_block,