aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-04-22 17:10:22 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-04-22 17:10:22 +0200
commitc4fa48421916ff0777e9cf1bbb3b83634392a494 (patch)
tree1b8d0de90bc03cc022baa89297ea7cbe759eeb42
parent1b57b570605c9145647e7ce62d43a5387efe9419 (diff)
downloadgnunet-c4fa48421916ff0777e9cf1bbb3b83634392a494.tar.gz
gnunet-c4fa48421916ff0777e9cf1bbb3b83634392a494.zip
add epochs CLI parameter
-rw-r--r--doc/man/gnunet-revocation.13
-rw-r--r--src/revocation/gnunet-revocation.c21
2 files changed, 19 insertions, 5 deletions
diff --git a/doc/man/gnunet-revocation.1 b/doc/man/gnunet-revocation.1
index 0c447a94f..05d80178a 100644
--- a/doc/man/gnunet-revocation.1
+++ b/doc/man/gnunet-revocation.1
@@ -30,6 +30,7 @@
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Nm 31.Nm
32.Op Fl t Ar KEY | Fl -test= Ns Ar KEY 32.Op Fl t Ar KEY | Fl -test= Ns Ar KEY
33.Op Fl e Ar EPOCHS | Fl -epochs= Ns Ar EPOCHS
33.Op Fl R Ar NAME | Fl -revoke= Ns Ar NAME 34.Op Fl R Ar NAME | Fl -revoke= Ns Ar NAME
34.Op Fl p | -perform 35.Op Fl p | -perform
35.Op Fl f Ar NAME | Fl -filename= Ns Ar NAME 36.Op Fl f Ar NAME | Fl -filename= Ns Ar NAME
@@ -50,6 +51,8 @@ Depending on your CPU, the calculation can take days or weeks.
50.Bl -tag -width indent 51.Bl -tag -width indent
51.It Fl t Ar KEY | Fl -test= Ns Ar KEY 52.It Fl t Ar KEY | Fl -test= Ns Ar KEY
52Check if the given KEY (ASCII-encoded public key required) has been revoked. 53Check if the given KEY (ASCII-encoded public key required) has been revoked.
54.It Fl e Ar EPOCHS | Fl -epochs= Ns Ar EPOCHS
55Number of epochs for which the revocation should be valid (default: 1)
53.It Fl R Ar NAME | Fl -revoke= Ns Ar NAME 56.It Fl R Ar NAME | Fl -revoke= Ns Ar NAME
54Calculate or perform revocation for the ego with the given NAME. 57Calculate or perform revocation for the ego with the given NAME.
55.It Fl p | -perform 58.It Fl p | -perform
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c
index de9560172..19fd5ab2c 100644
--- a/src/revocation/gnunet-revocation.c
+++ b/src/revocation/gnunet-revocation.c
@@ -59,6 +59,11 @@ static char *revoke_ego;
59static char *test_ego; 59static char *test_ego;
60 60
61/** 61/**
62 * -e option.
63 */
64static unsigned int epochs = 1;
65
66/**
62 * Handle for revocation query. 67 * Handle for revocation query.
63 */ 68 */
64static struct GNUNET_REVOCATION_Query *q; 69static struct GNUNET_REVOCATION_Query *q;
@@ -333,7 +338,7 @@ ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
333 } 338 }
334 GNUNET_IDENTITY_ego_get_public_key (ego, &key); 339 GNUNET_IDENTITY_ego_get_public_key (ego, &key);
335 privkey = GNUNET_IDENTITY_ego_get_private_key (ego); 340 privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
336 memset(&proof_of_work, 0, sizeof (proof_of_work)); 341 memset (&proof_of_work, 0, sizeof (proof_of_work));
337 if ((NULL != filename) && (GNUNET_YES == GNUNET_DISK_file_test (filename)) && 342 if ((NULL != filename) && (GNUNET_YES == GNUNET_DISK_file_test (filename)) &&
338 (sizeof(proof_of_work) == 343 (sizeof(proof_of_work) ==
339 GNUNET_DISK_fn_read (filename, &proof_of_work, sizeof(proof_of_work)))) 344 GNUNET_DISK_fn_read (filename, &proof_of_work, sizeof(proof_of_work))))
@@ -363,9 +368,9 @@ ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
363 */ 368 */
364 fprintf (stderr, 369 fprintf (stderr,
365 "%s", 370 "%s",
366 _("Continuing calculation where left off...\n")); 371 _ ("Continuing calculation where left off...\n"));
367 ph = GNUNET_REVOCATION_pow_start (&proof_of_work, 372 ph = GNUNET_REVOCATION_pow_start (&proof_of_work,
368 1, /* Epochs */ 373 epochs,
369 matching_bits); 374 matching_bits);
370 } 375 }
371 fprintf (stderr, 376 fprintf (stderr,
@@ -376,7 +381,7 @@ ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
376 GNUNET_REVOCATION_pow_init (privkey, 381 GNUNET_REVOCATION_pow_init (privkey,
377 &proof_of_work); 382 &proof_of_work);
378 ph = GNUNET_REVOCATION_pow_start (&proof_of_work, 383 ph = GNUNET_REVOCATION_pow_start (&proof_of_work,
379 1, /* Epochs */ 384 epochs, /* Epochs */
380 matching_bits); 385 matching_bits);
381 } 386 }
382 pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, ph); 387 pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, ph);
@@ -475,7 +480,7 @@ run (void *cls,
475 { 480 {
476 struct GNUNET_REVOCATION_PowCalculationHandle *ph; 481 struct GNUNET_REVOCATION_PowCalculationHandle *ph;
477 ph = GNUNET_REVOCATION_pow_start (&proof_of_work, 482 ph = GNUNET_REVOCATION_pow_start (&proof_of_work,
478 1, /* Epochs */ 483 epochs, /* Epochs */
479 matching_bits); 484 matching_bits);
480 485
481 pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, ph); 486 pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, ph);
@@ -528,6 +533,12 @@ main (int argc, char *const *argv)
528 gettext_noop ( 533 gettext_noop (
529 "test if the public key KEY has been revoked"), 534 "test if the public key KEY has been revoked"),
530 &test_ego), 535 &test_ego),
536 GNUNET_GETOPT_option_uint ('e',
537 "epochs",
538 "EPOCHS",
539 gettext_noop (
540 "number of epochs to calculate for"),
541 &epochs),
531 542
532 GNUNET_GETOPT_OPTION_END 543 GNUNET_GETOPT_OPTION_END
533 }; 544 };