aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-reclaim.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-14 00:09:18 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-14 10:01:24 +0200
commiteb2d072aa1096c9d77cbfde239a1004cab642e64 (patch)
treeb44e82f972c503a64a6f2679edd340f7a1ecdda6 /src/reclaim/gnunet-reclaim.c
parentaf90492d9f86b3bcce93a8459383744939318bc3 (diff)
downloadgnunet-eb2d072aa1096c9d77cbfde239a1004cab642e64.tar.gz
gnunet-eb2d072aa1096c9d77cbfde239a1004cab642e64.zip
RECLAIM: Simplify logic
Diffstat (limited to 'src/reclaim/gnunet-reclaim.c')
-rw-r--r--src/reclaim/gnunet-reclaim.c68
1 files changed, 44 insertions, 24 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index 0e5591d69..1c3b4174d 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -157,7 +157,8 @@ static struct GNUNET_SCHEDULER_Task *cleanup_task;
157 */ 157 */
158struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 158struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
159 159
160static void do_cleanup (void *cls) 160static void
161do_cleanup (void *cls)
161{ 162{
162 cleanup_task = NULL; 163 cleanup_task = NULL;
163 if (NULL != timeout) 164 if (NULL != timeout)
@@ -178,8 +179,8 @@ static void do_cleanup (void *cls)
178 GNUNET_free (attr_list); 179 GNUNET_free (attr_list);
179} 180}
180 181
181static void ticket_issue_cb (void *cls, 182static void
182 const struct GNUNET_RECLAIM_Ticket *ticket) 183ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
183{ 184{
184 char *ticket_str; 185 char *ticket_str;
185 reclaim_op = NULL; 186 reclaim_op = NULL;
@@ -192,7 +193,8 @@ static void ticket_issue_cb (void *cls,
192 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 193 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
193} 194}
194 195
195static void store_attr_cont (void *cls, int32_t success, const char *emsg) 196static void
197store_attr_cont (void *cls, int32_t success, const char *emsg)
196{ 198{
197 reclaim_op = NULL; 199 reclaim_op = NULL;
198 if (GNUNET_SYSERR == success) { 200 if (GNUNET_SYSERR == success) {
@@ -201,9 +203,9 @@ static void store_attr_cont (void *cls, int32_t success, const char *emsg)
201 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 203 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
202} 204}
203 205
204static void process_attrs (void *cls, 206static void
205 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 207process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
206 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 208 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
207{ 209{
208 char *value_str; 210 char *value_str;
209 const char *attr_type; 211 const char *attr_type;
@@ -224,33 +226,45 @@ static void process_attrs (void *cls,
224 attr_type, attr->version, attr->id); 226 attr_type, attr->version, attr->id);
225} 227}
226 228
227static void ticket_iter_err (void *cls) 229static void
230ticket_iter_err (void *cls)
228{ 231{
229 ticket_iterator = NULL; 232 ticket_iterator = NULL;
230 fprintf (stderr, "Failed to iterate over tickets\n"); 233 fprintf (stderr, "Failed to iterate over tickets\n");
231 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 234 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
232} 235}
233 236
234static void ticket_iter_fin (void *cls) 237static void
238ticket_iter_fin (void *cls)
235{ 239{
236 ticket_iterator = NULL; 240 ticket_iterator = NULL;
237 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 241 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
238} 242}
239 243
240static void ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) 244static void
245ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
241{ 246{
242 fprintf (stdout, "Found ticket\n"); 247 char *aud;
248 char *ref;
249
250 aud = GNUNET_STRINGS_data_to_string_alloc (
251 &ticket->audience, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
252 ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t));
253
254 fprintf (stdout, "Ticket ID: %s | Audience: %s\n", ref, aud);
243 GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator); 255 GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
244} 256}
245 257
246static void iter_error (void *cls) 258static void
259iter_error (void *cls)
247{ 260{
248 attr_iterator = NULL; 261 attr_iterator = NULL;
249 fprintf (stderr, "Failed to iterate over attributes\n"); 262 fprintf (stderr, "Failed to iterate over attributes\n");
250 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 263 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
251} 264}
252 265
253static void timeout_task (void *cls) 266static void
267timeout_task (void *cls)
254{ 268{
255 timeout = NULL; 269 timeout = NULL;
256 ret = 1; 270 ret = 1;
@@ -259,7 +273,8 @@ static void timeout_task (void *cls)
259 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 273 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
260} 274}
261 275
262static void process_rvk (void *cls, int success, const char *msg) 276static void
277process_rvk (void *cls, int success, const char *msg)
263{ 278{
264 reclaim_op = NULL; 279 reclaim_op = NULL;
265 if (GNUNET_OK != success) { 280 if (GNUNET_OK != success) {
@@ -269,7 +284,8 @@ static void process_rvk (void *cls, int success, const char *msg)
269 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 284 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
270} 285}
271 286
272static void iter_finished (void *cls) 287static void
288iter_finished (void *cls)
273{ 289{
274 char *data; 290 char *data;
275 size_t data_size; 291 size_t data_size;
@@ -325,9 +341,9 @@ static void iter_finished (void *cls)
325 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 341 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
326} 342}
327 343
328static void iter_cb (void *cls, 344static void
329 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 345iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
330 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 346 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
331{ 347{
332 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 348 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
333 char *attrs_tmp; 349 char *attrs_tmp;
@@ -367,7 +383,8 @@ static void iter_cb (void *cls,
367 GNUNET_RECLAIM_get_attributes_next (attr_iterator); 383 GNUNET_RECLAIM_get_attributes_next (attr_iterator);
368} 384}
369 385
370static void start_process () 386static void
387start_process ()
371{ 388{
372 if (NULL == pkey) { 389 if (NULL == pkey) {
373 fprintf (stderr, "Ego %s not found\n", ego_name); 390 fprintf (stderr, "Ego %s not found\n", ego_name);
@@ -402,8 +419,9 @@ static void start_process ()
402 419
403static int init = GNUNET_YES; 420static int init = GNUNET_YES;
404 421
405static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, 422static void
406 const char *name) 423ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
424 const char *name)
407{ 425{
408 if (NULL == name) { 426 if (NULL == name) {
409 if (GNUNET_YES == init) { 427 if (GNUNET_YES == init) {
@@ -418,8 +436,9 @@ static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
418} 436}
419 437
420 438
421static void run (void *cls, char *const *args, const char *cfgfile, 439static void
422 const struct GNUNET_CONFIGURATION_Handle *c) 440run (void *cls, char *const *args, const char *cfgfile,
441 const struct GNUNET_CONFIGURATION_Handle *c)
423{ 442{
424 ret = 0; 443 ret = 0;
425 if (NULL == ego_name) { 444 if (NULL == ego_name) {
@@ -446,7 +465,8 @@ static void run (void *cls, char *const *args, const char *cfgfile,
446} 465}
447 466
448 467
449int main (int argc, char *const argv[]) 468int
469main (int argc, char *const argv[])
450{ 470{
451 exp_interval = GNUNET_TIME_UNIT_HOURS; 471 exp_interval = GNUNET_TIME_UNIT_HOURS;
452 struct GNUNET_GETOPT_CommandLineOption options[] = { 472 struct GNUNET_GETOPT_CommandLineOption options[] = {