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/backenddb | |
parent | 49e2e44b09dd845d0922c0acef5ff487b52bf26d (diff) | |
download | merchant-ad5d54f48534ac0ad5bfd7f048bd7782e674a89b.tar.gz merchant-ad5d54f48534ac0ad5bfd7f048bd7782e674a89b.tar.bz2 merchant-ad5d54f48534ac0ad5bfd7f048bd7782e674a89b.zip |
migration to protocol v11
Diffstat (limited to 'src/backenddb')
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 274 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 276 |
2 files changed, 285 insertions, 265 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 7bdbaf63..1b55ecd6 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -878,7 +878,7 @@ kyc_status_cb (void *cls, uint64_t kyc_serial; char *exchange_url; char *payto_uri; - struct GNUNET_TIME_Absolute last_check; + struct GNUNET_TIME_Timestamp last_check; uint8_t kyc_ok; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("h_wire", @@ -889,8 +889,8 @@ kyc_status_cb (void *cls, &payto_uri), GNUNET_PQ_result_spec_string ("exchange_url", &exchange_url), - GNUNET_PQ_result_spec_absolute_time ("kyc_timestamp", - &last_check), + GNUNET_PQ_result_spec_timestamp ("kyc_timestamp", + &last_check), GNUNET_PQ_result_spec_auto_from_type ("kyc_ok", &kyc_ok), GNUNET_PQ_result_spec_end @@ -1006,7 +1006,7 @@ postgres_account_kyc_set_status ( uint64_t exchange_kyc_serial, const struct TALER_ExchangeSignatureP *exchange_sig, const struct TALER_ExchangePublicKeyP *exchange_pub, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Timestamp timestamp, bool kyc_ok) { struct PostgresClosure *pg = cls; @@ -1016,7 +1016,7 @@ postgres_account_kyc_set_status ( GNUNET_PQ_query_param_auto_from_type (h_wire), GNUNET_PQ_query_param_string (exchange_url), GNUNET_PQ_query_param_uint64 (&exchange_kyc_serial), - GNUNET_PQ_query_param_absolute_time (×tamp), + GNUNET_PQ_query_param_timestamp (×tamp), GNUNET_PQ_query_param_auto_from_type (&ok), exchange_pub ? GNUNET_PQ_query_param_auto_from_type (exchange_pub) @@ -1028,8 +1028,6 @@ postgres_account_kyc_set_status ( }; check_connection (pg); - GNUNET_assert (GNUNET_OK == - GNUNET_TIME_round_abs (×tamp)); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "upsert_account_kyc", params); @@ -1364,8 +1362,8 @@ postgres_lookup_product (void *cls, &pd->image), TALER_PQ_result_spec_json ("address", &pd->address), - GNUNET_PQ_result_spec_absolute_time ("next_restock", - &pd->next_restock), + GNUNET_PQ_result_spec_timestamp ("next_restock", + &pd->next_restock), GNUNET_PQ_result_spec_end }; @@ -1434,7 +1432,7 @@ postgres_insert_product (void *cls, TALER_PQ_query_param_amount (&pd->price), GNUNET_PQ_query_param_uint64 (&pd->total_stock), TALER_PQ_query_param_json (pd->address), - GNUNET_PQ_query_param_absolute_time (&pd->next_restock), + GNUNET_PQ_query_param_timestamp (&pd->next_restock), GNUNET_PQ_query_param_end }; @@ -1483,7 +1481,7 @@ postgres_update_product (void *cls, GNUNET_PQ_query_param_uint64 (&pd->total_stock), /* $10 */ GNUNET_PQ_query_param_uint64 (&pd->total_lost), TALER_PQ_query_param_json (pd->address), - GNUNET_PQ_query_param_absolute_time (&pd->next_restock), + GNUNET_PQ_query_param_timestamp (&pd->next_restock), GNUNET_PQ_query_param_end }; @@ -1520,7 +1518,7 @@ postgres_lock_product (void *cls, const char *product_id, const struct GNUNET_Uuid *uuid, uint64_t quantity, - struct GNUNET_TIME_Absolute expiration_time) + struct GNUNET_TIME_Timestamp expiration_time) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -1528,7 +1526,7 @@ postgres_lock_product (void *cls, GNUNET_PQ_query_param_string (product_id), GNUNET_PQ_query_param_auto_from_type (uuid), GNUNET_PQ_query_param_uint64 (&quantity), - GNUNET_PQ_query_param_absolute_time (&expiration_time), + GNUNET_PQ_query_param_timestamp (&expiration_time), GNUNET_PQ_query_param_end }; @@ -1708,7 +1706,7 @@ static enum GNUNET_DB_QueryStatus postgres_lookup_order_summary (void *cls, const char *instance_id, const char *order_id, - struct GNUNET_TIME_Absolute *timestamp, + struct GNUNET_TIME_Timestamp *timestamp, uint64_t *order_serial) { struct PostgresClosure *pg = cls; @@ -1720,8 +1718,8 @@ postgres_lookup_order_summary (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("order_serial", order_serial), - GNUNET_PQ_result_spec_absolute_time ("creation_time", - timestamp), + GNUNET_PQ_result_spec_timestamp ("creation_time", + timestamp), GNUNET_PQ_result_spec_end }; @@ -1774,14 +1772,14 @@ lookup_orders_cb (void *cls, { char *order_id; uint64_t order_serial; - struct GNUNET_TIME_Absolute ts; + struct GNUNET_TIME_Timestamp ts; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_string ("order_id", &order_id), GNUNET_PQ_result_spec_uint64 ("order_serial", &order_serial), - GNUNET_PQ_result_spec_absolute_time ("creation_time", - &ts), + GNUNET_PQ_result_spec_timestamp ("creation_time", + &ts), GNUNET_PQ_result_spec_end }; @@ -1833,7 +1831,7 @@ postgres_lookup_orders (void *cls, GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_uint64 (&limit), GNUNET_PQ_query_param_uint64 (&of->start_row), - GNUNET_PQ_query_param_absolute_time (&of->date), + GNUNET_PQ_query_param_timestamp (&of->date), GNUNET_PQ_query_param_auto_from_type (&paid), GNUNET_PQ_query_param_auto_from_type (&refunded), GNUNET_PQ_query_param_auto_from_type (&wired), @@ -1884,25 +1882,24 @@ postgres_insert_order (void *cls, const char *instance_id, const char *order_id, const struct GNUNET_HashCode *h_post_data, - struct GNUNET_TIME_Absolute pay_deadline, + struct GNUNET_TIME_Timestamp pay_deadline, const struct TALER_ClaimTokenP *claim_token, const json_t *contract_terms) { struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp now; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_string (order_id), - GNUNET_PQ_query_param_absolute_time (&pay_deadline), + GNUNET_PQ_query_param_timestamp (&pay_deadline), GNUNET_PQ_query_param_auto_from_type (claim_token), GNUNET_PQ_query_param_auto_from_type (h_post_data), - GNUNET_PQ_query_param_absolute_time (&now), + GNUNET_PQ_query_param_timestamp (&now), TALER_PQ_query_param_json (contract_terms), GNUNET_PQ_query_param_end }; - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); + now = GNUNET_TIME_timestamp_get (); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "inserting order: order_id: %s, instance_id: %s.\n", order_id, @@ -2049,8 +2046,8 @@ postgres_insert_contract_terms (void *cls, json_t *contract_terms) { struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute pay_deadline; - struct GNUNET_TIME_Absolute refund_deadline; + struct GNUNET_TIME_Timestamp pay_deadline; + struct GNUNET_TIME_Timestamp refund_deadline; const char *fulfillment_url; struct TALER_PrivateContractHash h_contract_terms; @@ -2064,10 +2061,10 @@ postgres_insert_contract_terms (void *cls, { struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_absolute_time ("pay_deadline", - &pay_deadline), - TALER_JSON_spec_absolute_time ("refund_deadline", - &refund_deadline), + GNUNET_JSON_spec_timestamp ("pay_deadline", + &pay_deadline), + GNUNET_JSON_spec_timestamp ("refund_deadline", + &refund_deadline), GNUNET_JSON_spec_end () }; enum GNUNET_GenericReturnValue res; @@ -2092,8 +2089,8 @@ postgres_insert_contract_terms (void *cls, GNUNET_PQ_query_param_string (order_id), TALER_PQ_query_param_json (contract_terms), GNUNET_PQ_query_param_auto_from_type (&h_contract_terms), - GNUNET_PQ_query_param_absolute_time (&pay_deadline), - GNUNET_PQ_query_param_absolute_time (&refund_deadline), + GNUNET_PQ_query_param_timestamp (&pay_deadline), + GNUNET_PQ_query_param_timestamp (&refund_deadline), (NULL == fulfillment_url) ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_string (fulfillment_url), @@ -2129,8 +2126,8 @@ postgres_update_contract_terms (void *cls, json_t *contract_terms) { struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute pay_deadline; - struct GNUNET_TIME_Absolute refund_deadline; + struct GNUNET_TIME_Timestamp pay_deadline; + struct GNUNET_TIME_Timestamp refund_deadline; const char *fulfillment_url = NULL; struct TALER_PrivateContractHash h_contract_terms; @@ -2144,10 +2141,10 @@ postgres_update_contract_terms (void *cls, { struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_absolute_time ("pay_deadline", - &pay_deadline), - TALER_JSON_spec_absolute_time ("refund_deadline", - &refund_deadline), + GNUNET_JSON_spec_timestamp ("pay_deadline", + &pay_deadline), + GNUNET_JSON_spec_timestamp ("refund_deadline", + &refund_deadline), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("fulfillment_url", &fulfillment_url)), @@ -2172,8 +2169,8 @@ postgres_update_contract_terms (void *cls, GNUNET_PQ_query_param_string (order_id), TALER_PQ_query_param_json (contract_terms), GNUNET_PQ_query_param_auto_from_type (&h_contract_terms), - GNUNET_PQ_query_param_absolute_time (&pay_deadline), - GNUNET_PQ_query_param_absolute_time (&refund_deadline), + GNUNET_PQ_query_param_timestamp (&pay_deadline), + GNUNET_PQ_query_param_timestamp (&refund_deadline), (NULL == fulfillment_url) ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_string (fulfillment_url), @@ -2376,18 +2373,18 @@ postgres_insert_exchange_signkey ( void *cls, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_ExchangePublicKeyP *exchange_pub, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute expire_date, - struct GNUNET_TIME_Absolute end_date, + struct GNUNET_TIME_Timestamp start_date, + struct GNUNET_TIME_Timestamp expire_date, + struct GNUNET_TIME_Timestamp end_date, const struct TALER_MasterSignatureP *master_sig) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_auto_from_type (exchange_pub), - GNUNET_PQ_query_param_absolute_time (&start_date), - GNUNET_PQ_query_param_absolute_time (&expire_date), - GNUNET_PQ_query_param_absolute_time (&end_date), + GNUNET_PQ_query_param_timestamp (&start_date), + GNUNET_PQ_query_param_timestamp (&expire_date), + GNUNET_PQ_query_param_timestamp (&end_date), GNUNET_PQ_query_param_auto_from_type (master_sig), GNUNET_PQ_query_param_end }; @@ -2423,7 +2420,7 @@ static enum GNUNET_DB_QueryStatus postgres_insert_deposit ( void *cls, const char *instance_id, - struct GNUNET_TIME_Absolute deposit_timestamp, + struct GNUNET_TIME_Timestamp deposit_timestamp, const struct TALER_PrivateContractHash *h_contract_terms, const struct TALER_CoinSpendPublicKeyP *coin_pub, const char *exchange_url, @@ -2439,7 +2436,7 @@ postgres_insert_deposit ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_auto_from_type (h_contract_terms), - GNUNET_PQ_query_param_absolute_time (&deposit_timestamp), /* $3 */ + GNUNET_PQ_query_param_timestamp (&deposit_timestamp), /* $3 */ GNUNET_PQ_query_param_auto_from_type (coin_pub), GNUNET_PQ_query_param_string (exchange_url), TALER_PQ_query_param_amount (amount_with_fee), /* $6/$7 */ @@ -2664,7 +2661,7 @@ static enum GNUNET_DB_QueryStatus postgres_refund_coin (void *cls, const char *instance_id, const struct TALER_PrivateContractHash *h_contract_terms, - struct GNUNET_TIME_Absolute refund_timestamp, + struct GNUNET_TIME_Timestamp refund_timestamp, const struct TALER_CoinSpendPublicKeyP *coin_pub, const char *reason) { @@ -2672,7 +2669,7 @@ postgres_refund_coin (void *cls, struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_auto_from_type (h_contract_terms), - GNUNET_PQ_query_param_absolute_time (&refund_timestamp), + GNUNET_PQ_query_param_timestamp (&refund_timestamp), GNUNET_PQ_query_param_auto_from_type (coin_pub), GNUNET_PQ_query_param_string (reason), GNUNET_PQ_query_param_end @@ -3026,15 +3023,15 @@ lookup_transfer_details_by_order_cb (void *cls, struct TALER_WireTransferIdentifierRawP wtid; char *exchange_url; uint64_t deposit_serial; - struct GNUNET_TIME_Absolute execution_time; + struct GNUNET_TIME_Timestamp execution_time; struct TALER_Amount deposit_value; struct TALER_Amount deposit_fee; uint8_t transfer_confirmed; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("deposit_serial", &deposit_serial), - GNUNET_PQ_result_spec_absolute_time ("deposit_timestamp", - &execution_time), + GNUNET_PQ_result_spec_timestamp ("deposit_timestamp", + &execution_time), GNUNET_PQ_result_spec_string ("exchange_url", &exchange_url), GNUNET_PQ_result_spec_auto_from_type ("wtid", @@ -3129,7 +3126,7 @@ postgres_insert_deposit_to_transfer ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&deposit_serial), TALER_PQ_query_param_amount (&dd->coin_contribution), - GNUNET_PQ_query_param_absolute_time (&dd->execution_time), + GNUNET_PQ_query_param_timestamp (&dd->execution_time), GNUNET_PQ_query_param_auto_from_type (&dd->exchange_sig), GNUNET_PQ_query_param_auto_from_type (&dd->exchange_pub), GNUNET_PQ_query_param_auto_from_type (&dd->wtid), @@ -3327,10 +3324,9 @@ process_deposits_for_refund_cb (void *cls, struct PostgresClosure *pg = ctx->pg; struct TALER_Amount current_refund; struct RefundCoinData rcd[GNUNET_NZL (num_results)]; - 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 (); GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (ctx->refund->currency, ¤t_refund)); @@ -3500,7 +3496,7 @@ process_deposits_for_refund_cb (void *cls, struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&rcd[i].order_serial), GNUNET_PQ_query_param_uint64 (&rcd[i].max_rtransaction_id), /* already inc'ed */ - GNUNET_PQ_query_param_absolute_time (&now), + GNUNET_PQ_query_param_timestamp (&now), GNUNET_PQ_query_param_auto_from_type (&rcd[i].coin_pub), GNUNET_PQ_query_param_string (ctx->reason), TALER_PQ_query_param_amount (increment), @@ -3658,7 +3654,7 @@ lookup_refunds_detailed_cb (void *cls, for (unsigned int i = 0; i<num_results; i++) { uint64_t refund_serial; - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp timestamp; struct TALER_CoinSpendPublicKeyP coin_pub; uint64_t rtransaction_id; struct TALER_Amount refund_amount; @@ -3668,8 +3664,8 @@ lookup_refunds_detailed_cb (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("refund_serial", &refund_serial), - GNUNET_PQ_result_spec_absolute_time ("refund_timestamp", - ×tamp), + GNUNET_PQ_result_spec_timestamp ("refund_timestamp", + ×tamp), GNUNET_PQ_result_spec_auto_from_type ("coin_pub", &coin_pub), GNUNET_PQ_result_spec_string ("exchange_url", @@ -4088,7 +4084,7 @@ RETRY: GNUNET_PQ_query_param_uint64 (&credit_serial), TALER_PQ_query_param_amount (&td->total_amount), TALER_PQ_query_param_amount (&td->wire_fee), - GNUNET_PQ_query_param_absolute_time (&td->execution_time), + GNUNET_PQ_query_param_timestamp (&td->execution_time), GNUNET_PQ_query_param_auto_from_type (&td->exchange_sig), GNUNET_PQ_query_param_auto_from_type (&td->exchange_pub), GNUNET_PQ_query_param_end @@ -4221,11 +4217,11 @@ static enum GNUNET_DB_QueryStatus postgres_lookup_wire_fee (void *cls, const struct TALER_MasterPublicKeyP *master_pub, const char *wire_method, - struct GNUNET_TIME_Absolute contract_date, + struct GNUNET_TIME_Timestamp contract_date, struct TALER_Amount *wire_fee, struct TALER_Amount *closing_fee, - struct GNUNET_TIME_Absolute *start_date, - struct GNUNET_TIME_Absolute *end_date, + struct GNUNET_TIME_Timestamp *start_date, + struct GNUNET_TIME_Timestamp *end_date, struct TALER_MasterSignatureP *master_sig) { struct PostgresClosure *pg = cls; @@ -4233,7 +4229,7 @@ postgres_lookup_wire_fee (void *cls, struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_auto_from_type (&h_wire_method), - GNUNET_PQ_query_param_absolute_time (&contract_date), + GNUNET_PQ_query_param_timestamp (&contract_date), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -4241,10 +4237,10 @@ postgres_lookup_wire_fee (void *cls, wire_fee), TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee", closing_fee), - GNUNET_PQ_result_spec_absolute_time ("start_date", - start_date), - GNUNET_PQ_result_spec_absolute_time ("end_date", - end_date), + GNUNET_PQ_result_spec_timestamp ("start_date", + start_date), + GNUNET_PQ_result_spec_timestamp ("end_date", + end_date), GNUNET_PQ_result_spec_auto_from_type ("master_sig", master_sig), GNUNET_PQ_result_spec_end @@ -4312,8 +4308,8 @@ lookup_deposits_by_contract_and_coin_cb (void *cls, struct TALER_Amount refund_fee; struct TALER_Amount wire_fee; 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; struct TALER_ExchangeSignatureP exchange_sig; struct TALER_ExchangePublicKeyP exchange_pub; struct GNUNET_PQ_ResultSpec rs[] = { @@ -4329,10 +4325,10 @@ lookup_deposits_by_contract_and_coin_cb (void *cls, &wire_fee), GNUNET_PQ_result_spec_auto_from_type ("h_wire", &h_wire), - GNUNET_PQ_result_spec_absolute_time ("deposit_timestamp", - &deposit_timestamp), - GNUNET_PQ_result_spec_absolute_time ("refund_deadline", - &refund_deadline), + GNUNET_PQ_result_spec_timestamp ("deposit_timestamp", + &deposit_timestamp), + GNUNET_PQ_result_spec_timestamp ("refund_deadline", + &refund_deadline), GNUNET_PQ_result_spec_auto_from_type ("exchange_sig", &exchange_sig), GNUNET_PQ_result_spec_auto_from_type ("exchange_pub", @@ -4440,7 +4436,7 @@ postgres_lookup_transfer ( struct TALER_Amount *total_amount, struct TALER_Amount *wire_fee, struct TALER_Amount *exchange_amount, - struct GNUNET_TIME_Absolute *execution_time, + struct GNUNET_TIME_Timestamp *execution_time, bool *have_exchange_sig, bool *verified) { @@ -4467,8 +4463,8 @@ postgres_lookup_transfer ( exchange_amount), NULL), GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_absolute_time ("execution_time", - execution_time), + GNUNET_PQ_result_spec_timestamp ("execution_time", + execution_time), NULL), GNUNET_PQ_result_spec_auto_from_type ("verified", &verified8), @@ -4477,7 +4473,7 @@ postgres_lookup_transfer ( enum GNUNET_DB_QueryStatus qs; check_connection (pg); - *execution_time = GNUNET_TIME_UNIT_ZERO_ABS; + *execution_time = GNUNET_TIME_UNIT_ZERO_TS; qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "lookup_transfer", params, @@ -4836,7 +4832,7 @@ lookup_transfers_cb (void *cls, char *payto_uri; char *exchange_url; uint64_t transfer_serial_id; - struct GNUNET_TIME_Absolute execution_time; + struct GNUNET_TIME_Timestamp execution_time; enum TALER_EXCHANGE_YesNoAll verified; uint8_t verified8; uint8_t confirmed8; @@ -4851,8 +4847,8 @@ lookup_transfers_cb (void *cls, &exchange_url), GNUNET_PQ_result_spec_uint64 ("credit_serial", &transfer_serial_id), - GNUNET_PQ_result_spec_absolute_time ("execution_time", - &execution_time), + GNUNET_PQ_result_spec_timestamp ("execution_time", + &execution_time), GNUNET_PQ_result_spec_auto_from_type ("verified", &verified8), GNUNET_PQ_result_spec_auto_from_type ("confirmed", @@ -4916,8 +4912,8 @@ static enum GNUNET_DB_QueryStatus postgres_lookup_transfers (void *cls, const char *instance_id, const char *payto_uri, - struct GNUNET_TIME_Absolute before, - struct GNUNET_TIME_Absolute after, + struct GNUNET_TIME_Timestamp before, + struct GNUNET_TIME_Timestamp after, int64_t limit, uint64_t offset, enum TALER_EXCHANGE_YesNoAll verified, @@ -4935,10 +4931,8 @@ postgres_lookup_transfers (void *cls, enum GNUNET_DB_QueryStatus qs; bool by_time; - by_time = ( (before.abs_value_us != - GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) || - (after.abs_value_us != - GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us) ); + by_time = ( (! GNUNET_TIME_absolute_is_never (before.abs_time)) || + (! GNUNET_TIME_absolute_is_zero (after.abs_time)) ); check_connection (pg); if (by_time) { @@ -4946,8 +4940,8 @@ postgres_lookup_transfers (void *cls, { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), - GNUNET_PQ_query_param_absolute_time (&before), - GNUNET_PQ_query_param_absolute_time (&after), + GNUNET_PQ_query_param_timestamp (&before), + GNUNET_PQ_query_param_timestamp (&after), GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_uint64 (&plimit), GNUNET_PQ_query_param_string (payto_uri), @@ -4967,8 +4961,8 @@ postgres_lookup_transfers (void *cls, { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), - GNUNET_PQ_query_param_absolute_time (&before), - GNUNET_PQ_query_param_absolute_time (&after), + GNUNET_PQ_query_param_timestamp (&before), + GNUNET_PQ_query_param_timestamp (&after), GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_uint64 (&plimit), GNUNET_PQ_query_param_end @@ -5052,8 +5046,8 @@ postgres_store_wire_fee_by_exchange ( const struct GNUNET_HashCode *h_wire_method, const struct TALER_Amount *wire_fee, const struct TALER_Amount *closing_fee, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute end_date, + struct GNUNET_TIME_Timestamp start_date, + struct GNUNET_TIME_Timestamp end_date, const struct TALER_MasterSignatureP *master_sig) { struct PostgresClosure *pg = cls; @@ -5062,8 +5056,8 @@ postgres_store_wire_fee_by_exchange ( GNUNET_PQ_query_param_auto_from_type (h_wire_method), TALER_PQ_query_param_amount (wire_fee), TALER_PQ_query_param_amount (closing_fee), - GNUNET_PQ_query_param_absolute_time (&start_date), - GNUNET_PQ_query_param_absolute_time (&end_date), + GNUNET_PQ_query_param_timestamp (&start_date), + GNUNET_PQ_query_param_timestamp (&end_date), GNUNET_PQ_query_param_auto_from_type (master_sig), GNUNET_PQ_query_param_end }; @@ -5073,7 +5067,7 @@ postgres_store_wire_fee_by_exchange ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Storing wire fee for %s starting at %s of %s\n", TALER_B2S (master_pub), - GNUNET_STRINGS_absolute_time_to_string (start_date), + GNUNET_TIME_timestamp2s (start_date), TALER_amount2s (wire_fee)); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "insert_wire_fee", @@ -5107,7 +5101,7 @@ postgres_insert_reserve (void *cls, const char *exchange_url, const char *payto_uri, const struct TALER_Amount *initial_balance, - struct GNUNET_TIME_Absolute expiration) + struct GNUNET_TIME_Timestamp expiration) { struct PostgresClosure *pg = cls; unsigned int retries; @@ -5128,18 +5122,17 @@ RETRY: /* Setup reserve */ { - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp now; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_auto_from_type (reserve_pub), - GNUNET_PQ_query_param_absolute_time (&now), - GNUNET_PQ_query_param_absolute_time (&expiration), + GNUNET_PQ_query_param_timestamp (&now), + GNUNET_PQ_query_param_timestamp (&expiration), TALER_PQ_query_param_amount (initial_balance), GNUNET_PQ_query_param_end }; - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); + now = GNUNET_TIME_timestamp_get (); qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, "insert_reserve", params); @@ -5273,8 +5266,8 @@ lookup_reserves_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { 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; struct TALER_Amount merchant_initial_balance; struct TALER_Amount exchange_initial_balance; struct TALER_Amount pickup_amount; @@ -5283,10 +5276,10 @@ lookup_reserves_cb (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &reserve_pub), - GNUNET_PQ_result_spec_absolute_time ("creation_time", - &creation_time), - GNUNET_PQ_result_spec_absolute_time ("expiration", - &expiration_time), + GNUNET_PQ_result_spec_timestamp ("creation_time", + &creation_time), + GNUNET_PQ_result_spec_timestamp ("expiration", + &expiration_time), TALER_PQ_RESULT_SPEC_AMOUNT ("merchant_initial_balance", &merchant_initial_balance), TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_initial_balance", @@ -5367,7 +5360,7 @@ lookup_reserves_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_lookup_reserves (void *cls, const char *instance_id, - struct GNUNET_TIME_Absolute created_after, + struct GNUNET_TIME_Timestamp created_after, enum TALER_EXCHANGE_YesNoAll active, enum TALER_EXCHANGE_YesNoAll failures, TALER_MERCHANTDB_ReservesCallback cb, @@ -5383,7 +5376,7 @@ postgres_lookup_reserves (void *cls, }; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), - GNUNET_PQ_query_param_absolute_time (&created_after), + GNUNET_PQ_query_param_timestamp (&created_after), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; @@ -5618,8 +5611,8 @@ postgres_lookup_reserve (void *cls, GNUNET_PQ_query_param_auto_from_type (reserve_pub), GNUNET_PQ_query_param_end }; - struct GNUNET_TIME_Absolute creation_time; - struct GNUNET_TIME_Absolute expiration_time; + struct GNUNET_TIME_Timestamp creation_time; + struct GNUNET_TIME_Timestamp expiration_time; struct TALER_Amount merchant_initial_balance; struct TALER_Amount exchange_initial_balance; struct TALER_Amount pickup_amount; @@ -5628,10 +5621,10 @@ postgres_lookup_reserve (void *cls, char *exchange_url = NULL; char *payto_uri = NULL; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_absolute_time ("creation_time", - &creation_time), - GNUNET_PQ_result_spec_absolute_time ("expiration", - &expiration_time), + GNUNET_PQ_result_spec_timestamp ("creation_time", + &creation_time), + GNUNET_PQ_result_spec_timestamp ("expiration", + &expiration_time), TALER_PQ_RESULT_SPEC_AMOUNT ("merchant_initial_balance", &merchant_initial_balance), TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_initial_balance", @@ -5791,7 +5784,7 @@ struct LookupReserveForTipContext * Set to the expiration time of the reserve we found. * #GNUNET_TIME_UNIT_FOREVER_ABS if we found none. */ - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; /** * Error status. @@ -5834,7 +5827,7 @@ lookup_reserve_for_tip_cb (void *cls, struct TALER_Amount committed_amount; struct TALER_Amount remaining; struct TALER_Amount initial_balance; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &reserve_pub), @@ -5842,8 +5835,8 @@ lookup_reserve_for_tip_cb (void *cls, &initial_balance), TALER_PQ_RESULT_SPEC_AMOUNT ("tips_committed", &committed_amount), - GNUNET_PQ_result_spec_absolute_time ("expiration", - &expiration), + GNUNET_PQ_result_spec_timestamp ("expiration", + &expiration), GNUNET_PQ_result_spec_end }; @@ -5874,11 +5867,12 @@ lookup_reserve_for_tip_cb (void *cls, lac->ec = TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS; continue; } - if ( (lac->expiration.abs_value_us != - GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) && - ( (expiration.abs_value_us > lac->expiration.abs_value_us) && - (GNUNET_TIME_absolute_get_remaining (lac->expiration).rel_value_us > - MIN_EXPIRATION.rel_value_us) ) ) + if ( (! GNUNET_TIME_absolute_is_never (lac->expiration.abs_time)) && + GNUNET_TIME_timestamp_cmp (expiration, >, lac->expiration) && + GNUNET_TIME_relative_cmp ( + GNUNET_TIME_absolute_get_remaining (lac->expiration.abs_time), + >, + MIN_EXPIRATION) ) { /* reserve expired */ if (lac->ok) @@ -5926,7 +5920,7 @@ postgres_authorize_tip (void *cls, const char *justification, const char *next_url, struct GNUNET_HashCode *tip_id, - struct GNUNET_TIME_Absolute *expiration) + struct GNUNET_TIME_Timestamp *expiration) { struct PostgresClosure *pg = cls; unsigned int retries = 0; @@ -5937,7 +5931,7 @@ postgres_authorize_tip (void *cls, struct LookupReserveForTipContext lac = { .pg = pg, .required_amount = *amount, - .expiration = GNUNET_TIME_UNIT_FOREVER_ABS + .expiration = GNUNET_TIME_UNIT_FOREVER_TS }; check_connection (pg); @@ -5997,8 +5991,8 @@ RETRY: GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_absolute_time ("expiration", - expiration), + GNUNET_PQ_result_spec_timestamp ("expiration", + expiration), TALER_PQ_RESULT_SPEC_AMOUNT ("tips_committed", &tips_committed), TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_initial_balance", @@ -6086,7 +6080,7 @@ RETRY: GNUNET_PQ_query_param_auto_from_type (tip_id), GNUNET_PQ_query_param_string (justification), GNUNET_PQ_query_param_string (next_url), - GNUNET_PQ_query_param_absolute_time (expiration), + GNUNET_PQ_query_param_timestamp (expiration), TALER_PQ_query_param_amount (amount), GNUNET_PQ_query_param_end }; @@ -6275,7 +6269,7 @@ postgres_lookup_tip (void *cls, const struct GNUNET_HashCode *tip_id, 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) { @@ -6290,8 +6284,8 @@ postgres_lookup_tip (void *cls, total_authorized), TALER_PQ_RESULT_SPEC_AMOUNT ("picked_up", total_picked_up), - GNUNET_PQ_result_spec_absolute_time ("expiration", - expiration), + GNUNET_PQ_result_spec_timestamp ("expiration", + expiration), GNUNET_PQ_result_spec_string ("exchange_url", exchange_url), GNUNET_PQ_result_spec_auto_from_type ("reserve_priv", @@ -6544,7 +6538,7 @@ postgres_lookup_tip_details (void *cls, struct TALER_Amount *total_authorized, struct TALER_Amount *total_picked_up, char **justification, - struct GNUNET_TIME_Absolute *expiration, + struct GNUNET_TIME_Timestamp *expiration, struct TALER_ReservePublicKeyP *reserve_pub, unsigned int *pickups_length, struct TALER_MERCHANTDB_PickupDetails **pickups) @@ -6567,8 +6561,8 @@ postgres_lookup_tip_details (void *cls, total_picked_up), GNUNET_PQ_result_spec_string ("justification", justification), - GNUNET_PQ_result_spec_absolute_time ("expiration", - expiration), + GNUNET_PQ_result_spec_timestamp ("expiration", + expiration), GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", reserve_pub), GNUNET_PQ_result_spec_end diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 1fbe0e65..d6d490b6 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -761,7 +761,7 @@ make_product (const char *id, GNUNET_assert (NULL != product->product.image); product->product.address = json_array (); GNUNET_assert (NULL != product->product.address); - product->product.next_restock = GNUNET_TIME_absolute_get_zero_ (); + product->product.next_restock = GNUNET_TIME_UNIT_ZERO_TS; } @@ -797,8 +797,9 @@ check_products_equal (const struct TALER_MERCHANTDB_ProductDetails *a, b->description_i18n)) || (0 != strcmp (a->unit, b->unit)) || - (GNUNET_OK != TALER_amount_cmp_currency (&a->price, - &b->price)) || + (GNUNET_OK != + TALER_amount_cmp_currency (&a->price, + &b->price)) || (0 != TALER_amount_cmp (&a->price, &b->price)) || (1 != json_equal (a->taxes, @@ -810,7 +811,9 @@ check_products_equal (const struct TALER_MERCHANTDB_ProductDetails *a, b->image)) || (1 != json_equal (a->address, b->address)) || - (a->next_restock.abs_value_us != b->next_restock.abs_value_us)) + (GNUNET_TIME_timestamp_cmp (a->next_restock, + !=, + b->next_restock))) return 1; return 0; } @@ -1088,9 +1091,8 @@ static int run_test_products (struct TestProducts_Closure *cls) { struct GNUNET_Uuid uuid; - struct GNUNET_TIME_Absolute refund_deadline = - GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), - GNUNET_TIME_UNIT_WEEKS); + struct GNUNET_TIME_Timestamp refund_deadline = + GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_WEEKS); /* Test that insert without an instance fails */ TEST_RET_ON_FAIL (test_insert_product (&cls->instance, @@ -1144,7 +1146,7 @@ run_test_products (struct TestProducts_Closure *cls) GNUNET_assert (0 == json_array_append_new (cls->products[0].product.address, json_string ("444 Some Street"))); - cls->products[0].product.next_restock = GNUNET_TIME_absolute_get (); + cls->products[0].product.next_restock = GNUNET_TIME_timestamp_get (); TEST_RET_ON_FAIL (test_update_product (&cls->instance, &cls->products[0], GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); @@ -1269,7 +1271,7 @@ struct OrderData /** * The pay deadline for the order */ - struct GNUNET_TIME_Absolute pay_deadline; + struct GNUNET_TIME_Timestamp pay_deadline; /** * The contract of the order @@ -1293,20 +1295,17 @@ static void make_order (const char *order_id, struct OrderData *order) { - struct GNUNET_TIME_Absolute refund_deadline; + struct GNUNET_TIME_Timestamp refund_deadline; order->id = order_id; order->contract = json_object (); GNUNET_assert (NULL != order->contract); - order->pay_deadline = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), - GNUNET_TIME_UNIT_DAYS); + order->pay_deadline = GNUNET_TIME_relative_to_timestamp ( + GNUNET_TIME_UNIT_DAYS); GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, &order->claim_token, sizeof (order->claim_token)); - refund_deadline = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), - GNUNET_TIME_UNIT_WEEKS); - GNUNET_TIME_round_abs (&order->pay_deadline); - GNUNET_TIME_round_abs (&refund_deadline); + refund_deadline = GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_WEEKS); json_object_set_new (order->contract, "fulfillment_url", json_string ("a")); @@ -1315,10 +1314,10 @@ make_order (const char *order_id, json_string (order_id)); json_object_set_new (order->contract, "pay_deadline", - GNUNET_JSON_from_time_abs (order->pay_deadline)); + GNUNET_JSON_from_timestamp (order->pay_deadline)); json_object_set_new (order->contract, "refund_deadline", - GNUNET_JSON_from_time_abs (refund_deadline)); + GNUNET_JSON_from_timestamp (refund_deadline)); } @@ -1455,7 +1454,7 @@ static void lookup_orders_cb (void *cls, const char *order_id, uint64_t order_serial, - struct GNUNET_TIME_Absolute timestamp) + struct GNUNET_TIME_Timestamp timestamp) { struct TestLookupOrders_Closure *cmp = cls; if (NULL == cmp) @@ -1559,7 +1558,7 @@ static void get_order_serial_cb (void *cls, const char *order_id, uint64_t order_serial, - struct GNUNET_TIME_Absolute timestamp) + struct GNUNET_TIME_Timestamp timestamp) { struct LookupOrderSerial_Closure *lookup_cls = cls; if (NULL == lookup_cls) @@ -1589,7 +1588,7 @@ get_order_serial (const struct InstanceData *instance, .paid = TALER_EXCHANGE_YNA_ALL, .refunded = TALER_EXCHANGE_YNA_ALL, .wired = TALER_EXCHANGE_YNA_ALL, - .date = GNUNET_TIME_UNIT_ZERO_ABS, + .date = GNUNET_TIME_UNIT_ZERO_TS, .start_row = 0, .delta = 256 }; @@ -1956,12 +1955,12 @@ pre_test_orders (struct TestOrders_Closure *cls) "other_field", json_string ("Second contract"))); - cls->orders[2].pay_deadline = GNUNET_TIME_UNIT_ZERO_ABS; + cls->orders[2].pay_deadline = GNUNET_TIME_UNIT_ZERO_TS; GNUNET_assert (0 == json_object_set_new ( cls->orders[2].contract, "pay_deadline", - GNUNET_JSON_from_time_abs (cls->orders[2].pay_deadline))); + GNUNET_JSON_from_timestamp (cls->orders[2].pay_deadline))); } @@ -1994,7 +1993,7 @@ run_test_orders (struct TestOrders_Closure *cls) .paid = TALER_EXCHANGE_YNA_ALL, .refunded = TALER_EXCHANGE_YNA_ALL, .wired = TALER_EXCHANGE_YNA_ALL, - .date = GNUNET_TIME_absolute_get_zero_ (), + .date = GNUNET_TIME_UNIT_ZERO_TS, .start_row = 0, .delta = 8 }; @@ -2309,17 +2308,17 @@ struct ExchangeSignkeyData /** * When the signing key becomes valid. */ - struct GNUNET_TIME_Absolute start_date; + struct GNUNET_TIME_Timestamp start_date; /** * When the signing key stops being used. */ - struct GNUNET_TIME_Absolute expire_date; + struct GNUNET_TIME_Timestamp expire_date; /** * When the signing key becomes invalid for proof. */ - struct GNUNET_TIME_Absolute end_date; + struct GNUNET_TIME_Timestamp end_date; }; @@ -2349,9 +2348,9 @@ make_exchange_signkey (struct ExchangeSignkeyData *signkey) GNUNET_CRYPTO_eddsa_sign (&signkey->master_priv.eddsa_priv, &exch_sign, &signkey->master_sig.eddsa_signature); - signkey->start_date = GNUNET_TIME_absolute_get (); - signkey->expire_date = GNUNET_TIME_absolute_get (); - signkey->end_date = GNUNET_TIME_absolute_get (); + signkey->start_date = GNUNET_TIME_timestamp_get (); + signkey->expire_date = GNUNET_TIME_timestamp_get (); + signkey->end_date = GNUNET_TIME_timestamp_get (); } @@ -2363,7 +2362,7 @@ struct DepositData /** * When the deposit was made. */ - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp timestamp; /** * Hash of the associated order's contract terms. @@ -2436,7 +2435,7 @@ make_deposit (const struct InstanceData *instance, }; struct TALER_Amount amount_without_fee; - deposit->timestamp = GNUNET_TIME_absolute_get (); + deposit->timestamp = GNUNET_TIME_timestamp_get (); GNUNET_assert (GNUNET_OK == TALER_JSON_contract_hash (order->contract, &deposit->h_contract_terms)); @@ -2463,12 +2462,12 @@ make_deposit (const struct InstanceData *instance, deposit->h_wire = account->h_wire; deposit_sign.h_contract_terms = deposit->h_contract_terms; deposit_sign.h_wire = deposit->h_wire; - deposit_sign.exchange_timestamp = GNUNET_TIME_absolute_hton ( - GNUNET_TIME_absolute_get ()); - deposit_sign.wire_deadline = GNUNET_TIME_absolute_hton ( - GNUNET_TIME_absolute_get ()); - deposit_sign.refund_deadline = GNUNET_TIME_absolute_hton ( - GNUNET_TIME_absolute_get ()); + deposit_sign.exchange_timestamp = GNUNET_TIME_timestamp_hton ( + GNUNET_TIME_timestamp_get ()); + deposit_sign.wire_deadline = GNUNET_TIME_timestamp_hton ( + GNUNET_TIME_timestamp_get ()); + deposit_sign.refund_deadline = GNUNET_TIME_timestamp_hton ( + GNUNET_TIME_timestamp_get ()); TALER_amount_hton (&deposit_sign.amount_without_fee, &amount_without_fee); deposit_sign.merchant_pub = instance->merchant_pub; @@ -2701,8 +2700,8 @@ lookup_deposits_contract_coin_cb ( 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) { @@ -2713,8 +2712,9 @@ lookup_deposits_contract_coin_cb ( cmp->results_length += 1; for (unsigned int i = 0; cmp->deposits_to_cmp_length > i; ++i) { - if ((cmp->deposits_to_cmp[i].timestamp.abs_value_us == - deposit_timestamp.abs_value_us) && + if ((GNUNET_TIME_timestamp_cmp (cmp->deposits_to_cmp[i].timestamp, + ==, + deposit_timestamp)) && (0 == strcmp (cmp->deposits_to_cmp[i].exchange_url, exchange_url)) && (GNUNET_OK == TALER_amount_cmp_currency ( @@ -3231,12 +3231,12 @@ struct WireFeeData /** * Start date of the wire fee. */ - struct GNUNET_TIME_Absolute wire_fee_start; + struct GNUNET_TIME_Timestamp wire_fee_start; /** * End date of the wire fee. */ - struct GNUNET_TIME_Absolute wire_fee_end; + struct GNUNET_TIME_Timestamp wire_fee_end; /** * Signature on the wire fee. @@ -3274,16 +3274,16 @@ make_wire_fee (const struct ExchangeSignkeyData *signkey, GNUNET_assert (GNUNET_OK == TALER_string_to_amount ("EUR:0.49", &wire_fee->closing_fee)); - wire_fee->wire_fee_start = GNUNET_TIME_absolute_get (); - wire_fee->wire_fee_end = GNUNET_TIME_absolute_add (wire_fee->wire_fee_start, - GNUNET_TIME_UNIT_MONTHS); + wire_fee->wire_fee_start = GNUNET_TIME_timestamp_get (); + wire_fee->wire_fee_end = GNUNET_TIME_relative_to_timestamp ( + GNUNET_TIME_UNIT_MONTHS); fee_sign.h_wire_method = wire_fee->h_wire_method; TALER_amount_hton (&fee_sign.wire_fee, &wire_fee->wire_fee); TALER_amount_hton (&fee_sign.closing_fee, &wire_fee->closing_fee); - fee_sign.start_date = GNUNET_TIME_absolute_hton (wire_fee->wire_fee_start); - fee_sign.end_date = GNUNET_TIME_absolute_hton (wire_fee->wire_fee_end); + fee_sign.start_date = GNUNET_TIME_timestamp_hton (wire_fee->wire_fee_start); + fee_sign.end_date = GNUNET_TIME_timestamp_hton (wire_fee->wire_fee_end); GNUNET_CRYPTO_eddsa_sign (&signkey->master_priv.eddsa_priv, &fee_sign, &wire_fee->fee_sig.eddsa_signature); @@ -3376,7 +3376,7 @@ make_transfer (const struct ExchangeSignkeyData *signkey, &deposits[i].deposit_fee)); } transfer->data.exchange_pub = signkey->exchange_pub; - transfer->data.execution_time = GNUNET_TIME_absolute_get (); + transfer->data.execution_time = GNUNET_TIME_timestamp_get (); transfer->data.details = details; GNUNET_assert (GNUNET_OK == TALER_string_to_amount ("EUR:0.50", @@ -3404,7 +3404,7 @@ test_lookup_transfer ( struct TALER_Amount total; struct TALER_Amount fee; struct TALER_Amount exchange_amount; - struct GNUNET_TIME_Absolute time; + struct GNUNET_TIME_Timestamp time; bool esig; bool verified; @@ -3434,7 +3434,9 @@ test_lookup_transfer ( &fee)) || (0 != TALER_amount_cmp (&transfer->data.wire_fee, &fee)) || - (transfer->data.execution_time.abs_value_us != time.abs_value_us) || + (GNUNET_TIME_timestamp_cmp (transfer->data.execution_time, + !=, + time)) || (transfer->verified != verified)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -3714,7 +3716,7 @@ lookup_transfer_details_order_cb ( 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) @@ -3731,18 +3733,20 @@ lookup_transfer_details_order_cb ( wtid)) && (0 == strcmp (cmp->transfers_to_cmp[i].exchange_url, exchange_url)) && - /*(cmp->transfers_to_cmp[i].execution_time.abs_value_us == - execution_time.abs_value_us) &&*/ - (GNUNET_OK == TALER_amount_cmp_currency ( + (GNUNET_OK == + TALER_amount_cmp_currency ( &cmp->transfers_to_cmp[i].data.total_amount, deposit_value)) && - (0 == TALER_amount_cmp (&cmp->transfers_to_cmp[i].data.total_amount, - deposit_value)) && - (GNUNET_OK == TALER_amount_cmp_currency ( + (0 == + TALER_amount_cmp (&cmp->transfers_to_cmp[i].data.total_amount, + deposit_value)) && + (GNUNET_OK == + TALER_amount_cmp_currency ( &cmp->transfers_to_cmp[i].deposit_fee, deposit_fee)) && - (0 == TALER_amount_cmp (&cmp->transfers_to_cmp[i].deposit_fee, - deposit_fee)) /* && + (0 == + TALER_amount_cmp (&cmp->transfers_to_cmp[i].deposit_fee, + deposit_fee)) /* && (cmp->transfers_to_cmp[i].confirmed == transfer_confirmed)*/) cmp->results_matching[i] += 1; } @@ -3847,13 +3851,13 @@ test_lookup_wire_fee (const struct ExchangeSignkeyData *signkey, { struct TALER_Amount wire_fee; struct TALER_Amount closing_fee; - struct GNUNET_TIME_Absolute start_date; - struct GNUNET_TIME_Absolute end_date; + struct GNUNET_TIME_Timestamp start_date; + struct GNUNET_TIME_Timestamp end_date; struct TALER_MasterSignatureP master_sig; if (1 != plugin->lookup_wire_fee (plugin->cls, &signkey->master_pub, wire_fee_data->wire_method, - GNUNET_TIME_absolute_get (), + GNUNET_TIME_timestamp_get (), &wire_fee, &closing_fee, &start_date, @@ -3864,16 +3868,22 @@ test_lookup_wire_fee (const struct ExchangeSignkeyData *signkey, "Lookup wire fee failed\n"); return 1; } - if ((GNUNET_OK != TALER_amount_cmp_currency (&wire_fee_data->wire_fee, - &wire_fee)) || + if ((GNUNET_OK != + TALER_amount_cmp_currency (&wire_fee_data->wire_fee, + &wire_fee)) || (0 != TALER_amount_cmp (&wire_fee_data->wire_fee, &wire_fee)) || - (GNUNET_OK != TALER_amount_cmp_currency (&wire_fee_data->closing_fee, - &closing_fee)) || + (GNUNET_OK != + TALER_amount_cmp_currency (&wire_fee_data->closing_fee, + &closing_fee)) || (0 != TALER_amount_cmp (&wire_fee_data->closing_fee, &closing_fee)) || - (wire_fee_data->wire_fee_start.abs_value_us != start_date.abs_value_us) || - (wire_fee_data->wire_fee_end.abs_value_us != end_date.abs_value_us) || + (GNUNET_TIME_timestamp_cmp (wire_fee_data->wire_fee_start, + !=, + start_date)) || + (GNUNET_TIME_timestamp_cmp (wire_fee_data->wire_fee_end, + !=, + end_date)) || (0 != GNUNET_memcmp (&wire_fee_data->fee_sig, &master_sig))) { @@ -3921,7 +3931,7 @@ struct TestLookupTransfers_Closure * @param payto_uri target account that received the wire transfer * @param exchange_url base URL of the exchange that made the wire transfer * @param transfer_serial_id serial number identifying the transfer in the backend - * @param execution_time when did the exchange make the transfer, #GNUNET_TIME_UNIT_FOREVER_ABS + * @param execution_time when did the exchange make the transfer, #GNUNET_TIME_UNIT_FOREVER_TS * if it did not yet happen * @param verified true if we checked the exchange's answer and liked it, * false there is a problem (verification failed or did not yet happen) @@ -3935,7 +3945,7 @@ lookup_transfers_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) { @@ -3950,8 +3960,10 @@ lookup_transfers_cb (void *cls, credit_amount)) && (0 == TALER_amount_cmp (&cmp->transfers_to_cmp[i].data.total_amount, credit_amount)) && - (cmp->transfers_to_cmp[i].data.execution_time.abs_value_us == - execution_time.abs_value_us)) + (GNUNET_TIME_timestamp_cmp ( + cmp->transfers_to_cmp[i].data.execution_time, + ==, + execution_time))) { cmp->results_matching[i] += 1; } @@ -3977,8 +3989,8 @@ lookup_transfers_cb (void *cls, static int test_lookup_transfers (const struct InstanceData *instance, const struct TALER_MERCHANTDB_AccountDetails *account, - struct GNUNET_TIME_Absolute before, - struct GNUNET_TIME_Absolute after, + struct GNUNET_TIME_Timestamp before, + struct GNUNET_TIME_Timestamp after, int64_t limit, uint64_t offset, enum TALER_EXCHANGE_YesNoAll filter_verified, @@ -4242,7 +4254,7 @@ run_test_transfers (struct TestTransfers_Closure *cls) plugin->lookup_wire_fee (plugin->cls, &cls->signkey.master_pub, cls->wire_fee[0].wire_method, - GNUNET_TIME_absolute_get (), + GNUNET_TIME_timestamp_get (), NULL, NULL, NULL, @@ -4348,8 +4360,8 @@ run_test_transfers (struct TestTransfers_Closure *cls) &cls->transfers[0])); TEST_RET_ON_FAIL (test_lookup_transfers (&cls->instance, &cls->account, - GNUNET_TIME_UNIT_FOREVER_ABS, - GNUNET_TIME_UNIT_ZERO_ABS, + GNUNET_TIME_UNIT_FOREVER_TS, + GNUNET_TIME_UNIT_ZERO_TS, 8, 0, TALER_EXCHANGE_YNA_ALL, @@ -4409,7 +4421,7 @@ struct ReserveData /** * The expiration date */ - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; }; @@ -4488,8 +4500,8 @@ struct TestLookupReserve_Closure */ static void lookup_reserve_cb (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, @@ -4504,9 +4516,11 @@ lookup_reserve_cb (void *cls, unsigned int tip_cmp_results[tips_length]; if (NULL == cmp) return; - if ((cmp->reserve_to_cmp->expiration.abs_value_us != - expiration_time.abs_value_us) || - (GNUNET_OK != TALER_amount_cmp_currency ( + if (GNUNET_TIME_timestamp_cmp (cmp->reserve_to_cmp->expiration, + !=, + expiration_time) || + (GNUNET_OK != + TALER_amount_cmp_currency ( &cmp->reserve_to_cmp->initial_amount, merchant_initial_amount)) || (0 != TALER_amount_cmp (&cmp->reserve_to_cmp->initial_amount, @@ -4629,8 +4643,8 @@ struct TestLookupReserves_Closure static void lookup_reserves_cb (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, @@ -4642,11 +4656,14 @@ lookup_reserves_cb (void *cls, return; for (unsigned int i = 0; cmp->reserves_to_cmp_length > i; ++i) { - if ((0 == GNUNET_memcmp (&cmp->reserves_to_cmp[i].reserve_pub, - reserve_pub)) && - (cmp->reserves_to_cmp[i].expiration.abs_value_us == - expiration_time.abs_value_us) && - (GNUNET_OK == TALER_amount_cmp_currency ( + if ((0 == + GNUNET_memcmp (&cmp->reserves_to_cmp[i].reserve_pub, + reserve_pub)) && + (GNUNET_TIME_timestamp_cmp (cmp->reserves_to_cmp[i].expiration, + ==, + expiration_time)) && + (GNUNET_OK == + TALER_amount_cmp_currency ( &cmp->reserves_to_cmp[i].initial_amount, merchant_initial_amount)) && (0 == TALER_amount_cmp (&cmp->reserves_to_cmp[i].initial_amount, @@ -4680,7 +4697,7 @@ test_lookup_reserves (const struct InstanceData *instance, memset (results_matching, 0, sizeof (unsigned int) * reserves_length); if (1 != plugin->lookup_reserves (plugin->cls, instance->instance.id, - GNUNET_TIME_absolute_get_zero_ (), + GNUNET_TIME_UNIT_ZERO_TS, TALER_EXCHANGE_YNA_ALL, TALER_EXCHANGE_YNA_ALL, &lookup_reserves_cb, @@ -4812,7 +4829,7 @@ struct TipData /** * When the tip expires. */ - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; }; @@ -4876,7 +4893,7 @@ test_lookup_tip (const struct InstanceData *instance, { struct TALER_Amount total_authorized; struct TALER_Amount total_picked_up; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; char *exchange_url = NULL; struct TALER_ReservePrivateKeyP reserve_priv; @@ -4894,15 +4911,19 @@ test_lookup_tip (const struct InstanceData *instance, GNUNET_free (exchange_url); return 1; } - if ((GNUNET_OK != TALER_amount_cmp_currency (&tip->details.total_amount, - &total_authorized)) || + if ((GNUNET_OK != + TALER_amount_cmp_currency (&tip->details.total_amount, + &total_authorized)) || (0 != TALER_amount_cmp (&tip->details.total_amount, &total_authorized)) || - (GNUNET_OK != TALER_amount_cmp_currency (expected_total_picked_up, - &total_picked_up)) || + (GNUNET_OK != + TALER_amount_cmp_currency (expected_total_picked_up, + &total_picked_up)) || (0 != TALER_amount_cmp (expected_total_picked_up, &total_picked_up)) || - (tip->expiration.abs_value_us != expiration.abs_value_us) || + (GNUNET_TIME_timestamp_cmp (tip->expiration, + !=, + expiration)) || (0 != strcmp (reserve->exchange_url, exchange_url)) || (0 != GNUNET_memcmp (&reserve->reserve_priv, @@ -4943,7 +4964,7 @@ test_lookup_tip_details ( struct TALER_Amount total_authorized; struct TALER_Amount total_picked_up; char *justification = NULL; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; struct TALER_ReservePublicKeyP reserve_pub; unsigned int pickups_length; struct TALER_MERCHANTDB_PickupDetails *pickups = NULL; @@ -4973,13 +4994,16 @@ test_lookup_tip_details ( &total_authorized)) || (0 != TALER_amount_cmp (&tip->details.total_amount, &total_authorized)) || - (GNUNET_OK != TALER_amount_cmp_currency (expected_total_picked_up, - &total_picked_up)) || + (GNUNET_OK != + TALER_amount_cmp_currency (expected_total_picked_up, + &total_picked_up)) || (0 != TALER_amount_cmp (expected_total_picked_up, &total_picked_up)) || (0 != strcmp (tip->details.reason, justification)) || - (tip->expiration.abs_value_us != expiration.abs_value_us) || + (GNUNET_TIME_timestamp_cmp (tip->expiration, + !=, + expiration)) || (0 != GNUNET_memcmp (&reserve->reserve_pub, &reserve_pub)) || (expected_pickups_length != pickups_length) ) @@ -5341,9 +5365,8 @@ pre_test_tips (struct TestTips_Closure *cls) &cls->reserve.initial_amount)); cls->reserve.exchange_url = "exch-url"; cls->reserve.payto_uri = "payto://other-uri"; - cls->reserve.expiration = - GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), - GNUNET_TIME_UNIT_WEEKS); + cls->reserve.expiration = GNUNET_TIME_relative_to_timestamp ( + GNUNET_TIME_UNIT_WEEKS); GNUNET_CRYPTO_eddsa_key_create ( &cls->expired_reserve.reserve_priv.eddsa_priv); @@ -5356,7 +5379,7 @@ pre_test_tips (struct TestTips_Closure *cls) &cls->expired_reserve.initial_amount)); cls->expired_reserve.exchange_url = "exch-url"; cls->expired_reserve.payto_uri = "payto://some-uri"; - cls->expired_reserve.expiration = GNUNET_TIME_UNIT_ZERO_ABS; + cls->expired_reserve.expiration = GNUNET_TIME_UNIT_ZERO_TS; /* Tip/pickup */ make_tip (&cls->tip); @@ -5753,7 +5776,7 @@ struct RefundData /** * When the refund occurred. */ - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Timestamp timestamp; /** * Reason for the refund. @@ -5786,7 +5809,7 @@ static void make_refund (const struct DepositData *deposit, struct RefundData *refund) { - refund->timestamp = GNUNET_TIME_absolute_get (); + refund->timestamp = GNUNET_TIME_timestamp_get (); refund->reason = "some reason"; refund->refund_amount = deposit->amount_with_fee; refund->coin_pub = &deposit->coin_pub; @@ -5860,7 +5883,7 @@ struct TestLookupRefundsDetailed_Closure static void lookup_refunds_detailed_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, @@ -5874,8 +5897,9 @@ lookup_refunds_detailed_cb (void *cls, cmp->results_length += 1; for (unsigned int i = 0; cmp->refunds_to_cmp_length > i; ++i) { - if (((cmp->refunds_to_cmp[i].timestamp.abs_value_us == - timestamp.abs_value_us) || + if (((GNUNET_TIME_timestamp_cmp (cmp->refunds_to_cmp[i].timestamp, + ==, + timestamp)) || ! cmp->cmp_timestamps) && (0 == GNUNET_memcmp (cmp->refunds_to_cmp[i].coin_pub, coin_pub)) && @@ -5883,7 +5907,8 @@ lookup_refunds_detailed_cb (void *cls, exchange_url)) && (0 == strcmp (cmp->refunds_to_cmp[i].reason, reason)) && - (GNUNET_OK == TALER_amount_cmp_currency ( + (GNUNET_OK == + TALER_amount_cmp_currency ( &cmp->refunds_to_cmp[i].refund_amount, refund_amount)) && (0 == TALER_amount_cmp (&cmp->refunds_to_cmp[i].refund_amount, @@ -5983,7 +6008,7 @@ struct LookupRefundSerial_Closure static void get_refund_serial_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, @@ -5994,15 +6019,17 @@ get_refund_serial_cb (void *cls, struct LookupRefundSerial_Closure *lookup_cls = cls; if (NULL == lookup_cls) return; - if ((lookup_cls->refund->timestamp.abs_value_us == - timestamp.abs_value_us) && + if ((GNUNET_TIME_timestamp_cmp (lookup_cls->refund->timestamp, + ==, + timestamp)) && (0 == GNUNET_memcmp (lookup_cls->refund->coin_pub, coin_pub)) && (0 == strcmp (lookup_cls->refund->exchange_url, exchange_url)) && (0 == strcmp (lookup_cls->refund->reason, reason)) && - (GNUNET_OK == TALER_amount_cmp_currency ( + (GNUNET_OK == + TALER_amount_cmp_currency ( &lookup_cls->refund->refund_amount, refund_amount)) && (0 == TALER_amount_cmp (&lookup_cls->refund->refund_amount, @@ -6592,7 +6619,7 @@ run_test_lookup_orders_all_filters ( .paid = (i % 3) + 1, .refunded = ((i / 3) % 3) + 1, .wired = ((i / 9) % 3) + 1, - .date = GNUNET_TIME_absolute_get_zero_ (), + .date = GNUNET_TIME_UNIT_ZERO_TS, .start_row = 0, .delta = 64 }; @@ -6627,7 +6654,7 @@ run_test_lookup_orders_all_filters ( /* Now test decreasing */ filter.start_row = 256; - filter.date = GNUNET_TIME_UNIT_FOREVER_ABS; + filter.date = GNUNET_TIME_UNIT_FOREVER_TS; filter.delta = -64; reverse_order_data_array (orders_length, @@ -6670,7 +6697,7 @@ kyc_status_ok (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) { bool *fail = cls; @@ -6686,7 +6713,7 @@ kyc_status_fail (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) { bool *fail = cls; @@ -6707,7 +6734,7 @@ test_kyc (void) struct InstanceData instance; struct TALER_MERCHANTDB_AccountDetails account; bool fail; - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp now; make_instance ("test_kyc", &instance); @@ -6717,8 +6744,7 @@ test_kyc (void) TEST_RET_ON_FAIL (test_insert_account (&instance, &account, GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); + now = GNUNET_TIME_timestamp_get (); TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->account_kyc_set_status (plugin->cls, instance.instance.id, |