merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 154043468c0de4fb87fb66eebf5110f8ff909ea5
parent 8e703ec55501282f5fade998d8ce173f81f5fa49
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat,  7 Aug 2021 16:40:36 +0200

-code cleanup: use new GNUNET_TIME functions

Diffstat:
Msrc/backend/taler-merchant-httpd.c | 4+---
Msrc/backend/taler-merchant-httpd_auditors.c | 2+-
Msrc/backend/taler-merchant-httpd_exchanges.c | 12+++++-------
Msrc/backend/taler-merchant-httpd_post-orders-ID-pay.c | 2+-
Msrc/backend/taler-merchant-httpd_post-tips-ID-pickup.c | 2+-
Msrc/backend/taler-merchant-httpd_private-get-orders-ID.c | 6++----
Msrc/backend/taler-merchant-httpd_private-get-orders.c | 4+---
Msrc/backend/taler-merchant-httpd_private-post-orders-ID-refund.c | 3+--
Msrc/backend/taler-merchant-httpd_private-post-orders.c | 9+++------
9 files changed, 16 insertions(+), 28 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -410,9 +410,7 @@ do_resume (void *cls) sc = GNUNET_CONTAINER_heap_peek (resume_timeout_heap); if (NULL == sc) return; - if (0 != - GNUNET_TIME_absolute_get_remaining ( - sc->long_poll_timeout).rel_value_us) + if (GNUNET_TIME_absolute_is_future (sc->long_poll_timeout)) break; GNUNET_assert (sc == GNUNET_CONTAINER_heap_remove_root (resume_timeout_heap)); diff --git a/src/backend/taler-merchant-httpd_auditors.c b/src/backend/taler-merchant-httpd_auditors.c @@ -72,7 +72,7 @@ TMH_AUDITORS_check_dk (struct TALER_EXCHANGE_Handle *mh, const struct TALER_EXCHANGE_Keys *keys; const struct TALER_EXCHANGE_AuditorInformation *ai; - if (0 == GNUNET_TIME_absolute_get_remaining (dk->expire_deposit).rel_value_us) + if (GNUNET_TIME_absolute_is_past (dk->expire_deposit)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Denomination key offered by client has expired for deposits\n"); diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c @@ -567,7 +567,7 @@ process_find_operations (struct Exchange *exchange) { need_wire = true; /* Do not warn if this is before our first attempt */ - if (0 != exchange->wire_retry_delay.rel_value_us) + if (! GNUNET_TIME_relative_is_zero (exchange->wire_retry_delay)) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Exchange does not support `%s' wire method (will retry later)\n", fo->wire_method); @@ -976,7 +976,7 @@ keys_mgmt_cb (void *cls, delay = RELOAD_DELAY; else delay = GNUNET_TIME_absolute_get_remaining (expire); - if (0 == delay.rel_value_us) + if (GNUNET_TIME_relative_is_zero (delay)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "/keys response from exchange expired immediately! Retrying in 1 minute.\n"); @@ -1089,11 +1089,8 @@ TMH_EXCHANGES_find_exchange (const char *chosen_exchange, GNUNET_CONTAINER_DLL_insert (exchange->fo_head, exchange->fo_tail, fo); - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); if ( (force_reload) && - (0 == GNUNET_TIME_absolute_get_remaining ( - exchange->first_retry).rel_value_us) ) + (GNUNET_TIME_absolute_is_past (exchange->first_retry)) ) { /* increment exponential-backoff */ exchange->retry_delay = RETRY_BACKOFF (exchange->retry_delay); @@ -1108,7 +1105,8 @@ TMH_EXCHANGES_find_exchange (const char *chosen_exchange, return fo; } - + now = GNUNET_TIME_absolute_get (); + (void) GNUNET_TIME_round_abs (&now); if ( (! exchange->pending) && ( (NULL == fo->wire_method) || (NULL != get_wire_fees (exchange, diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -1797,7 +1797,7 @@ parse_pay (struct MHD_Connection *connection, NULL); } - if (0 == GNUNET_TIME_absolute_get_remaining (pc->pay_deadline).rel_value_us) + if (GNUNET_TIME_absolute_is_past (pc->pay_deadline)) { /* too late */ return (MHD_YES == diff --git a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c @@ -896,7 +896,7 @@ RETRY: return reply_lookup_tip_failed (connection, qs); } - if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) + if (GNUNET_TIME_absolute_is_past (expiration)) { GNUNET_free (exchange_url); TMH_db->rollback (TMH_db->cls); diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -1067,8 +1067,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, if ( (! paid) && (! order_only) ) { - if (0 != GNUNET_TIME_absolute_get_remaining ( - gorc->sc.long_poll_timeout).rel_value_us) + if (GNUNET_TIME_absolute_is_future (gorc->sc.long_poll_timeout)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Suspending GET /private/orders/%s\n", @@ -1122,8 +1121,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, } if ( (! paid) && - (0 != GNUNET_TIME_absolute_get_remaining ( - gorc->sc.long_poll_timeout).rel_value_us) ) + (GNUNET_TIME_absolute_is_future (gorc->sc.long_poll_timeout)) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Suspending GET /private/orders/%s\n", diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -163,9 +163,7 @@ order_timeout (void *cls) order_timeout_heap = NULL; return; } - if (0 != - GNUNET_TIME_absolute_get_remaining ( - po->long_poll_timeout).rel_value_us) + if (GNUNET_TIME_absolute_is_future (po->long_poll_timeout)) break; GNUNET_assert (po == GNUNET_CONTAINER_heap_remove_root (order_timeout_heap)); diff --git a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c @@ -164,8 +164,7 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_NOT_ALLOWED_BY_CONTRACT, NULL); } - if (0 == GNUNET_TIME_absolute_get_remaining ( - refund_deadline).rel_value_us) + if (GNUNET_TIME_absolute_is_past (refund_deadline)) { /* it is too late for refunds */ /* NOTE: We MAY still be lucky that the exchange did not yet diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -837,10 +837,9 @@ patch_order (struct MHD_Connection *connection, } /* If no refund_deadline given, set one based on refund_delay. */ - if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == - refund_deadline.abs_value_us) + if (GNUNET_TIME_absolute_is_never (refund_deadline)) { - if (0 == refund_delay.rel_value_us) + if (GNUNET_TIME_relative_is_zero (refund_delay)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Refund delay is zero, no refunds are possible for this order\n"); @@ -1324,9 +1323,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, struct TMH_HandlerContext *hc) { json_t *order; - struct GNUNET_TIME_Relative refund_delay = { - .rel_value_us = 0 - }; + struct GNUNET_TIME_Relative refund_delay = GNUNET_TIME_UNIT_ZERO; const char *payment_target = NULL; json_t *ip = NULL; unsigned int ips_len = 0;