diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-12-14 16:10:40 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-12-14 16:10:40 +0100 |
commit | ad5d54f48534ac0ad5bfd7f048bd7782e674a89b (patch) | |
tree | 4443e41c1aec412d82642b194aa3d837c9eb5cfd /src/backend | |
parent | 49e2e44b09dd845d0922c0acef5ff487b52bf26d (diff) | |
download | merchant-ad5d54f48534ac0ad5bfd7f048bd7782e674a89b.tar.gz merchant-ad5d54f48534ac0ad5bfd7f048bd7782e674a89b.tar.bz2 merchant-ad5d54f48534ac0ad5bfd7f048bd7782e674a89b.zip |
migration to protocol v11
Diffstat (limited to 'src/backend')
31 files changed, 271 insertions, 265 deletions
diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h index f81b15aa..93ca63d3 100644 --- a/src/backend/taler-merchant-httpd.h +++ b/src/backend/taler-merchant-httpd.h @@ -304,7 +304,7 @@ struct TMH_OrderChangeEventDetailsP /** * Execution date of the order. */ - struct GNUNET_TIME_AbsoluteNBO execution_date; + struct GNUNET_TIME_TimestampNBO execution_date; /** * See `enum TMH_OrderStateFlags`. In NBO. diff --git a/src/backend/taler-merchant-httpd_auditors.c b/src/backend/taler-merchant-httpd_auditors.c index e693935e..27b3524a 100644 --- 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 (GNUNET_TIME_absolute_is_past (dk->expire_deposit)) + if (GNUNET_TIME_absolute_is_past (dk->expire_deposit.abs_time)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Denomination key offered by client has expired for deposits\n"); diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c index 8f92bd07..753a25da 100644 --- a/src/backend/taler-merchant-httpd_config.c +++ b/src/backend/taler-merchant-httpd_config.c @@ -42,7 +42,8 @@ * #MERCHANT_PROTOCOL_CURRENT and #MERCHANT_PROTOCOL_AGE in * merchant_api_config.c! */ -#define MERCHANT_PROTOCOL_VERSION "2:0:0" +#define MERCHANT_PROTOCOL_VERSION "3:0:0" + MHD_RESULT MH_handler_config (struct TMH_RequestHandler *rh, diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c index f3603efe..accbd9c9 100644 --- a/src/backend/taler-merchant-httpd_exchanges.c +++ b/src/backend/taler-merchant-httpd_exchanges.c @@ -366,11 +366,15 @@ process_wire_fees (struct Exchange *exchange, endp = endp->next; while ( (NULL != endp) && (NULL != fees) && - (fees->start_date.abs_value_us < endp->end_date.abs_value_us) ) + (GNUNET_TIME_timestamp_cmp (fees->start_date, + <, + endp->end_date)) ) fees = fees->next; if ( (NULL != endp) && (NULL != fees) && - (fees->start_date.abs_value_us != endp->end_date.abs_value_us) ) + (GNUNET_TIME_timestamp_cmp (fees->start_date, + !=, + endp->end_date)) ) { /* Hole in the fee structure, not allowed! */ GNUNET_break_op (0); @@ -390,7 +394,7 @@ process_wire_fees (struct Exchange *exchange, "Storing wire fee for `%s' and method `%s' at %s in DB; the fee is %s\n", TALER_B2S (master_pub), wire_method, - GNUNET_STRINGS_absolute_time_to_string (af->start_date), + GNUNET_TIME_timestamp2s (af->start_date), TALER_amount2s (&af->wire_fee)); TMH_db->preflight (TMH_db->cls); if (GNUNET_OK != @@ -504,7 +508,7 @@ process_wire_accounts (struct Exchange *exchange, */ static struct FeesByWireMethod * get_wire_fees (struct Exchange *exchange, - struct GNUNET_TIME_Absolute now, + struct GNUNET_TIME_Timestamp now, const char *wire_method) { for (struct FeesByWireMethod *fbw = exchange->wire_fees_head; @@ -518,7 +522,9 @@ get_wire_fees (struct Exchange *exchange, /* Advance through list up to current time */ while ( (NULL != (af = fbw->af)) && - (now.abs_value_us >= af->end_date.abs_value_us) ) + (GNUNET_TIME_timestamp_cmp (now, + >=, + af->end_date)) ) { fbw->af = af->next; GNUNET_free (af); @@ -545,10 +551,10 @@ static bool process_find_operations (struct Exchange *exchange) { struct TMH_EXCHANGES_FindOperation *fn; - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp now; bool need_wire; - now = GNUNET_TIME_absolute_get (); + now = GNUNET_TIME_timestamp_get (); need_wire = false; for (struct TMH_EXCHANGES_FindOperation *fo = exchange->fo_head; NULL != fo; @@ -583,14 +589,17 @@ process_find_operations (struct Exchange *exchange) fbw = NULL; continue; } - if (fbw->af->start_date.abs_value_us > now.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (fbw->af->start_date, + >, + now)) { /* Disagreement on the current time */ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Exchange's earliest fee is %s ahead of our time. Clock skew issue?\n", - GNUNET_STRINGS_relative_time_to_string ( - GNUNET_TIME_absolute_get_remaining (fbw->af->start_date), - GNUNET_YES)); + GNUNET_TIME_relative2s ( + GNUNET_TIME_absolute_get_remaining ( + fbw->af->start_date.abs_time), + true)); fbw = NULL; continue; } @@ -902,7 +911,7 @@ keys_mgmt_cb (void *cls, enum TALER_EXCHANGE_VersionCompatibility compat) { struct Exchange *exchange = cls; - struct GNUNET_TIME_Absolute expire; + struct GNUNET_TIME_Timestamp expire; struct GNUNET_TIME_Relative delay; if ( (MHD_HTTP_OK != hr->http_status) || @@ -979,13 +988,13 @@ keys_mgmt_cb (void *cls, } } + exchange->first_retry = GNUNET_TIME_relative_to_absolute (RELOAD_DELAY); expire = TALER_EXCHANGE_check_keys_current (exchange->conn, TALER_EXCHANGE_CKF_NONE); - exchange->first_retry = GNUNET_TIME_relative_to_absolute (RELOAD_DELAY); - if (0 == expire.abs_value_us) + if (0 == GNUNET_TIME_absolute_is_zero (expire.abs_time)) delay = RELOAD_DELAY; else - delay = GNUNET_TIME_absolute_get_remaining (expire); + delay = GNUNET_TIME_absolute_get_remaining (expire.abs_time); if (GNUNET_TIME_relative_is_zero (delay)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1049,7 +1058,7 @@ TMH_EXCHANGES_find_exchange (const char *chosen_exchange, { struct Exchange *exchange; struct TMH_EXCHANGES_FindOperation *fo; - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp now; if (NULL == merchant_curl_ctx) { @@ -1115,8 +1124,7 @@ TMH_EXCHANGES_find_exchange (const char *chosen_exchange, return fo; } - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); + now = GNUNET_TIME_timestamp_get (); if ( (! exchange->pending) && ( (NULL == fo->wire_method) || (NULL != get_wire_fees (exchange, diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c index ddc1c1c7..db1c3fee 100644 --- a/src/backend/taler-merchant-httpd_get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_get-orders-ID.c @@ -738,7 +738,7 @@ send_pay_request (struct GetOrderData *god, static void process_refunds_cb (void *cls, uint64_t refund_serial, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Timestamp timestamp, const struct TALER_CoinSpendPublicKeyP *coin_pub, const char *exchange_url, uint64_t rtransaction_id, diff --git a/src/backend/taler-merchant-httpd_get-tips-ID.c b/src/backend/taler-merchant-httpd_get-tips-ID.c index 5b0abd89..4b4b2858 100644 --- a/src/backend/taler-merchant-httpd_get-tips-ID.c +++ b/src/backend/taler-merchant-httpd_get-tips-ID.c @@ -159,7 +159,7 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, enum GNUNET_DB_QueryStatus qs; struct TALER_Amount total_authorized; struct TALER_Amount total_picked_up; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; char *exchange_url; struct TALER_ReservePrivateKeyP reserve_priv; @@ -210,15 +210,12 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, /* Build response */ { struct TALER_Amount remaining; - struct GNUNET_TIME_Absolute expiration_round = expiration; MHD_RESULT ret; GNUNET_break (0 <= TALER_amount_subtract (&remaining, &total_authorized, &total_picked_up)); - - GNUNET_TIME_round_abs (&expiration_round); if (TMH_MHD_test_html_desired (connection)) { char *qr; @@ -274,16 +271,15 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, { ret = TALER_MHD_REPLY_JSON_PACK ( connection, - ( (0 == remaining.value) && - (0 == remaining.fraction) ) + TALER_amount_is_zero (&remaining) ? MHD_HTTP_GONE : MHD_HTTP_OK, GNUNET_JSON_pack_string ("exchange_url", exchange_url), TALER_JSON_pack_amount ("tip_amount", &remaining), - GNUNET_JSON_pack_time_abs ("expiration", - expiration_round)); + GNUNET_JSON_pack_timestamp ("expiration", + expiration)); } GNUNET_free (exchange_url); return ret; diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c index fe686dd3..e271cbaa 100644 --- a/src/backend/taler-merchant-httpd_helper.c +++ b/src/backend/taler-merchant-httpd_helper.c @@ -195,7 +195,7 @@ TMH_products_array_valid (const json_t *products) struct TALER_Amount price; const char *image_data_url = NULL; json_t *taxes = NULL; - struct GNUNET_TIME_Absolute delivery_date; + struct GNUNET_TIME_Timestamp delivery_date; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("product_id", @@ -222,8 +222,8 @@ TMH_products_array_valid (const json_t *products) GNUNET_JSON_spec_json ("taxes", &taxes)), GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_absolute_time ("delivery_date", - &delivery_date)), + GNUNET_JSON_spec_timestamp ("delivery_date", + &delivery_date)), GNUNET_JSON_spec_end () }; const char *ename; diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c index e3afaffb..4c5f0313 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c @@ -658,13 +658,13 @@ refund_coins (void *cls, const struct TALER_Amount *wire_fee) { struct AbortContext *ac = cls; - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp now; (void) amount_with_fee; (void) deposit_fee; (void) refund_fee; (void) wire_fee; - now = GNUNET_TIME_absolute_get (); + now = GNUNET_TIME_timestamp_get (); for (unsigned int i = 0; i<ac->coins_cnt; i++) { struct RefundDetails *rdi = &ac->rd[i]; diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c index 089933ea..16990d4b 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c @@ -123,10 +123,10 @@ claim_order (const char *instance_id, { struct GNUNET_HashCode unused; - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp timestamp; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_absolute_time ("timestamp", - ×tamp), + GNUNET_JSON_spec_timestamp ("timestamp", + ×tamp), GNUNET_JSON_spec_end () }; diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c index 7867e1ea..bea47c4e 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -291,22 +291,22 @@ struct PayContext * Wire transfer deadline. How soon would the merchant like the * wire transfer to be executed? */ - struct GNUNET_TIME_Absolute wire_transfer_deadline; + struct GNUNET_TIME_Timestamp wire_transfer_deadline; /** * Timestamp from @e contract_terms. */ - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp timestamp; /** * Refund deadline from @e contract_terms. */ - struct GNUNET_TIME_Absolute refund_deadline; + struct GNUNET_TIME_Timestamp refund_deadline; /** * Deadline for the customer to pay for this proposal. */ - struct GNUNET_TIME_Absolute pay_deadline; + struct GNUNET_TIME_Timestamp pay_deadline; /** * Number of transactions that the wire fees are expected to be @@ -419,7 +419,7 @@ struct KycContext /** * Initial DB timestamp. */ - struct GNUNET_TIME_Absolute kyc_timestamp; + struct GNUNET_TIME_Timestamp kyc_timestamp; /** * Initial KYC status. @@ -686,11 +686,10 @@ deposit_get_callback ( { struct KycContext *kc = cls; enum GNUNET_DB_QueryStatus qs; - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp now; kc->dg = NULL; - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); + now = GNUNET_TIME_timestamp_get (); switch (dr->hr.http_status) { case MHD_HTTP_OK: @@ -791,7 +790,7 @@ kyc_cb ( uint64_t exchange_kyc_serial, const char *payto_uri, const char *exchange_url, - struct GNUNET_TIME_Absolute last_check, + struct GNUNET_TIME_Timestamp last_check, bool kyc_ok) { struct KycContext *kc = cls; @@ -837,8 +836,10 @@ check_kyc (struct PayContext *pc, GNUNET_free (kc); return; /* we are done */ } - if (GNUNET_TIME_absolute_get_duration (kc->kyc_timestamp).rel_value_us < - KYC_RETRY_FREQUENCY.rel_value_us) + if (GNUNET_TIME_relative_cmp (GNUNET_TIME_absolute_get_duration ( + kc->kyc_timestamp.abs_time), + <, + KYC_RETRY_FREQUENCY)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Not re-checking KYC status at `%s', as we already recently asked\n", @@ -2113,14 +2114,14 @@ parse_pay (struct MHD_Connection *connection, &pc->max_wire_fee), GNUNET_JSON_spec_uint32 ("wire_fee_amortization", &pc->wire_fee_amortization), - TALER_JSON_spec_absolute_time ("timestamp", - &pc->timestamp), - TALER_JSON_spec_absolute_time ("refund_deadline", - &pc->refund_deadline), - TALER_JSON_spec_absolute_time ("pay_deadline", - &pc->pay_deadline), - TALER_JSON_spec_absolute_time ("wire_transfer_deadline", - &pc->wire_transfer_deadline), + GNUNET_JSON_spec_timestamp ("timestamp", + &pc->timestamp), + GNUNET_JSON_spec_timestamp ("refund_deadline", + &pc->refund_deadline), + GNUNET_JSON_spec_timestamp ("pay_deadline", + &pc->pay_deadline), + GNUNET_JSON_spec_timestamp ("wire_transfer_deadline", + &pc->wire_transfer_deadline), GNUNET_JSON_spec_fixed_auto ("h_wire", &pc->h_wire), GNUNET_JSON_spec_end () @@ -2140,8 +2141,9 @@ parse_pay (struct MHD_Connection *connection, } } - if (pc->wire_transfer_deadline.abs_value_us < - pc->refund_deadline.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (pc->wire_transfer_deadline, + <, + pc->refund_deadline)) { /* This should already have been checked when creating the order! */ GNUNET_break (0); @@ -2151,7 +2153,7 @@ parse_pay (struct MHD_Connection *connection, NULL); } - if (GNUNET_TIME_absolute_is_past (pc->pay_deadline)) + if (GNUNET_TIME_absolute_is_past (pc->pay_deadline.abs_time)) { /* too late */ return (MHD_YES == diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c index 8ba00129..c6011d21 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c @@ -79,7 +79,7 @@ struct CoinRefund * When did the merchant grant the refund. To be used to group events * in the wallet. */ - struct GNUNET_TIME_Absolute execution_time; + struct GNUNET_TIME_Timestamp execution_time; /** * Coin to refund. @@ -500,7 +500,7 @@ exchange_found_cb (void *cls, static void process_refunds_cb (void *cls, uint64_t refund_serial, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Timestamp timestamp, const struct TALER_CoinSpendPublicKeyP *coin_pub, const char *exchange_url, uint64_t rtransaction_id, @@ -770,8 +770,8 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, &cr->coin_pub), TALER_JSON_pack_amount ("refund_amount", &cr->refund_amount), - GNUNET_JSON_pack_time_abs ("execution_time", - cr->execution_time)); + GNUNET_JSON_pack_timestamp ("execution_time", + cr->execution_time)); } else { @@ -790,8 +790,8 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, &cr->coin_pub), TALER_JSON_pack_amount ("refund_amount", &cr->refund_amount), - GNUNET_JSON_pack_time_abs ("execution_time", - cr->execution_time)); + GNUNET_JSON_pack_timestamp ("execution_time", + cr->execution_time)); } } else @@ -811,8 +811,8 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, &cr->coin_pub), TALER_JSON_pack_amount ("refund_amount", &cr->refund_amount), - GNUNET_JSON_pack_time_abs ("execution_time", - cr->execution_time)); + GNUNET_JSON_pack_timestamp ("execution_time", + cr->execution_time)); } GNUNET_assert ( 0 == diff --git a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c index c7c28a13..c60ba021 100644 --- a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c +++ b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c @@ -619,7 +619,7 @@ TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh, struct TALER_Amount total_authorized; struct TALER_Amount total_picked_up; struct TALER_Amount total_remaining; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; enum GNUNET_DB_QueryStatus qs; unsigned int num_retries; @@ -911,7 +911,7 @@ RETRY: return reply_lookup_tip_failed (connection, qs); } - if (GNUNET_TIME_absolute_is_past (expiration)) + if (GNUNET_TIME_absolute_is_past (expiration.abs_time)) { GNUNET_free (exchange_url); TMH_db->rollback (TMH_db->cls); diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c index d18ea668..03f799a9 100644 --- a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c +++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c @@ -96,7 +96,7 @@ struct ExchangeKycRequest /** * Timestamp when we last got a reply from the exchange. */ - struct GNUNET_TIME_Absolute last_check; + struct GNUNET_TIME_Timestamp last_check; /** * Last KYC status returned by the exchange. @@ -427,10 +427,10 @@ exchange_check_cb (void *cls, break; case MHD_HTTP_NO_CONTENT: { - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp now; enum GNUNET_DB_QueryStatus qs; - now = GNUNET_TIME_absolute_get (); + now = GNUNET_TIME_timestamp_get (); qs = TMH_db->account_kyc_set_status (TMH_db->cls, kc->mi->settings.id, &ekr->h_wire, @@ -555,15 +555,17 @@ kyc_status_cb (void *cls, uint64_t exchange_kyc_serial, const char *payto_uri, const char *exchange_url, - struct GNUNET_TIME_Absolute last_check, + struct GNUNET_TIME_Timestamp last_check, bool kyc_ok) { struct KycContext *kc = cls; struct ExchangeKycRequest *ekr; if (kyc_ok && - (GNUNET_TIME_absolute_get_duration (last_check).rel_value_us < - STALE_KYC_TIMEOUT.rel_value_us) ) + (GNUNET_TIME_relative_cmp ( + GNUNET_TIME_absolute_get_duration (last_check.abs_time), + <, + STALE_KYC_TIMEOUT)) ) return; /* KYC ok, ignore! */ kc->response_code = MHD_HTTP_ACCEPTED; ekr = GNUNET_new (struct ExchangeKycRequest); diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c index 5b2bfeb0..328ffbf0 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -505,10 +505,9 @@ deposit_get_cb (void *cls, /* got a 'preliminary' reply from the exchange, remember our target UUID */ enum GNUNET_DB_QueryStatus qs; - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp now; - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); + now = GNUNET_TIME_timestamp_get (); qs = TMH_db->account_kyc_set_status ( TMH_db->cls, gorc->hc->instance->settings.id, @@ -740,7 +739,7 @@ gorc_cleanup (void *cls) static void process_refunds_cb (void *cls, uint64_t refund_serial, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Timestamp timestamp, const struct TALER_CoinSpendPublicKeyP *coin_pub, const char *exchange_url, uint64_t rtransaction_id, @@ -756,8 +755,8 @@ process_refunds_cb (void *cls, GNUNET_JSON_PACK ( TALER_JSON_pack_amount ("amount", refund_amount), - GNUNET_JSON_pack_time_abs ("timestamp", - timestamp), + GNUNET_JSON_pack_timestamp ("timestamp", + timestamp), GNUNET_JSON_pack_string ("reason", reason)))); /* For refunded coins, we are not charged deposit fees, so subtract those @@ -802,7 +801,7 @@ static void process_transfer_details (void *cls, const struct TALER_WireTransferIdentifierRawP *wtid, const char *exchange_url, - struct GNUNET_TIME_Absolute execution_time, + struct GNUNET_TIME_Timestamp execution_time, const struct TALER_Amount *deposit_value, const struct TALER_Amount *deposit_fee, bool transfer_confirmed) @@ -810,7 +809,6 @@ process_transfer_details (void *cls, struct GetOrderRequestContext *gorc = cls; json_t *wire_details = gorc->wire_details; struct TALER_Amount wired; - struct GNUNET_TIME_Absolute execution_time_round = execution_time; /* Compute total amount *wired* */ GNUNET_assert (0 < @@ -822,7 +820,6 @@ process_transfer_details (void *cls, &gorc->deposit_fees_total, deposit_fee)); - GNUNET_TIME_round_abs (&execution_time_round); GNUNET_assert (0 <= TALER_amount_subtract (&wired, deposit_value, @@ -837,8 +834,8 @@ process_transfer_details (void *cls, exchange_url), TALER_JSON_pack_amount ("amount", &wired), - GNUNET_JSON_pack_time_abs ("execution_time", - execution_time_round), + GNUNET_JSON_pack_timestamp ("execution_time", + execution_time), GNUNET_JSON_pack_bool ("confirmed", transfer_confirmed)))); } @@ -856,7 +853,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, bool order_only = false; struct TALER_ClaimTokenP claim_token = { 0 }; const char *summary; - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp timestamp; if (NULL == gorc) { @@ -1067,8 +1064,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, &gorc->fulfillment_url)), GNUNET_JSON_spec_string ("summary", &summary), - TALER_JSON_spec_absolute_time ("timestamp", - ×tamp), + GNUNET_JSON_spec_timestamp ("timestamp", + ×tamp), GNUNET_JSON_spec_end () }; @@ -1210,8 +1207,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, &gorc->contract_amount), GNUNET_JSON_pack_string ("summary", summary), - GNUNET_JSON_pack_time_abs ("creation_time", - timestamp)); + GNUNET_JSON_pack_timestamp ("creation_time", + timestamp)); GNUNET_free (taler_pay_uri); GNUNET_free (already_paid_order_id); return ret; @@ -1323,8 +1320,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, &gorc->contract_amount), GNUNET_JSON_pack_string ("summary", summary), - GNUNET_JSON_pack_time_abs ("creation_time", - timestamp)); + GNUNET_JSON_pack_timestamp ("creation_time", + timestamp)); GNUNET_free (taler_pay_uri); GNUNET_free (order_status_url); return ret; diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c index 9546ae06..29b6e65a 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders.c +++ b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -241,7 +241,7 @@ cleanup (void *ctx) static void process_refunds_cb (void *cls, uint64_t refund_serial, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Timestamp timestamp, const struct TALER_CoinSpendPublicKeyP *coin_pub, const char *exchange_url, uint64_t rtransaction_id, @@ -270,7 +270,7 @@ static void add_order (void *cls, const char *orig_order_id, uint64_t order_serial, - struct GNUNET_TIME_Absolute creation_time) + struct GNUNET_TIME_Timestamp creation_time) { struct TMH_PendingOrder *po = cls; json_t *contract_terms = NULL; @@ -356,13 +356,13 @@ add_order (void *cls, } { - struct GNUNET_TIME_Absolute rd; + struct GNUNET_TIME_Timestamp rd; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("amount", TMH_currency, &order_amount), - GNUNET_JSON_spec_absolute_time ("refund_deadline", - &rd), + GNUNET_JSON_spec_timestamp ("refund_deadline", + &rd), GNUNET_JSON_spec_string ("summary", &summary), GNUNET_JSON_spec_end () @@ -380,7 +380,7 @@ add_order (void *cls, return; } - if (GNUNET_TIME_absolute_is_future (rd) && + if (GNUNET_TIME_absolute_is_future (rd.abs_time) && paid) { struct TALER_Amount refund_amount; @@ -415,8 +415,8 @@ add_order (void *cls, order_id), GNUNET_JSON_pack_uint64 ("row_id", order_serial), - GNUNET_JSON_pack_time_abs ("timestamp", - creation_time), + GNUNET_JSON_pack_timestamp ("timestamp", + creation_time), TALER_JSON_pack_amount ("amount", &order_amount), GNUNET_JSON_pack_string ("summary", @@ -448,7 +448,7 @@ resume_by_event (void *cls, struct TMH_PendingOrder *pn; enum TMH_OrderStateFlags osf; uint64_t order_serial_id; - struct GNUNET_TIME_Absolute date; + struct GNUNET_TIME_Timestamp date; if (sizeof (*oce) != extra_size) { @@ -457,7 +457,7 @@ resume_by_event (void *cls, } osf = (enum TMH_OrderStateFlags) ntohl (oce->order_state); order_serial_id = GNUNET_ntohll (oce->order_serial_id); - date = GNUNET_TIME_absolute_ntoh (oce->execution_date); + date = GNUNET_TIME_timestamp_ntoh (oce->execution_date); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received notification about new order %llu\n", (unsigned long long) order_serial_id); @@ -490,7 +490,9 @@ resume_by_event (void *cls, po); continue; } - if (date.abs_value_us < po->of.date.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (date, + <, + po->of.date)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Client %p waits on different order date\n", @@ -508,7 +510,9 @@ resume_by_event (void *cls, po); continue; } - if (date.abs_value_us > po->of.date.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (date, + >, + po->of.date)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Client %p waits on different order date\n", @@ -555,12 +559,12 @@ resume_by_event (void *cls, void TMH_notify_order_change (struct TMH_MerchantInstance *mi, enum TMH_OrderStateFlags osf, - struct GNUNET_TIME_Absolute date, + struct GNUNET_TIME_Timestamp date, uint64_t order_serial_id) { struct TMH_OrderChangeEventDetailsP oce = { .order_serial_id = GNUNET_htonll (order_serial_id), - .execution_date = GNUNET_TIME_absolute_hton (date), + .execution_date = GNUNET_TIME_timestamp_hton (date), .order_state = htonl (osf) }; struct TMH_OrderChangeEventP eh = { @@ -679,6 +683,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, } } } + // FIXME: use date_s, as we round to seconds anyway! { const char *date_ms_str; @@ -688,9 +693,9 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, if (NULL == date_ms_str) { if (of.delta > 0) - of.date = GNUNET_TIME_UNIT_ZERO_ABS; + of.date = GNUNET_TIME_UNIT_ZERO_TS; else - of.date = GNUNET_TIME_UNIT_FOREVER_ABS; + of.date = GNUNET_TIME_UNIT_FOREVER_TS; } else { @@ -710,8 +715,9 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, "date_ms"); } - of.date = GNUNET_TIME_absolute_from_ms (ll); - if (GNUNET_TIME_absolute_is_never (of.date)) + of.date = GNUNET_TIME_absolute_to_timestamp ( + GNUNET_TIME_absolute_from_ms (ll)); + if (GNUNET_TIME_absolute_is_never (of.date.abs_time)) { GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, diff --git a/src/backend/taler-merchant-httpd_private-get-orders.h b/src/backend/taler-merchant-httpd_private-get-orders.h index 53a20b17..833c9ca4 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders.h +++ b/src/backend/taler-merchant-httpd_private-get-orders.h @@ -50,7 +50,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, void TMH_notify_order_change (struct TMH_MerchantInstance *mi, enum TMH_OrderStateFlags osf, - struct GNUNET_TIME_Absolute date, + struct GNUNET_TIME_Timestamp date, uint64_t order_serial_id); diff --git a/src/backend/taler-merchant-httpd_private-get-products-ID.c b/src/backend/taler-merchant-httpd_private-get-products-ID.c index 6af8236c..1cff0deb 100644 --- a/src/backend/taler-merchant-httpd_private-get-products-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-products-ID.c @@ -89,7 +89,7 @@ TMH_private_get_products_ID (const struct TMH_RequestHandler *rh, GNUNET_JSON_pack_object_steal ("address", pd.address), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_time_abs ("next_restock", + GNUNET_JSON_pack_timestamp ("next_restock", (pd.next_restock)))); GNUNET_free (pd.description); GNUNET_free (pd.image); diff --git a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c index e0cee3a7..5b1481a7 100644 --- a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c @@ -70,8 +70,8 @@ struct GetReserveContext */ static void handle_reserve_details (void *cls, - struct GNUNET_TIME_Absolute creation_time, - struct GNUNET_TIME_Absolute expiration_time, + struct GNUNET_TIME_Timestamp creation_time, + struct GNUNET_TIME_Timestamp expiration_time, const struct TALER_Amount *merchant_initial_amount, const struct TALER_Amount *exchange_initial_amount, const struct TALER_Amount *picked_up_amount, @@ -84,11 +84,6 @@ handle_reserve_details (void *cls, { struct GetReserveContext *ctx = cls; json_t *tips_json; - struct GNUNET_TIME_Absolute creation_time_round = creation_time; - struct GNUNET_TIME_Absolute expiration_time_round = expiration_time; - - GNUNET_TIME_round_abs (&creation_time_round); - GNUNET_TIME_round_abs (&expiration_time_round); if (NULL != tips) { @@ -115,10 +110,10 @@ handle_reserve_details (void *cls, ctx->res = TALER_MHD_REPLY_JSON_PACK ( ctx->connection, MHD_HTTP_OK, - GNUNET_JSON_pack_time_abs ("creation_time", - creation_time_round), - GNUNET_JSON_pack_time_abs ("expiration_time", - expiration_time_round), + GNUNET_JSON_pack_timestamp ("creation_time", + creation_time), + GNUNET_JSON_pack_timestamp ("expiration_time", + expiration_time), TALER_JSON_pack_amount ("merchant_initial_amount", merchant_initial_amount), TALER_JSON_pack_amount ("exchange_initial_amount", diff --git a/src/backend/taler-merchant-httpd_private-get-reserves.c b/src/backend/taler-merchant-httpd_private-get-reserves.c index f231a292..be0925d3 100644 --- a/src/backend/taler-merchant-httpd_private-get-reserves.c +++ b/src/backend/taler-merchant-httpd_private-get-reserves.c @@ -41,8 +41,8 @@ static void add_reserve (void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, - struct GNUNET_TIME_Absolute creation_time, - struct GNUNET_TIME_Absolute expiration_time, + struct GNUNET_TIME_Timestamp creation_time, + struct GNUNET_TIME_Timestamp expiration_time, const struct TALER_Amount *merchant_initial_amount, const struct TALER_Amount *exchange_initial_amount, const struct TALER_Amount *pickup_amount, @@ -50,21 +50,17 @@ add_reserve (void *cls, bool active) { json_t *pa = cls; - struct GNUNET_TIME_Absolute creation_time_round = creation_time; - struct GNUNET_TIME_Absolute expiration_time_round = expiration_time; - GNUNET_TIME_round_abs (&creation_time_round); - GNUNET_TIME_round_abs (&expiration_time_round); GNUNET_assert (0 == json_array_append_new ( pa, GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("reserve_pub", reserve_pub), - GNUNET_JSON_pack_time_abs ("creation_time", - creation_time_round), - GNUNET_JSON_pack_time_abs ("expiration_time", - expiration_time_round), + GNUNET_JSON_pack_timestamp ("creation_time", + creation_time), + GNUNET_JSON_pack_timestamp ("expiration_time", + expiration_time), TALER_JSON_pack_amount ("merchant_initial_amount", merchant_initial_amount), TALER_JSON_pack_amount ("exchange_initial_amount", @@ -93,7 +89,8 @@ TMH_private_get_reserves (const struct TMH_RequestHandler *rh, { json_t *ra; enum GNUNET_DB_QueryStatus qs; - struct GNUNET_TIME_Absolute created_after = { 0 }; + struct GNUNET_TIME_Timestamp created_after + = GNUNET_TIME_UNIT_ZERO_TS; enum TALER_EXCHANGE_YesNoAll active; enum TALER_EXCHANGE_YesNoAll failures; diff --git a/src/backend/taler-merchant-httpd_private-get-tips-ID.c b/src/backend/taler-merchant-httpd_private-get-tips-ID.c index ee26f9e5..0460b3c7 100644 --- a/src/backend/taler-merchant-httpd_private-get-tips-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-tips-ID.c @@ -37,7 +37,7 @@ TMH_private_get_tips_ID (const struct TMH_RequestHandler *rh, struct TALER_Amount total_authorized; struct TALER_Amount total_picked_up; char *reason; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; struct TALER_ReservePublicKeyP reserve_pub; unsigned int pickups_length = 0; struct TALER_MERCHANTDB_PickupDetails *pickups = NULL; @@ -131,11 +131,8 @@ TMH_private_get_tips_ID (const struct TMH_RequestHandler *rh, pickups_length, 0); { - struct GNUNET_TIME_Absolute expiration_round = expiration; MHD_RESULT ret; - GNUNET_TIME_round_abs (&expiration_round); - ret = TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, @@ -145,8 +142,8 @@ TMH_private_get_tips_ID (const struct TMH_RequestHandler *rh, &total_picked_up), GNUNET_JSON_pack_string ("reason", reason), - GNUNET_JSON_pack_time_abs ("expiration", - expiration_round), + GNUNET_JSON_pack_timestamp ("expiration", + expiration), GNUNET_JSON_pack_data_auto ("reserve_pub", &reserve_pub), GNUNET_JSON_pack_allow_null ( diff --git a/src/backend/taler-merchant-httpd_private-get-transfers.c b/src/backend/taler-merchant-httpd_private-get-transfers.c index c1d243f7..03a7beaa 100644 --- a/src/backend/taler-merchant-httpd_private-get-transfers.c +++ b/src/backend/taler-merchant-httpd_private-get-transfers.c @@ -49,7 +49,7 @@ transfer_cb (void *cls, const char *payto_uri, const char *exchange_url, uint64_t transfer_serial_id, - struct GNUNET_TIME_Absolute execution_time, + struct GNUNET_TIME_Timestamp execution_time, bool verified, bool confirmed) { @@ -72,11 +72,11 @@ transfer_cb (void *cls, GNUNET_JSON_pack_bool ("confirmed", confirmed), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_time_abs ( + GNUNET_JSON_pack_timestamp ( "execution_time", - GNUNET_TIME_absolute_is_never (execution_time) - ? GNUNET_TIME_UNIT_ZERO_ABS /* => field omitted */ - : execution_time) )); + GNUNET_TIME_absolute_is_never (execution_time.abs_time) + ? GNUNET_TIME_UNIT_ZERO_TS /* => field omitted */ + : execution_time)) ); GNUNET_assert (0 == json_array_append_new (ja, r)); @@ -97,8 +97,8 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, struct TMH_HandlerContext *hc) { const char *payto_uri; - struct GNUNET_TIME_Absolute before = GNUNET_TIME_UNIT_FOREVER_ABS; - struct GNUNET_TIME_Absolute after = GNUNET_TIME_UNIT_ZERO_ABS; + struct GNUNET_TIME_Timestamp before = GNUNET_TIME_UNIT_FOREVER_TS; + struct GNUNET_TIME_Timestamp after = GNUNET_TIME_UNIT_ZERO_TS; int64_t limit = -20; uint64_t offset; enum TALER_EXCHANGE_YesNoAll verified; @@ -114,8 +114,8 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, "before"); if ( (NULL != before_s) && (GNUNET_OK != - GNUNET_STRINGS_fancy_time_to_absolute (before_s, - &before)) ) + GNUNET_STRINGS_fancy_time_to_timestamp (before_s, + &before)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, @@ -129,8 +129,8 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, "after"); if ( (NULL != after_s) && (GNUNET_OK != - GNUNET_STRINGS_fancy_time_to_absolute (after_s, - &after)) ) + GNUNET_STRINGS_fancy_time_to_timestamp (after_s, + &after)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c index d7ebc1f2..2ea0508b 100644 --- a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c @@ -83,10 +83,10 @@ patch_instances_ID (struct TMH_MerchantInstance *mi, TALER_JSON_spec_amount ("default_max_deposit_fee", TMH_currency, &is.default_max_deposit_fee), - TALER_JSON_spec_relative_time ("default_wire_transfer_delay", - &is.default_wire_transfer_delay), - TALER_JSON_spec_relative_time ("default_pay_delay", - &is.default_pay_delay), + GNUNET_JSON_spec_relative_time ("default_wire_transfer_delay", + &is.default_wire_transfer_delay), + GNUNET_JSON_spec_relative_time ("default_pay_delay", + &is.default_pay_delay), GNUNET_JSON_spec_end () }; enum GNUNET_DB_QueryStatus qs; diff --git a/src/backend/taler-merchant-httpd_private-patch-products-ID.c b/src/backend/taler-merchant-httpd_private-patch-products-ID.c index b146b31f..13a5c664 100644 --- a/src/backend/taler-merchant-httpd_private-patch-products-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-products-ID.c @@ -142,7 +142,7 @@ TMH_private_patch_products_ID (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_json ("address", &pd.address)), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_absolute_time ("next_restock", + GNUNET_JSON_spec_timestamp ("next_restock", &pd.next_restock)), GNUNET_JSON_spec_end () }; diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c index 0ab7fce6..d512d439 100644 --- a/src/backend/taler-merchant-httpd_private-post-instances.c +++ b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -170,10 +170,10 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, TALER_JSON_spec_amount ("default_max_deposit_fee", TMH_currency, &is.default_max_deposit_fee), - TALER_JSON_spec_relative_time ("default_wire_transfer_delay", - &is.default_wire_transfer_delay), - TALER_JSON_spec_relative_time ("default_pay_delay", - &is.default_pay_delay), + GNUNET_JSON_spec_relative_time ("default_wire_transfer_delay", + &is.default_wire_transfer_delay), + GNUNET_JSON_spec_relative_time ("default_pay_delay", + &is.default_pay_delay), GNUNET_JSON_spec_end () }; 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 index 2f98be98..fe120212 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c @@ -156,8 +156,8 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, enum GNUNET_DB_QueryStatus qs; json_t *contract_terms; uint64_t order_serial; - struct GNUNET_TIME_Absolute refund_deadline; - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp refund_deadline; + struct GNUNET_TIME_Timestamp timestamp; qs = TMH_db->lookup_contract_terms (TMH_db->cls, hc->instance->settings.id, @@ -168,10 +168,10 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_absolute_time ("refund_deadline", - &refund_deadline), - TALER_JSON_spec_absolute_time ("timestamp", - ×tamp), + GNUNET_JSON_spec_timestamp ("refund_deadline", + &refund_deadline), + GNUNET_JSON_spec_timestamp ("timestamp", + ×tamp), GNUNET_JSON_spec_end () }; @@ -190,7 +190,9 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, "mandatory fields missing"); } json_decref (contract_terms); - if (timestamp.abs_value_us == refund_deadline.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (timestamp, + ==, + refund_deadline)) { /* refund was never allowed, so we should refuse hard */ return TALER_MHD_reply_with_error ( @@ -199,7 +201,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 (GNUNET_TIME_absolute_is_past (refund_deadline)) + if (GNUNET_TIME_absolute_is_past (refund_deadline.abs_time)) { /* it is too late for refunds */ /* NOTE: We MAY still be lucky that the exchange did not yet @@ -335,7 +337,7 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, } { - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp timestamp; uint64_t order_serial; enum GNUNET_DB_QueryStatus qs; diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index 41b211eb..35cdf790 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -145,7 +145,7 @@ make_merchant_base_url (struct MHD_Connection *connection, "X-Forwarded-Prefix"); if (NULL != uri_path) GNUNET_buffer_write_path (&buf, uri_path); - + if (0 != strcmp (instance_id, "default")) { @@ -198,7 +198,7 @@ static enum GNUNET_DB_QueryStatus execute_transaction (struct TMH_HandlerContext *hc, const char *order_id, const struct GNUNET_HashCode *h_post_data, - struct GNUNET_TIME_Absolute pay_deadline, + struct GNUNET_TIME_Timestamp pay_deadline, const json_t *order, const struct TALER_ClaimTokenP *claim_token, unsigned int inventory_products_length, @@ -208,7 +208,7 @@ execute_transaction (struct TMH_HandlerContext *hc, unsigned int *out_of_stock_index) { enum GNUNET_DB_QueryStatus qs; - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp timestamp; uint64_t order_serial; if (GNUNET_OK != @@ -333,10 +333,10 @@ execute_order (struct MHD_Connection *connection, json_t *merchant; json_t *summary_i18n = NULL; json_t *fulfillment_i18n = NULL; - struct GNUNET_TIME_Absolute timestamp; - struct GNUNET_TIME_Absolute refund_deadline = { 0 }; - struct GNUNET_TIME_Absolute wire_transfer_deadline; - struct GNUNET_TIME_Absolute pay_deadline; + struct GNUNET_TIME_Timestamp timestamp; + struct GNUNET_TIME_Timestamp refund_deadline = { 0 }; + struct GNUNET_TIME_Timestamp wire_transfer_deadline; + struct GNUNET_TIME_Timestamp pay_deadline; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("amount", TMH_currency, @@ -361,15 +361,15 @@ execute_order (struct MHD_Connection *connection, GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_json ("fulfillment_message_i18n", &fulfillment_i18n)), - TALER_JSON_spec_absolute_time ("timestamp", - ×tamp), + GNUNET_JSON_spec_timestamp ("timestamp", + ×tamp), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_absolute_time ("refund_deadline", - &refund_deadline)), - TALER_JSON_spec_absolute_time ("pay_deadline", - &pay_deadline), - TALER_JSON_spec_absolute_time ("wire_transfer_deadline", - &wire_transfer_deadline), + GNUNET_JSON_spec_timestamp ("refund_deadline", + &refund_deadline)), + GNUNET_JSON_spec_timestamp ("pay_deadline", + &pay_deadline), + GNUNET_JSON_spec_timestamp ("wire_transfer_deadline", + &wire_transfer_deadline), GNUNET_JSON_spec_end () }; enum GNUNET_DB_QueryStatus qs; @@ -563,7 +563,7 @@ execute_order (struct MHD_Connection *connection, "available_quantity", pd.total_stock - pd.total_sold - pd.total_lost), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_time_abs ( + GNUNET_JSON_pack_timestamp ( "restock_expected", pd.next_restock))); TALER_MERCHANTDB_product_details_free (&pd); @@ -659,13 +659,16 @@ patch_order (struct MHD_Connection *connection, struct TALER_Amount max_wire_fee = { 0 }; struct TALER_Amount max_fee = { 0 }; uint32_t wire_fee_amortization = 0; - struct GNUNET_TIME_Absolute timestamp = { 0 }; - struct GNUNET_TIME_Absolute delivery_date = { 0 }; - struct GNUNET_TIME_Absolute refund_deadline - = GNUNET_TIME_UNIT_FOREVER_ABS; - struct GNUNET_TIME_Absolute pay_deadline = { 0 }; - struct GNUNET_TIME_Absolute wire_deadline - = GNUNET_TIME_UNIT_FOREVER_ABS; + struct GNUNET_TIME_Timestamp timestamp + = GNUNET_TIME_UNIT_ZERO_TS; + struct GNUNET_TIME_Timestamp delivery_date + = GNUNET_TIME_UNIT_ZERO_TS; + struct GNUNET_TIME_Timestamp refund_deadline + = GNUNET_TIME_UNIT_FOREVER_TS; + struct GNUNET_TIME_Timestamp pay_deadline + = GNUNET_TIME_UNIT_ZERO_TS; + struct GNUNET_TIME_Timestamp wire_deadline + = GNUNET_TIME_UNIT_FOREVER_TS; /* auto_refund only needs to be type-checked, * mostly because in GNUnet relative times can't * be negative. */ @@ -684,17 +687,17 @@ patch_order (struct MHD_Connection *connection, GNUNET_JSON_spec_string ("fulfillment_url", &fulfillment_url)), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_absolute_time ("timestamp", - ×tamp)), + GNUNET_JSON_spec_timestamp ("timestamp", + ×tamp)), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_absolute_time ("refund_deadline", - &refund_deadline)), + GNUNET_JSON_spec_timestamp ("refund_deadline", + &refund_deadline)), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_absolute_time ("pay_deadline", - &pay_deadline)), + GNUNET_JSON_spec_timestamp ("pay_deadline", + &pay_deadline)), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_absolute_time ("wire_transfer_deadline", - &wire_deadline)), + GNUNET_JSON_spec_timestamp ("wire_transfer_deadline", + &wire_deadline)), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_amount ("max_fee", TMH_currency, @@ -707,11 +710,11 @@ patch_order (struct MHD_Connection *connection, GNUNET_JSON_spec_uint32 ("wire_fee_amortization", &wire_fee_amortization)), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_absolute_time ("delivery_date", - &delivery_date)), + GNUNET_JSON_spec_timestamp ("delivery_date", + &delivery_date)), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_relative_time ("auto_refund", - &auto_refund)), + GNUNET_JSON_spec_relative_time ("auto_refund", + &auto_refund)), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_json ("delivery_location", &delivery_location)), @@ -825,20 +828,19 @@ patch_order (struct MHD_Connection *connection, /* Check soundness of refund deadline, and that a timestamp * is actually present. */ { - struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); + struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); - (void) GNUNET_TIME_round_abs (&now); /* Add timestamp if it doesn't exist (or is zero) */ - if (0 == timestamp.abs_value_us) + if (GNUNET_TIME_absolute_is_zero (timestamp.abs_time)) { GNUNET_assert (0 == json_object_set_new (order, "timestamp", - GNUNET_JSON_from_time_abs (now))); + GNUNET_JSON_from_timestamp (now))); } /* If no refund_deadline given, set one based on refund_delay. */ - if (GNUNET_TIME_absolute_is_never (refund_deadline)) + if (GNUNET_TIME_absolute_is_never (refund_deadline.abs_time)) { if (GNUNET_TIME_relative_is_zero (refund_delay)) { @@ -848,18 +850,19 @@ patch_order (struct MHD_Connection *connection, } else { - refund_deadline = GNUNET_TIME_relative_to_absolute (refund_delay); - (void) GNUNET_TIME_round_abs (&refund_deadline); + refund_deadline = GNUNET_TIME_relative_to_timestamp (refund_delay); } GNUNET_assert (0 == json_object_set_new (order, "refund_deadline", - GNUNET_JSON_from_time_abs ( + GNUNET_JSON_from_timestamp ( refund_deadline))); } - if ((0 != delivery_date.abs_value_us) && - (delivery_date.abs_value_us < now.abs_value_us) ) + if ( (! GNUNET_TIME_absolute_is_zero (delivery_date.abs_time)) && + (GNUNET_TIME_timestamp_cmp (delivery_date, + <, + now)) ) { GNUNET_break_op (0); return TALER_MHD_reply_with_error ( @@ -870,35 +873,35 @@ patch_order (struct MHD_Connection *connection, } } - if (0 == pay_deadline.abs_value_us) + if (GNUNET_TIME_absolute_is_zero (pay_deadline.abs_time)) { - struct GNUNET_TIME_Absolute t; + struct GNUNET_TIME_Timestamp t; - t = GNUNET_TIME_relative_to_absolute (settings->default_pay_delay); - (void) GNUNET_TIME_round_abs (&t); + t = GNUNET_TIME_relative_to_timestamp (settings->default_pay_delay); GNUNET_assert (0 == json_object_set_new (order, "pay_deadline", - GNUNET_JSON_from_time_abs (t))); + GNUNET_JSON_from_timestamp (t))); } - if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == wire_deadline.abs_value_us) + if (GNUNET_TIME_absolute_is_never (wire_deadline.abs_time)) { - struct GNUNET_TIME_Absolute t; + struct GNUNET_TIME_Timestamp t; - t = GNUNET_TIME_relative_to_absolute ( + t = GNUNET_TIME_relative_to_timestamp ( GNUNET_TIME_relative_max (settings->default_wire_transfer_delay, refund_delay)); - wire_deadline = GNUNET_TIME_absolute_max (refund_deadline, - t); - (void) GNUNET_TIME_round_abs (&wire_deadline); + wire_deadline = GNUNET_TIME_timestamp_max (refund_deadline, + t); GNUNET_assert (0 == json_object_set_new (order, "wire_transfer_deadline", - GNUNET_JSON_from_time_abs ( + GNUNET_JSON_from_timestamp ( wire_deadline))); } - if (wire_deadline.abs_value_us < refund_deadline.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (wire_deadline, + <, + refund_deadline)) { GNUNET_break_op (0); return TALER_MHD_reply_with_error ( @@ -1337,8 +1340,8 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_json ("order", &order), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_relative_time ("refund_delay", - &refund_delay)), + GNUNET_JSON_spec_relative_time ("refund_delay", + &refund_delay)), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("payment_target", &payment_target)), @@ -1367,8 +1370,8 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Refund delay is %s\n", - GNUNET_STRINGS_relative_time_to_string (refund_delay, - GNUNET_NO)); + GNUNET_TIME_relative2s (refund_delay, + false)); TMH_db->expire_locks (TMH_db->cls); if (create_token) diff --git a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c index 9983b520..184f1d28 100644 --- a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c +++ b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c @@ -43,8 +43,8 @@ TMH_private_post_products_ID_lock (const struct TMH_RequestHandler *rh, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("lock_uuid", &uuids), - TALER_JSON_spec_relative_time ("duration", - &duration), + GNUNET_JSON_spec_relative_time ("duration", + &duration), GNUNET_JSON_spec_uint32 ("quantity", &quantity), GNUNET_JSON_spec_end () @@ -71,7 +71,7 @@ TMH_private_post_products_ID_lock (const struct TMH_RequestHandler *rh, product_id, &uuid, quantity, - GNUNET_TIME_relative_to_absolute (duration)); + GNUNET_TIME_relative_to_timestamp (duration)); switch (qs) { case GNUNET_DB_STATUS_HARD_ERROR: diff --git a/src/backend/taler-merchant-httpd_private-post-products.c b/src/backend/taler-merchant-httpd_private-post-products.c index dfbec969..b8256a80 100644 --- a/src/backend/taler-merchant-httpd_private-post-products.c +++ b/src/backend/taler-merchant-httpd_private-post-products.c @@ -65,8 +65,9 @@ products_equal (const struct TALER_MERCHANTDB_ProductDetails *p1, p2->image)) && (1 == json_equal (p1->address, p2->address)) && - (p1->next_restock.abs_value_us == - p2->next_restock.abs_value_us) ); + (GNUNET_TIME_timestamp_cmp (p1->next_restock, + ==, + p2->next_restock) ) ); } @@ -105,8 +106,8 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_json ("address", &pd.address)), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_absolute_time ("next_restock", - &pd.next_restock)), + GNUNET_JSON_spec_timestamp ("next_restock", + &pd.next_restock)), GNUNET_JSON_spec_end () }; diff --git a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c index f9ceede3..1b69fa21 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c @@ -44,7 +44,7 @@ authorize_tip (const struct TMH_RequestHandler *rh, const struct TALER_ReservePublicKeyP *reserve_pub) { enum TALER_ErrorCode ec; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; struct GNUNET_HashCode tip_id; const char *justification; const char *next_url; @@ -127,7 +127,6 @@ authorize_tip (const struct TMH_RequestHandler *rh, tip_status_url = TMH_make_tip_status_url (connection, &tip_id, hc->instance->settings.id); - GNUNET_TIME_round_abs (&expiration); res = TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, @@ -137,8 +136,8 @@ authorize_tip (const struct TMH_RequestHandler *rh, taler_tip_uri), GNUNET_JSON_pack_string ("tip_status_url", tip_status_url), - GNUNET_JSON_pack_time_abs ("tip_expiration", - expiration)); + GNUNET_JSON_pack_timestamp ("tip_expiration", + expiration)); GNUNET_free (taler_tip_uri); GNUNET_free (tip_status_url); return res; diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c b/src/backend/taler-merchant-httpd_private-post-reserves.c index be92b7e4..37b887ef 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves.c @@ -96,7 +96,7 @@ struct PostReserveContext /** * When will the reserve expire. */ - struct GNUNET_TIME_Absolute reserve_expiration; + struct GNUNET_TIME_Timestamp reserve_expiration; /** * Which HTTP status should we return? @@ -251,7 +251,7 @@ handle_exchange (void *cls, return; } rc->reserve_expiration - = GNUNET_TIME_relative_to_absolute (keys->reserve_closing_delay); + = GNUNET_TIME_relative_to_timestamp (keys->reserve_closing_delay); rc->payto_uri = GNUNET_strdup (payto_uri); TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */ } diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c index 871aa57a..f06f25c0 100644 --- a/src/backend/taler-merchant-httpd_private-post-transfers.c +++ b/src/backend/taler-merchant-httpd_private-post-transfers.c @@ -299,8 +299,8 @@ check_transfer (void *cls, const struct TALER_Amount *refund_fee, const struct TALER_Amount *wire_fee, const struct TALER_MerchantWireHash *h_wire, - struct GNUNET_TIME_Absolute deposit_timestamp, - struct GNUNET_TIME_Absolute refund_deadline, + struct GNUNET_TIME_Timestamp deposit_timestamp, + struct GNUNET_TIME_Timestamp refund_deadline, const struct TALER_ExchangeSignatureP *exchange_sig, const struct TALER_ExchangePublicKeyP *exchange_pub) { @@ -326,10 +326,10 @@ check_transfer (void *cls, TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_REPORTS), GNUNET_JSON_pack_string ("exchange_url", exchange_url), - GNUNET_JSON_pack_time_abs ("deposit_timestamp", - deposit_timestamp), - GNUNET_JSON_pack_time_abs ("refund_deadline", - refund_deadline), + GNUNET_JSON_pack_timestamp ("deposit_timestamp", + deposit_timestamp), + GNUNET_JSON_pack_timestamp ("refund_deadline", + refund_deadline), GNUNET_JSON_pack_uint64 ("conflict_offset", ptc->current_offset), GNUNET_JSON_pack_data_auto ("coin_pub", @@ -372,14 +372,14 @@ check_transfer (void *cls, */ static enum GNUNET_GenericReturnValue check_wire_fee (struct PostTransfersContext *ptc, - struct GNUNET_TIME_Absolute execution_time, + struct GNUNET_TIME_Timestamp execution_time, const struct TALER_Amount *wire_fee) { struct TALER_Amount expected_fee; struct TALER_Amount closing_fee; struct TALER_MasterSignatureP master_sig; - struct GNUNET_TIME_Absolute start_date; - struct GNUNET_TIME_Absolute end_date; + struct GNUNET_TIME_Timestamp start_date; + struct GNUNET_TIME_Timestamp end_date; enum GNUNET_DB_QueryStatus qs; char *wire_method; @@ -409,7 +409,7 @@ check_wire_fee (struct PostTransfersContext *ptc, "Failed to find wire fee for `%s' and method `%s' at %s in DB, accepting blindly that the fee is %s\n", TALER_B2S (&ptc->master_pub), wire_method, - GNUNET_STRINGS_absolute_time_to_string (execution_time), + GNUNET_TIME_timestamp2s (execution_time), TALER_amount2s (wire_fee)); GNUNET_free (wire_method); return GNUNET_NO; @@ -430,16 +430,16 @@ check_wire_fee (struct PostTransfersContext *ptc, TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_BAD_WIRE_FEE), TALER_JSON_pack_amount ("wire_fee", wire_fee), - GNUNET_JSON_pack_time_abs ("execution_time", - execution_time), + GNUNET_JSON_pack_timestamp ("execution_time", + execution_time), TALER_JSON_pack_amount ("expected_wire_fee", &expected_fee), TALER_JSON_pack_amount ("expected_closing_fee", &closing_fee), - GNUNET_JSON_pack_time_abs ("start_date", - start_date), - GNUNET_JSON_pack_time_abs ("end_date", - end_date), + GNUNET_JSON_pack_timestamp ("start_date", + start_date), + GNUNET_JSON_pack_timestamp ("end_date", + end_date), GNUNET_JSON_pack_data_auto ("master_sig", &master_sig), GNUNET_JSON_pack_data_auto ("master_pub", @@ -969,7 +969,7 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, /* Check if transfer data is in database, if not, add it. */ for (unsigned int retry = 0; retry<MAX_RETRIES; retry++) { - struct GNUNET_TIME_Absolute execution_time; + struct GNUNET_TIME_Timestamp execution_time; struct TALER_Amount total_amount; struct TALER_Amount exchange_amount; struct TALER_Amount wire_fee; @@ -1332,8 +1332,8 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, &total_amount), TALER_JSON_pack_amount ("wire_fee", &wire_fee), - GNUNET_JSON_pack_time_abs ("execution_time", - execution_time), + GNUNET_JSON_pack_timestamp ("execution_time", + execution_time), GNUNET_JSON_pack_array_steal ("deposit_sums", deposit_sums)); } /* end of 'verified == true' (not an 'if'!) */ |