diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-07-23 20:40:13 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-07-23 20:40:13 +0200 |
commit | 325b60989faadb54213af578bb9b1b705d022726 (patch) | |
tree | 2d527bb489a09bd601b5defbd04c08109eabce4d | |
parent | 098bd64f39ce9f6bfca54fe2505b91a079c22f16 (diff) |
-use new GNUNET_TIME functions
-rw-r--r-- | src/exchange/taler-exchange-httpd_deposit.c | 19 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_keys.c | 9 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_melt.c | 21 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_recoup.c | 19 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_refreshes_reveal.c | 15 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_withdraw.c | 16 |
6 files changed, 71 insertions, 28 deletions
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index f0f6784f4..8e93d998d 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -431,7 +431,6 @@ TEH_handler_deposit (struct MHD_Connection *connection, /* check denomination exists and is valid */ { struct TEH_DenominationKey *dk; - struct GNUNET_TIME_Absolute now; MHD_RESULT mret; dk = TEH_keys_denomination_by_hash (&deposit.coin.denom_pub_hash, @@ -442,11 +441,13 @@ TEH_handler_deposit (struct MHD_Connection *connection, GNUNET_JSON_parse_free (spec); return mret; } - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); - if (now.abs_value_us >= dk->meta.expire_deposit.abs_value_us) + if (GNUNET_TIME_absolute_is_past (dk->meta.expire_deposit)) { /* This denomination is past the expiration time for deposits */ + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, @@ -455,9 +456,13 @@ TEH_handler_deposit (struct MHD_Connection *connection, TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED, "DEPOSIT"); } - if (now.abs_value_us < dk->meta.start.abs_value_us) + if (GNUNET_TIME_absolute_is_future (dk->meta.start)) { /* This denomination is not yet valid */ + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, @@ -468,6 +473,10 @@ TEH_handler_deposit (struct MHD_Connection *connection, } if (dk->recoup_possible) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination has been revoked */ GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_expired_denom_pub_hash ( diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c index f6894a2a8..b12a1e420 100644 --- a/src/exchange/taler-exchange-httpd_keys.c +++ b/src/exchange/taler-exchange-httpd_keys.c @@ -1806,8 +1806,7 @@ get_key_state (bool management_only) return ksh; } if ( (old_ksh->key_generation < key_generation) || - (0 == GNUNET_TIME_absolute_get_remaining ( - old_ksh->signature_expires).rel_value_us) ) + (GNUNET_TIME_absolute_is_past (old_ksh->signature_expires)) ) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Rebuilding /keys, generation upgrade from %llu to %llu\n", @@ -2075,7 +2074,7 @@ TEH_keys_get_handler (const struct TEH_RequestHandler *rh, be a problem, as giving back 'older' data than what the client asks for (given that the client asks for data in the distant future) is not problematic */ - last_issue_date.abs_value_us = (uint64_t) cherrypickn * 1000000LLU; + last_issue_date = GNUNET_TIME_absolute_from_s (cherrypickn); } else { @@ -2385,7 +2384,7 @@ add_future_denomkey_cb (void *cls, h_denom_pub); if (NULL != dk) return GNUNET_OK; /* skip: this key is already active! */ - if (0 == hd->validity_duration.rel_value_us) + if (GNUNET_TIME_relative_is_zero (hd->validity_duration)) return GNUNET_OK; /* this key already expired! */ meta.start = hd->start_time; meta.expire_withdraw = GNUNET_TIME_absolute_add (meta.start, @@ -2461,7 +2460,7 @@ add_future_signkey_cb (void *cls, pid); if (NULL != sk) return GNUNET_OK; /* skip: this key is already active */ - if (0 == hsk->validity_duration.rel_value_us) + if (GNUNET_TIME_relative_is_zero (hsk->validity_duration)) return GNUNET_OK; /* this key already expired! */ stamp_expire = GNUNET_TIME_absolute_add (hsk->start_time, hsk->validity_duration); diff --git a/src/exchange/taler-exchange-httpd_melt.c b/src/exchange/taler-exchange-httpd_melt.c index 7276f9a65..a11d608bc 100644 --- a/src/exchange/taler-exchange-httpd_melt.c +++ b/src/exchange/taler-exchange-httpd_melt.c @@ -466,7 +466,6 @@ check_for_denomination_key (struct MHD_Connection *connection, /* Baseline: check if deposits/refreshs are generally simply still allowed for this denomination */ struct TEH_DenominationKey *dk; - struct GNUNET_TIME_Absolute now; MHD_RESULT mret; dk = TEH_keys_denomination_by_hash ( @@ -475,10 +474,12 @@ check_for_denomination_key (struct MHD_Connection *connection, &mret); if (NULL == dk) return mret; - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); - if (now.abs_value_us >= dk->meta.expire_legal.abs_value_us) + if (GNUNET_TIME_absolute_is_past (dk->meta.expire_legal)) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* Way too late now, even zombies have expired */ return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, @@ -487,8 +488,12 @@ check_for_denomination_key (struct MHD_Connection *connection, TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED, "MELT"); } - if (now.abs_value_us < dk->meta.start.abs_value_us) + if (GNUNET_TIME_absolute_is_future (dk->meta.start)) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination is not yet valid */ return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, @@ -497,7 +502,7 @@ check_for_denomination_key (struct MHD_Connection *connection, TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE, "MELT"); } - if (now.abs_value_us >= dk->meta.expire_deposit.abs_value_us) + if (GNUNET_TIME_absolute_is_past (dk->meta.expire_deposit)) { /* We are past deposit expiration time, but maybe this is a zombie? */ struct GNUNET_HashCode denom_hash; @@ -526,6 +531,10 @@ check_for_denomination_key (struct MHD_Connection *connection, &rmc->refresh_session.coin.denom_pub_hash)); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* We never saw this coin before, so _this_ justification is not OK */ return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, diff --git a/src/exchange/taler-exchange-httpd_recoup.c b/src/exchange/taler-exchange-httpd_recoup.c index 0c49cc68a..991b16e27 100644 --- a/src/exchange/taler-exchange-httpd_recoup.c +++ b/src/exchange/taler-exchange-httpd_recoup.c @@ -364,7 +364,6 @@ verify_and_execute_recoup (struct MHD_Connection *connection, void *coin_ev; size_t coin_ev_size; MHD_RESULT mret; - struct GNUNET_TIME_Absolute now; /* check denomination exists and is in recoup mode */ dk = TEH_keys_denomination_by_hash (&coin->denom_pub_hash, @@ -372,10 +371,12 @@ verify_and_execute_recoup (struct MHD_Connection *connection, &mret); if (NULL == dk) return mret; - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); - if (now.abs_value_us >= dk->meta.expire_deposit.abs_value_us) + if (GNUNET_TIME_absolute_is_past (dk->meta.expire_deposit)) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination is past the expiration time for recoup */ return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, @@ -384,8 +385,12 @@ verify_and_execute_recoup (struct MHD_Connection *connection, TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED, "RECOUP"); } - if (now.abs_value_us < dk->meta.start.abs_value_us) + if (GNUNET_TIME_absolute_is_future (dk->meta.start)) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination is not yet valid */ return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, @@ -396,6 +401,10 @@ verify_and_execute_recoup (struct MHD_Connection *connection, } if (! dk->recoup_possible) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination is not eligible for recoup */ return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c index d915aefce..4fbc949ee 100644 --- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c +++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c @@ -546,7 +546,6 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection, enum GNUNET_GenericReturnValue res; MHD_RESULT ret; struct TEH_KeyStateHandle *ksh; - struct GNUNET_TIME_Absolute now; ksh = TEH_keys_get_state (); if (NULL == ksh) @@ -557,8 +556,6 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection, NULL); } /* Parse denomination key hashes */ - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); for (unsigned int i = 0; i<num_fresh_coins; i++) { struct GNUNET_JSON_Specification spec[] = { @@ -584,8 +581,12 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection, if (NULL == dks[i]) return mret; - if (now.abs_value_us >= dks[i]->meta.expire_withdraw.abs_value_us) + if (GNUNET_TIME_absolute_is_past (dks[i]->meta.expire_withdraw)) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination is past the expiration time for withdraws */ return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, @@ -594,8 +595,12 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection, TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED, "REVEAL"); } - if (now.abs_value_us < dks[i]->meta.start.abs_value_us) + if (GNUNET_TIME_absolute_is_future (dks[i]->meta.start)) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination is not yet valid */ return TEH_RESPONSE_reply_expired_denom_pub_hash ( connection, diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index d0216c4c4..5c484653b 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c @@ -392,8 +392,12 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh, } now = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&now); - if (now.abs_value_us >= dk->meta.expire_withdraw.abs_value_us) + if (GNUNET_TIME_absolute_is_past (dk->meta.expire_withdraw)) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination is past the expiration time for withdraws */ GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_expired_denom_pub_hash ( @@ -403,8 +407,12 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh, TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED, "WITHDRAW"); } - if (now.abs_value_us < dk->meta.start.abs_value_us) + if (GNUNET_TIME_absolute_is_future (dk->meta.start)) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination is not yet valid */ GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_expired_denom_pub_hash ( @@ -416,6 +424,10 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh, } if (dk->recoup_possible) { + struct GNUNET_TIME_Absolute now; + + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); /* This denomination has been revoked */ GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_expired_denom_pub_hash ( |