-use new GNUNET_TIME functions
This commit is contained in:
parent
098bd64f39
commit
325b60989f
@ -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 (
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user