Better calculation of # DKs

This commit is contained in:
Marcello Stanisci 2019-04-10 19:01:26 +02:00
parent 123d5077e9
commit 0d3758807b
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
3 changed files with 36 additions and 34 deletions

View File

@ -439,21 +439,12 @@ get_anchor (const char *dir,
} }
else if (anchor->abs_value_us != now.abs_value_us) else if (anchor->abs_value_us != now.abs_value_us)
{ {
/**
* XXX-ANCHOR question: why adding the duration only in this
* case, and not _all the times we found a anchor_ ? Like for
* instance, below out of this block?
*
*/
*anchor = GNUNET_TIME_absolute_add (*anchor, *anchor = GNUNET_TIME_absolute_add (*anchor,
duration); duration);
*anchor = GNUNET_TIME_absolute_subtract (*anchor, *anchor = GNUNET_TIME_absolute_subtract (*anchor,
overlap); overlap);
} }
/* ==>Missing to add the duration to the anchor here?<== */
/* anchor is now the stamp where we need to create a new key */ /* anchor is now the stamp where we need to create a new key */
} }

View File

@ -200,7 +200,7 @@ TALER_EXCHANGEDB_denomination_key_write (const char *filename,
if (NULL == (fh = GNUNET_DISK_file_open if (NULL == (fh = GNUNET_DISK_file_open
(filename, (filename,
GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE,
GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE))) GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_OPEN_FAILIFEXISTS)))
goto cleanup; goto cleanup;
wsize = sizeof (struct TALER_EXCHANGEDB_DenominationKeyInformationP); wsize = sizeof (struct TALER_EXCHANGEDB_DenominationKeyInformationP);
if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh, if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh,

View File

@ -55,19 +55,28 @@
"test_exchange_api_keys_cherry_picking_extended_2.conf" "test_exchange_api_keys_cherry_picking_extended_2.conf"
/** /**
* Current time. * Add seconds.
*/
struct GNUNET_TIME_Absolute now;
/**
* Adds to the current time.
* *
* @param relative number of _seconds_ to add to the current time. * @param base absolute time to add seconds to.
* @param relative number of seconds to add.
* @return a new absolute time, modified according to @e relative. * @return a new absolute time, modified according to @e relative.
*/ */
#define NOWPLUSSECS(secs) \ #define ADDSECS(base, secs) \
GNUNET_TIME_absolute_add \ GNUNET_TIME_absolute_add \
(now, \ (base, \
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \
secs))
/**
* Subtract seconds.
*
* @param base absolute time to subtract seconds to.
* @param secs relative number of _seconds_ to subtract.
* @return a new absolute time, modified according to @e relative.
*/
#define SUBSECS(base, secs) \
GNUNET_TIME_absolute_sub \
(base, \
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \
secs)) secs))
#define JAN1971 "1971-01-01" #define JAN1971 "1971-01-01"
@ -169,7 +178,6 @@ run (void *cls,
}; };
now = GNUNET_TIME_absolute_get ();
struct TALER_TESTING_Command ordinary_cherry_pick[] = { struct TALER_TESTING_Command ordinary_cherry_pick[] = {
/** /**
@ -201,26 +209,29 @@ run (void *cls,
2, 2,
TTH_parse_time (JAN2030)), TTH_parse_time (JAN2030)),
/**
* We now load a very high lookahead_sign value of 3500 s,
* with now == JAN2030.
*/
TALER_TESTING_cmd_exec_keyup_with_now TALER_TESTING_cmd_exec_keyup_with_now
("keyup-3", ("keyup-3",
CONFIG_FILE_EXTENDED_2, CONFIG_FILE_EXTENDED_2,
TTH_parse_time (JAN2030)), /* Taking care of not using a 'now' that equals the
* last DK timestamp, otherwise it would get silently
* overridden. */
ADDSECS (TTH_parse_time (JAN2030),
10)),
/** /**
* For each DK with a withdraw duration of 80 s * Expected number of DK:
* (- 1 s of overlap), and for the latest 3500 s
* lookahead_sign value, we should have ((3500 - _79_) / 79)
* keys we just downloaded + 2 old DK keys stored in memory
* (total 46). The _79_ seconds we subtract are from the one
* key generated at "keyup-1".
* *
* This currently fails: look for XXX-ANCHOR at * 3500 (the lookaeahd_sign time frame, in seconds)
* taler-exchange-keyup.c to get some insight about the reason * - 69 (how many seconds are covered by the latest DK)
* behind. * ----
* 3431
* / 79 (how many seconds each DK will cover)
* ----
* 44 (rounded up)
* + 2 (old DKs already stored locally: 1 from the
* very initial setup, and 1 from the 'keyup-1' CMD)
* ----
* 46
*/ */
TALER_TESTING_cmd_check_keys_with_now TALER_TESTING_cmd_check_keys_with_now
("check-keys-3", ("check-keys-3",