aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_psycstore_service.h
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2013-08-15 10:09:33 +0000
committerGabor X Toth <*@tg-x.net>2013-08-15 10:09:33 +0000
commit9b731d2b45c2ddc2ea24de7a0c87a672a6856f3a (patch)
tree70d1ad32b0500fb38af21e6916665c509090f269 /src/include/gnunet_psycstore_service.h
parent5e7b0418545ff38967a2d2edc0ebab8e8030f336 (diff)
downloadgnunet-9b731d2b45c2ddc2ea24de7a0c87a672a6856f3a.tar.gz
gnunet-9b731d2b45c2ddc2ea24de7a0c87a672a6856f3a.zip
psycstore: added state_hash_update() and counters_get(); psyc: async state_get*(); multicast: membership test & replay params
Diffstat (limited to 'src/include/gnunet_psycstore_service.h')
-rw-r--r--src/include/gnunet_psycstore_service.h171
1 files changed, 119 insertions, 52 deletions
diff --git a/src/include/gnunet_psycstore_service.h b/src/include/gnunet_psycstore_service.h
index 5c79e2073..cd93c165f 100644
--- a/src/include/gnunet_psycstore_service.h
+++ b/src/include/gnunet_psycstore_service.h
@@ -76,14 +76,53 @@ struct GNUNET_PSYCSTORE_OperationHandle;
76 76
77 77
78/** 78/**
79 * Callback used to return the latest value of counters of a channel.
80 *
81 * @see GNUNET_PSYCSTORE_counters_get()
82 *
83 * @param *cls Closure.
84 * @param fragment_id Latest message fragment ID, used by multicast.
85 * @param message_id Latest message ID, used by PSYC.
86 * @param group_generation Latest group generation, used by PSYC.
87 */
88typedef void
89(*GNUNET_PSYCSTORE_CountersCallback) (void *cls,
90 uint64_t fragment_id,
91 uint64_t message_id,
92 uint64_t group_generation);
93
94
95/**
96 * Retrieve latest values of counters for a channel.
97 *
98 * The current value of counters are needed when a channel master is restarted,
99 * so that it can continue incrementing the counters from their last value.
100 *
101 * @param h Handle for the PSYCstore.
102 * @param channel_key Public key that identifies the channel.
103 * @param cb Callback to call with the result.
104 * @param cb_cls Closure for the callback.
105 *
106 * @return
107 */
108struct GNUNET_PSYCSTORE_OperationHandle *
109GNUNET_PSYCSTORE_counters_get (struct GNUNET_PSYCSTORE_Handle *h,
110 GNUNET_CRYPTO_EccPublicKey *channel_key,
111 GNUNET_PSYCSTORE_CountersCallback *cb,
112 void *cb_cls);
113
114
115/**
79 * Function called with the result of an asynchronous operation. 116 * Function called with the result of an asynchronous operation.
80 * 117 *
81 * @param result #GNUNET_SYSERR on error, 118 * @param result #GNUNET_SYSERR on error,
82 * #GNUNET_YES on success or if the peer was a member, 119 * #GNUNET_YES on success or if the peer was a member,
83 * #GNUNET_NO if the peer was not a member 120 * #GNUNET_NO if the peer was not a member
84 */ 121 */
85typedef void (*GNUNET_PSYCSTORE_ResultCallback)(void *cls, 122typedef void
86 int result); 123(*GNUNET_PSYCSTORE_ResultCallback) (void *cls,
124 int result);
125
87 126
88/** 127/**
89 * Store join/leave events for a PSYC channel in order to be able to answer 128 * Store join/leave events for a PSYC channel in order to be able to answer
@@ -92,9 +131,12 @@ typedef void (*GNUNET_PSYCSTORE_ResultCallback)(void *cls,
92 * @param h Handle for the PSYCstore. 131 * @param h Handle for the PSYCstore.
93 * @param channel_key The channel where the event happened. 132 * @param channel_key The channel where the event happened.
94 * @param slave_key Public key of joining/leaving slave. 133 * @param slave_key Public key of joining/leaving slave.
134 * @param did_join #GNUNET_YES on join, #GNUNET_NO on part.
95 * @param announced_at ID of the message that announced the membership change. 135 * @param announced_at ID of the message that announced the membership change.
96 * @param effective_since Message ID this membership change is in effect since. 136 * @param effective_since Message ID this membership change is in effect since.
97 * @param did_join #GNUNET_YES on join, #GNUNET_NO on part. 137 * @param group_generation In case of a part, the last group generation the
138 * slave has access to. It has relevance when a larger message have
139 * fragments with different group generations.
98 * @param rcb Callback to call with the result of the storage operation. 140 * @param rcb Callback to call with the result of the storage operation.
99 * @param rcb_cls Closure for the callback. 141 * @param rcb_cls Closure for the callback.
100 * 142 *
@@ -104,24 +146,26 @@ struct GNUNET_PSYCSTORE_OperationHandle *
104GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, 146GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
105 const struct GNUNET_CRYPTO_EccPublicKey *channel_key, 147 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
106 const struct GNUNET_CRYPTO_EccPublicKey *slave_key, 148 const struct GNUNET_CRYPTO_EccPublicKey *slave_key,
149 int did_join,
107 uint64_t announced_at, 150 uint64_t announced_at,
108 uint64_t effective_since, 151 uint64_t effective_since,
109 int did_join, 152 uint64_t group_generation,
110 GNUNET_PSYCSTORE_ResultCallback rcb, 153 GNUNET_PSYCSTORE_ResultCallback rcb,
111 void *rcb_cls); 154 void *rcb_cls);
112 155
113 156
114/** 157/**
115 * Test if a peer was a member of the channel when the message fragment with the 158 * Test if a peer was a member of the channel during the given period specified by the group generation.
116 * specified ID was sent to the channel.
117 * 159 *
118 * This is useful in case of retransmissions to check if the peer was authorized 160 * This is useful when relaying and replaying messages to check if a particular slave has access to the message fragment with a given group generation. It is also used when handling join requests to determine whether the slave is currently admitted to the channel.
119 * to see the requested message.
120 * 161 *
121 * @param h Handle for the PSYCstore. 162 * @param h Handle for the PSYCstore.
122 * @param channel_key The channel we are interested in. 163 * @param channel_key The channel we are interested in.
123 * @param slave_key Public key of slave whose membership to check. 164 * @param slave_key Public key of slave whose membership to check.
124 * @param fragment_id Message fragment ID to check. 165 * @param message_id Message ID for which to do the membership test.
166 * @param group_generation Group generation of the fragment of the message to
167 * test. It has relevance if the message consists of multiple fragments
168 * with different group generations.
125 * @param rcb Callback to call with the test result. 169 * @param rcb Callback to call with the test result.
126 * @param rcb_cls Closure for the callback. 170 * @param rcb_cls Closure for the callback.
127 * 171 *
@@ -131,7 +175,8 @@ struct GNUNET_PSYCSTORE_OperationHandle *
131GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, 175GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h,
132 const struct GNUNET_CRYPTO_EccPublicKey *channel_key, 176 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
133 const struct GNUNET_CRYPTO_EccPublicKey *slave_key, 177 const struct GNUNET_CRYPTO_EccPublicKey *slave_key,
134 uint64_t fragment_id, 178 uint64_t message_id,
179 uint64_t group_generation,
135 GNUNET_PSYCSTORE_ResultCallback rcb, 180 GNUNET_PSYCSTORE_ResultCallback rcb,
136 void *rcb_cls); 181 void *rcb_cls);
137 182
@@ -160,12 +205,14 @@ GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h,
160 * GNUNET_PSYCSTORE_fragment_get() or GNUNET_PSYCSTORE_message_get() call. 205 * GNUNET_PSYCSTORE_fragment_get() or GNUNET_PSYCSTORE_message_get() call.
161 * 206 *
162 * @param cls Closure. 207 * @param cls Closure.
163 * @param message The retrieved message fragment. 208 * @param message The retrieved message fragment. A NULL value indicates that
209 * there are no more results to be returned.
164 * @param flags Message flags indicating fragmentation status. 210 * @param flags Message flags indicating fragmentation status.
165 */ 211 */
166typedef void (*GNUNET_PSYCSTORE_FragmentResultCallback)(void *cls, 212typedef void
167 const struct GNUNET_MULTICAST_MessageHeader *message, 213(*GNUNET_PSYCSTORE_FragmentCallback) (void *cls,
168 enum GNUNET_PSYC_MessageFlags flags); 214 const struct GNUNET_MULTICAST_MessageHeader *message,
215 enum GNUNET_PSYC_MessageFlags flags);
169 216
170 217
171/** 218/**
@@ -174,8 +221,8 @@ typedef void (*GNUNET_PSYCSTORE_FragmentResultCallback)(void *cls,
174 * @param h Handle for the PSYCstore. 221 * @param h Handle for the PSYCstore.
175 * @param channel_key The channel we are interested in. 222 * @param channel_key The channel we are interested in.
176 * @param fragment_id Fragment ID to check. Use 0 to get the latest message fragment. 223 * @param fragment_id Fragment ID to check. Use 0 to get the latest message fragment.
177 * @param rcb Callback to call with the result of the operation. 224 * @param cb Callback to call with the retrieved fragment.
178 * @param rcb_cls Closure for the callback. 225 * @param cb_cls Closure for the callback.
179 * 226 *
180 * @return Handle that can be used to cancel the operation. 227 * @return Handle that can be used to cancel the operation.
181 */ 228 */
@@ -183,8 +230,8 @@ struct GNUNET_PSYCSTORE_OperationHandle *
183GNUNET_PSYCSTORE_fragment_get (struct GNUNET_PSYCSTORE_Handle *h, 230GNUNET_PSYCSTORE_fragment_get (struct GNUNET_PSYCSTORE_Handle *h,
184 const struct GNUNET_CRYPTO_EccPublicKey *channel_key, 231 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
185 uint64_t fragment_id, 232 uint64_t fragment_id,
186 GNUNET_PSYCSTORE_FragmentResultCallback rcb, 233 GNUNET_PSYCSTORE_FragmentCallback cb,
187 void *rcb_cls); 234 void *cb_cls);
188 235
189 236
190/** 237/**
@@ -193,8 +240,8 @@ GNUNET_PSYCSTORE_fragment_get (struct GNUNET_PSYCSTORE_Handle *h,
193 * @param h Handle for the PSYCstore. 240 * @param h Handle for the PSYCstore.
194 * @param channel_key The channel we are interested in. 241 * @param channel_key The channel we are interested in.
195 * @param message_id Message ID to check. Use 0 to get the latest message. 242 * @param message_id Message ID to check. Use 0 to get the latest message.
196 * @param rcb Callback to call with the result of the operation. 243 * @param cb Callback to call with the retrieved fragments.
197 * @param rcb_cls Closure for the callback. 244 * @param cb_cls Closure for the callback.
198 * 245 *
199 * @return Handle that can be used to cancel the operation. 246 * @return Handle that can be used to cancel the operation.
200 */ 247 */
@@ -202,25 +249,22 @@ struct GNUNET_PSYCSTORE_OperationHandle *
202GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h, 249GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h,
203 const struct GNUNET_CRYPTO_EccPublicKey *channel_key, 250 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
204 uint64_t message_id, 251 uint64_t message_id,
205 GNUNET_PSYCSTORE_FragmentResultCallback rcb, 252 GNUNET_PSYCSTORE_FragmentCallback cb,
206 void *rcb_cls); 253 void *cb_cls);
207 254
208 255
209/** 256/**
210 * Modify the channel state. 257 * Apply modifiers of a message to the current channel state.
211 *
212 * Applies the operation to the current channel state.
213 * 258 *
214 * An error is returned if there are missing messages containing state 259 * An error is returned if there are missing messages containing state
215 * operations before the current one. 260 * operations before the current one.
216 * 261 *
217 * @param h Handle for the PSYCstore. 262 * @param h Handle for the PSYCstore.
218 * @param channel_key The channel we are interested in. 263 * @param channel_key The channel we are interested in.
219 * @param message_id ID of the message that contains this state modifier. 264 * @param message_id ID of the message that contains the @a modifiers.
220 * @param oper Operation to perform. 265 * @param state_delta Value of the _state_delta PSYC header variable of the message.
221 * @param name Name of variable. 266 * @param modifier_count Number of elements in the @a modifiers array.
222 * @param value_size Size of @a value. 267 * @param modifiers List of modifiers to apply.
223 * @param value Value of variable.
224 * @param rcb Callback to call with the result of the operation. 268 * @param rcb Callback to call with the result of the operation.
225 * @param rcb_cls Closure for the callback. 269 * @param rcb_cls Closure for the callback.
226 * 270 *
@@ -230,37 +274,58 @@ struct GNUNET_PSYCSTORE_OperationHandle *
230GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h, 274GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h,
231 const struct GNUNET_CRYPTO_EccPublicKey *channel_key, 275 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
232 uint64_t message_id, 276 uint64_t message_id,
233 enum GNUNET_ENV_Operator *oper, 277 uint64_t state_delta,
234 const char *name, 278 size_t modifier_count,
235 size_t value_size, 279 const struct GNUNET_ENV_Modifier *modifiers,
236 const void *value,
237 GNUNET_PSYCSTORE_ResultCallback rcb, 280 GNUNET_PSYCSTORE_ResultCallback rcb,
238 void *rcb_cls); 281 void *rcb_cls);
239 282
240 283
241/** 284/**
285 * Update signed values of state variables in the state store.
286 *
287 * @param h Handle for the PSYCstore.
288 * @param channel_key The channel we are interested in.
289 * @param message_id Message ID that contained the state @a hash.
290 * @param hash Hash of the serialized full state.
291 * @param rcb Callback to call with the result of the operation.
292 * @param rcb_cls Closure for the callback.
293 *
294 */
295struct GNUNET_PSYCSTORE_OperationHandle *
296GNUNET_PSYCSTORE_state_hash_update (struct GNUNET_PSYCSTORE_Handle *h,
297 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
298 uint64_t message_id,
299 const struct GNUNET_HashCode *hash,
300 GNUNET_PSYCSTORE_ResultCallback rcb,
301 void *rcb_cls);
302
303
304/**
242 * Function called with the value of a state variable. 305 * Function called with the value of a state variable.
243 * 306 *
244 * @param cls Closure. 307 * @param cls Closure.
245 * @param name Name of variable. 308 * @param name Name of the state variable. A NULL value indicates that there are no more
246 * @param size Size of @a value. 309 * state variables to be returned.
247 * @param value Value of variable. 310 * @param value_size Number of bytes in @a value.
311 * @param value Value of the state variable.
248t * 312t *
249 */ 313 */
250typedef void (*GNUNET_PSYCSTORE_StateResultCallback)(void *cls, 314typedef void
251 const char *name, 315(*GNUNET_PSYCSTORE_StateCallback) (void *cls,
252 size_t size, 316 const char *name,
253 const void *value); 317 size_t value_size,
318 const void *value);
254 319
255 320
256/** 321/**
257 * Retrieve the given state variable for a channel. 322 * Retrieve the best matching state variable.
258 * 323 *
259 * @param h Handle for the PSYCstore. 324 * @param h Handle for the PSYCstore.
260 * @param channel_key The channel we are interested in. 325 * @param channel_key The channel we are interested in.
261 * @param name Name of variable to get. 326 * @param name Name of variable to match, the returned variable might be less specific.
262 * @param rcb Callback to call with the result. 327 * @param cb Callback to return matching state variables.
263 * @param rcb_cls Closure for the callback. 328 * @param cb_cls Closure for the callback.
264 * 329 *
265 * @return Handle that can be used to cancel the operation. 330 * @return Handle that can be used to cancel the operation.
266 */ 331 */
@@ -268,25 +333,27 @@ struct GNUNET_PSYCSTORE_OperationHandle *
268GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h, 333GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h,
269 const struct GNUNET_CRYPTO_EccPublicKey *channel_key, 334 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
270 const char *name, 335 const char *name,
271 GNUNET_PSYCSTORE_StateResultCallback rcb, 336 GNUNET_PSYCSTORE_StateCallback cb,
272 void *rcb_cls); 337 void *cb_cls);
273 338
274 339
275/** 340/**
276 * Retrieve all state variables for a channel. 341 * Retrieve all state variables for a channel with the given prefix.
277 * 342 *
278 * @param h Handle for the PSYCstore. 343 * @param h Handle for the PSYCstore.
279 * @param channel_key The channel we are interested in. 344 * @param channel_key The channel we are interested in.
280 * @param rcb Callback to call with the result. 345 * @param name_prefix Prefix of state variable names to match.
281 * @param rcb_cls Closure for the callback. 346 * @param cb Callback to return matching state variables.
347 * @param cb_cls Closure for the callback.
282 * 348 *
283 * @return Handle that can be used to cancel the operation. 349 * @return Handle that can be used to cancel the operation.
284 */ 350 */
285struct GNUNET_PSYCSTORE_OperationHandle * 351struct GNUNET_PSYCSTORE_OperationHandle *
286GNUNET_PSYCSTORE_state_get_all (struct GNUNET_PSYCSTORE_Handle *h, 352GNUNET_PSYCSTORE_state_get_all (struct GNUNET_PSYCSTORE_Handle *h,
287 const struct GNUNET_CRYPTO_EccPublicKey *channel_key, 353 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
288 GNUNET_PSYCSTORE_StateResultCallback rcb, 354 const char *name_prefix,
289 void *rcb_cls); 355 GNUNET_PSYCSTORE_StateCallback cb,
356 void *cb_cls);
290 357
291 358
292/** 359/**