From 36c2bb7d41b95564652a66b0de40527f78022582 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 14 Dec 2021 19:19:32 +0100 Subject: -fixing FTBFS for v11 --- src/stasis/plugin_anastasis_postgres.c | 177 ++++++++++++++++----------------- 1 file changed, 86 insertions(+), 91 deletions(-) (limited to 'src/stasis/plugin_anastasis_postgres.c') diff --git a/src/stasis/plugin_anastasis_postgres.c b/src/stasis/plugin_anastasis_postgres.c index bdbdc04..813da94 100644 --- a/src/stasis/plugin_anastasis_postgres.c +++ b/src/stasis/plugin_anastasis_postgres.c @@ -1072,7 +1072,7 @@ postgres_increment_lifetime ( const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub, const struct ANASTASIS_PaymentSecretP *payment_identifier, struct GNUNET_TIME_Relative lifetime, - struct GNUNET_TIME_Absolute *paid_until) + struct GNUNET_TIME_Timestamp *paid_until) { struct PostgresClosure *pg = cls; enum GNUNET_DB_QueryStatus qs; @@ -1101,7 +1101,7 @@ postgres_increment_lifetime ( { case GNUNET_DB_STATUS_HARD_ERROR: rollback (pg); - *paid_until = GNUNET_TIME_UNIT_ZERO_ABS; + *paid_until = GNUNET_TIME_UNIT_ZERO_TS; return qs; case GNUNET_DB_STATUS_SOFT_ERROR: goto retry; @@ -1120,10 +1120,10 @@ postgres_increment_lifetime ( GNUNET_PQ_query_param_auto_from_type (account_pub), GNUNET_PQ_query_param_end }; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_absolute_time ("expiration_date", - &expiration), + GNUNET_PQ_result_spec_timestamp ("expiration_date", + &expiration), GNUNET_PQ_result_spec_end }; @@ -1151,13 +1151,12 @@ postgres_increment_lifetime ( /* user does not exist, create new one */ struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (account_pub), - GNUNET_PQ_query_param_absolute_time (&expiration), + GNUNET_PQ_query_param_timestamp (&expiration), GNUNET_PQ_query_param_end }; - expiration = GNUNET_TIME_relative_to_absolute (lifetime); - GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - expiration.abs_value_us); + expiration = GNUNET_TIME_relative_to_timestamp (lifetime); + GNUNET_break (! GNUNET_TIME_absolute_is_never (expiration.abs_time)); *paid_until = expiration; qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, "user_insert", @@ -1173,22 +1172,24 @@ postgres_increment_lifetime ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Payment existed, lifetime of account %s unchanged at %s\n", TALER_B2S (account_pub), - GNUNET_STRINGS_absolute_time_to_string (*paid_until)); + GNUNET_TIME_timestamp2s (*paid_until)); return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; } else { /* user exists, update expiration_date */ struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_absolute_time (&expiration), + GNUNET_PQ_query_param_timestamp (&expiration), GNUNET_PQ_query_param_auto_from_type (account_pub), GNUNET_PQ_query_param_end }; - expiration = GNUNET_TIME_absolute_add (expiration, - lifetime); - GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - expiration.abs_value_us); + expiration + = GNUNET_TIME_absolute_to_timestamp ( + GNUNET_TIME_absolute_add (expiration.abs_time, + lifetime)); + GNUNET_break (! GNUNET_TIME_absolute_is_never ( + expiration.abs_time)); *paid_until = expiration; qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, "user_update", @@ -1220,7 +1221,7 @@ postgres_increment_lifetime ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Incremented lifetime of account %s to %s\n", TALER_B2S (account_pub), - GNUNET_STRINGS_absolute_time_to_string (*paid_until)); + GNUNET_TIME_timestamp2s (*paid_until)); return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; retry: rollback (pg); @@ -1244,7 +1245,7 @@ postgres_update_lifetime ( void *cls, const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub, const struct ANASTASIS_PaymentSecretP *payment_identifier, - struct GNUNET_TIME_Absolute eol) + struct GNUNET_TIME_Timestamp eol) { struct PostgresClosure *pg = cls; enum GNUNET_DB_QueryStatus qs; @@ -1288,10 +1289,10 @@ postgres_update_lifetime ( GNUNET_PQ_query_param_auto_from_type (account_pub), GNUNET_PQ_query_param_end }; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp expiration; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_absolute_time ("expiration_date", - &expiration), + GNUNET_PQ_result_spec_timestamp ("expiration_date", + &expiration), GNUNET_PQ_result_spec_end }; @@ -1311,41 +1312,39 @@ postgres_update_lifetime ( /* user does not exist, create new one */ struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (account_pub), - GNUNET_PQ_query_param_absolute_time (&eol), + GNUNET_PQ_query_param_timestamp (&eol), GNUNET_PQ_query_param_end }; - GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - eol.abs_value_us); + GNUNET_break (! GNUNET_TIME_absolute_is_never (eol.abs_time)); qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, "user_insert", params); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Created new account %s with expiration %s\n", TALER_B2S (account_pub), - GNUNET_STRINGS_absolute_time_to_string (eol)); + GNUNET_TIME_timestamp2s (eol)); } break; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: { /* user exists, update expiration_date */ struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_absolute_time (&expiration), + GNUNET_PQ_query_param_timestamp (&expiration), GNUNET_PQ_query_param_auto_from_type (account_pub), GNUNET_PQ_query_param_end }; - expiration = GNUNET_TIME_absolute_max (expiration, - eol); - GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - expiration.abs_value_us); + expiration = GNUNET_TIME_timestamp_max (expiration, + eol); + GNUNET_break (! GNUNET_TIME_absolute_is_never (expiration.abs_time)); qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, "user_update", params); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Updated account %s to new expiration %s\n", TALER_B2S (account_pub), - GNUNET_STRINGS_absolute_time_to_string (expiration)); + GNUNET_TIME_timestamp2s (expiration)); } break; } @@ -1399,14 +1398,14 @@ postgres_record_recdoc_payment ( const struct TALER_Amount *amount) { struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); + struct GNUNET_TIME_Timestamp expiration; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (account_pub), GNUNET_PQ_query_param_uint32 (&post_counter), TALER_PQ_query_param_amount (amount), GNUNET_PQ_query_param_auto_from_type (payment_secret), - GNUNET_PQ_query_param_absolute_time (&now), + GNUNET_PQ_query_param_timestamp (&now), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; @@ -1423,8 +1422,8 @@ postgres_record_recdoc_payment ( GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_absolute_time ("expiration_date", - &expiration), + GNUNET_PQ_result_spec_timestamp ("expiration_date", + &expiration), GNUNET_PQ_result_spec_end }; @@ -1443,11 +1442,11 @@ postgres_record_recdoc_payment ( case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: { /* create new user with short lifetime */ - struct GNUNET_TIME_Absolute exp - = GNUNET_TIME_relative_to_absolute (TRANSIENT_LIFETIME); + struct GNUNET_TIME_Timestamp exp + = GNUNET_TIME_relative_to_timestamp (TRANSIENT_LIFETIME); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (account_pub), - GNUNET_PQ_query_param_absolute_time (&exp), + GNUNET_PQ_query_param_timestamp (&exp), GNUNET_PQ_query_param_end }; @@ -1469,7 +1468,7 @@ postgres_record_recdoc_payment ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Created new account %s with transient life until %s\n", TALER_B2S (account_pub), - GNUNET_STRINGS_absolute_time_to_string (exp)); + GNUNET_TIME_timestamp2s (exp)); break; } } @@ -1503,11 +1502,12 @@ postgres_record_truth_upload_payment ( struct GNUNET_TIME_Relative duration) { struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute exp = GNUNET_TIME_relative_to_absolute (duration); + struct GNUNET_TIME_Timestamp exp = GNUNET_TIME_relative_to_timestamp ( + duration); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (uuid), TALER_PQ_query_param_amount (amount), - GNUNET_PQ_query_param_absolute_time (&exp), + GNUNET_PQ_query_param_timestamp (&exp), GNUNET_PQ_query_param_end }; @@ -1530,18 +1530,18 @@ static enum GNUNET_DB_QueryStatus postgres_check_truth_upload_paid ( void *cls, const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid, - struct GNUNET_TIME_Absolute *paid_until) + struct GNUNET_TIME_Timestamp *paid_until) { struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); + struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (uuid), - GNUNET_PQ_query_param_absolute_time (&now), + GNUNET_PQ_query_param_timestamp (&now), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_absolute_time ("expiration", - paid_until), + GNUNET_PQ_result_spec_timestamp ("expiration", + paid_until), GNUNET_PQ_result_spec_end }; @@ -1570,12 +1570,12 @@ postgres_record_challenge_payment ( const struct TALER_Amount *amount) { struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); + struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (truth_uuid), TALER_PQ_query_param_amount (amount), GNUNET_PQ_query_param_auto_from_type (payment_secret), - GNUNET_PQ_query_param_absolute_time (&now), + GNUNET_PQ_query_param_timestamp (&now), GNUNET_PQ_query_param_end }; @@ -1634,7 +1634,7 @@ postgres_record_auth_iban_payment ( const struct TALER_Amount *amount, const char *debit_account, const char *credit_account, - struct GNUNET_TIME_Absolute execution_date) + struct GNUNET_TIME_Timestamp execution_date) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -1643,7 +1643,7 @@ postgres_record_auth_iban_payment ( TALER_PQ_query_param_amount (amount), GNUNET_PQ_query_param_string (debit_account), GNUNET_PQ_query_param_string (credit_account), - GNUNET_PQ_query_param_absolute_time (&execution_date), + GNUNET_PQ_query_param_timestamp (&execution_date), GNUNET_PQ_query_param_end }; @@ -1753,7 +1753,7 @@ static enum GNUNET_DB_QueryStatus postgres_test_auth_iban_payment ( void *cls, const char *debit_account, - struct GNUNET_TIME_Absolute earliest_date, + struct GNUNET_TIME_Timestamp earliest_date, ANASTASIS_DB_AuthIbanTransfercheck cb, void *cb_cls) { @@ -1765,7 +1765,7 @@ postgres_test_auth_iban_payment ( }; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (debit_account), - TALER_PQ_query_param_absolute_time (&earliest_date), + GNUNET_PQ_query_param_timestamp (&earliest_date), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; @@ -1936,7 +1936,7 @@ postgres_store_truth ( struct GNUNET_TIME_Relative truth_expiration) { struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute expiration = GNUNET_TIME_absolute_get (); + struct GNUNET_TIME_Timestamp expiration; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (truth_uuid), GNUNET_PQ_query_param_auto_from_type (key_share_data), @@ -1944,14 +1944,12 @@ postgres_store_truth ( GNUNET_PQ_query_param_fixed_size (encrypted_truth, encrypted_truth_size), GNUNET_PQ_query_param_string (mime_type), - TALER_PQ_query_param_absolute_time (&expiration), + GNUNET_PQ_query_param_timestamp (&expiration), GNUNET_PQ_query_param_end }; - expiration = GNUNET_TIME_absolute_add (expiration, - truth_expiration); - GNUNET_TIME_round_abs (&expiration); + expiration = GNUNET_TIME_relative_to_timestamp (truth_expiration); check_connection (pg); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "truth_insert", @@ -2051,7 +2049,7 @@ enum ANASTASIS_DB_AccountStatus postgres_lookup_account ( void *cls, const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub, - struct GNUNET_TIME_Absolute *paid_until, + struct GNUNET_TIME_Timestamp *paid_until, struct GNUNET_HashCode *recovery_data_hash, uint32_t *version) { @@ -2067,8 +2065,8 @@ postgres_lookup_account ( postgres_preflight (pg)); { struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_absolute_time ("expiration_date", - paid_until), + GNUNET_PQ_result_spec_timestamp ("expiration_date", + paid_until), GNUNET_PQ_result_spec_auto_from_type ("recovery_data_hash", recovery_data_hash), GNUNET_PQ_result_spec_uint32 ("version", @@ -2097,8 +2095,8 @@ postgres_lookup_account ( /* check if account exists */ { struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_absolute_time ("expiration_date", - paid_until), + GNUNET_PQ_result_spec_timestamp ("expiration_date", + paid_until), GNUNET_PQ_result_spec_end }; @@ -2372,17 +2370,16 @@ postgres_verify_challenge_code ( .hashed_code = hashed_code, .pg = pg }; - struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); + struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (truth_uuid), - TALER_PQ_query_param_absolute_time (&now), + GNUNET_PQ_query_param_timestamp (&now), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; *satisfied = false; check_connection (pg); - GNUNET_TIME_round_abs (&now); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "challengecode_select", params, @@ -2447,13 +2444,13 @@ postgres_test_challenge_code_satisfied ( void *cls, const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid, const uint64_t code, - struct GNUNET_TIME_Absolute after) + struct GNUNET_TIME_Timestamp after) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (truth_uuid), GNUNET_PQ_query_param_uint64 (&code), - GNUNET_PQ_query_param_absolute_time (&after), + GNUNET_PQ_query_param_timestamp (&after), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -2483,12 +2480,13 @@ postgres_lookup_challenge_payment ( { struct PostgresClosure *pg = cls; struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); - struct GNUNET_TIME_Absolute recent - = GNUNET_TIME_absolute_subtract (now, - ANASTASIS_CHALLENGE_OFFER_LIFETIME); + struct GNUNET_TIME_Timestamp recent + = GNUNET_TIME_absolute_to_timestamp ( + GNUNET_TIME_absolute_subtract (now, + ANASTASIS_CHALLENGE_OFFER_LIFETIME)); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (truth_uuid), - GNUNET_PQ_query_param_absolute_time (&recent), + GNUNET_PQ_query_param_timestamp (&recent), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -2555,20 +2553,18 @@ postgres_create_challenge_code ( struct GNUNET_TIME_Relative rotation_period, struct GNUNET_TIME_Relative validity_period, uint32_t retry_counter, - struct GNUNET_TIME_Absolute *retransmission_date, + struct GNUNET_TIME_Timestamp *retransmission_date, uint64_t *code) { struct PostgresClosure *pg = cls; enum GNUNET_DB_QueryStatus qs; - struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); - struct GNUNET_TIME_Absolute expiration_date; + struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); + struct GNUNET_TIME_Timestamp expiration_date; struct GNUNET_TIME_Absolute ex_rot; check_connection (pg); - GNUNET_TIME_round_abs (&now); - expiration_date = GNUNET_TIME_absolute_add (now, - validity_period); - ex_rot = GNUNET_TIME_absolute_subtract (now, + expiration_date = GNUNET_TIME_relative_to_timestamp (validity_period); + ex_rot = GNUNET_TIME_absolute_subtract (now.abs_time, rotation_period); for (unsigned int retries = 0; retriesconn, "challengecode_mark_sent", params); @@ -2741,9 +2736,9 @@ enum GNUNET_DB_QueryStatus postgres_challenge_gc (void *cls) { struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute time_now = GNUNET_TIME_absolute_get (); + struct GNUNET_TIME_Timestamp time_now = GNUNET_TIME_timestamp_get (); struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_absolute_time (&time_now), + GNUNET_PQ_query_param_timestamp (&time_now), GNUNET_PQ_query_param_end }; -- cgit v1.2.3