diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-04-20 08:24:06 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-04-20 08:24:06 +0200 |
commit | 6d61330e3ae457a27f10247cd9caf53987604143 (patch) | |
tree | b877d94ad7bd49be40c0d601e57a09116abc6150 /src/revocation/gnunet-revocation.c | |
parent | 196a465c2254c224055b71a5bdb3697e7a468801 (diff) | |
download | gnunet-6d61330e3ae457a27f10247cd9caf53987604143.tar.gz gnunet-6d61330e3ae457a27f10247cd9caf53987604143.zip |
evaluate epochs
Diffstat (limited to 'src/revocation/gnunet-revocation.c')
-rw-r--r-- | src/revocation/gnunet-revocation.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c index 5566162f4..c33f12c90 100644 --- a/src/revocation/gnunet-revocation.c +++ b/src/revocation/gnunet-revocation.c | |||
@@ -84,6 +84,11 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
84 | static unsigned long long matching_bits; | 84 | static unsigned long long matching_bits; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Epoch length | ||
88 | */ | ||
89 | static struct GNUNET_TIME_Relative epoch_length; | ||
90 | |||
91 | /** | ||
87 | * Task used for proof-of-work calculation. | 92 | * Task used for proof-of-work calculation. |
88 | */ | 93 | */ |
89 | static struct GNUNET_SCHEDULER_Task *pow_task; | 94 | static struct GNUNET_SCHEDULER_Task *pow_task; |
@@ -341,6 +346,7 @@ ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego) | |||
341 | struct GNUNET_REVOCATION_Pow *pow; | 346 | struct GNUNET_REVOCATION_Pow *pow; |
342 | struct GNUNET_CRYPTO_EcdsaPublicKey key; | 347 | struct GNUNET_CRYPTO_EcdsaPublicKey key; |
343 | struct GNUNET_REVOCATION_PowCalculationHandle *ph = NULL; | 348 | struct GNUNET_REVOCATION_PowCalculationHandle *ph = NULL; |
349 | int epochs; | ||
344 | 350 | ||
345 | el = NULL; | 351 | el = NULL; |
346 | if (NULL == ego) | 352 | if (NULL == ego) |
@@ -365,11 +371,19 @@ ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego) | |||
365 | GNUNET_free (pow); | 371 | GNUNET_free (pow); |
366 | return; | 372 | return; |
367 | } | 373 | } |
368 | if (GNUNET_YES == | 374 | if (0 < (epochs = |
369 | GNUNET_REVOCATION_check_pow (pow, | 375 | GNUNET_REVOCATION_check_pow (pow, |
370 | (unsigned int) matching_bits)) | 376 | (unsigned int) matching_bits))) |
371 | { | 377 | { |
378 | struct GNUNET_TIME_Absolute ts; | ||
379 | struct GNUNET_TIME_Relative ttl; | ||
380 | ts = GNUNET_TIME_absolute_ntoh (pow->timestamp); | ||
381 | ttl = GNUNET_TIME_relative_multiply (epoch_length, | ||
382 | epochs); | ||
372 | fprintf (stderr, "%s", _ ("Revocation certificate ready\n")); | 383 | fprintf (stderr, "%s", _ ("Revocation certificate ready\n")); |
384 | fprintf (stderr, "%s %s for %s\n", _ ("Valid from"), | ||
385 | GNUNET_STRINGS_absolute_time_to_string (ts), | ||
386 | GNUNET_STRINGS_relative_time_to_string (ttl, GNUNET_NO)); | ||
373 | if (perform) | 387 | if (perform) |
374 | perform_revocation (pow); | 388 | perform_revocation (pow); |
375 | else | 389 | else |
@@ -448,6 +462,17 @@ run (void *cls, | |||
448 | "WORKBITS"); | 462 | "WORKBITS"); |
449 | return; | 463 | return; |
450 | } | 464 | } |
465 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, | ||
466 | "REVOCATION", | ||
467 | "EPOCH_LENGTH", | ||
468 | &epoch_length)) | ||
469 | { | ||
470 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | ||
471 | "REVOCATION", | ||
472 | "EPOCH_LENGTH"); | ||
473 | return; | ||
474 | } | ||
475 | |||
451 | if (NULL != revoke_ego) | 476 | if (NULL != revoke_ego) |
452 | { | 477 | { |
453 | if (! perform && (NULL == filename)) | 478 | if (! perform && (NULL == filename)) |
@@ -472,7 +497,7 @@ run (void *cls, | |||
472 | return; | 497 | return; |
473 | } | 498 | } |
474 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 499 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
475 | if (GNUNET_YES != | 500 | if (0 >= |
476 | GNUNET_REVOCATION_check_pow (&pow, | 501 | GNUNET_REVOCATION_check_pow (&pow, |
477 | (unsigned int) matching_bits)) | 502 | (unsigned int) matching_bits)) |
478 | { | 503 | { |