diff options
Diffstat (limited to 'src/backend/anastasis-httpd_policy_upload.c')
-rw-r--r-- | src/backend/anastasis-httpd_policy_upload.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/backend/anastasis-httpd_policy_upload.c b/src/backend/anastasis-httpd_policy_upload.c index 0f9d8d6..b9ab266 100644 --- a/src/backend/anastasis-httpd_policy_upload.c +++ b/src/backend/anastasis-httpd_policy_upload.c | |||
@@ -114,7 +114,7 @@ struct PolicyUploadContext | |||
114 | * Timestamp of the order in @e payment_identifier. Used to | 114 | * Timestamp of the order in @e payment_identifier. Used to |
115 | * select the most recent unpaid offer. | 115 | * select the most recent unpaid offer. |
116 | */ | 116 | */ |
117 | struct GNUNET_TIME_Absolute existing_pi_timestamp; | 117 | struct GNUNET_TIME_Timestamp existing_pi_timestamp; |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * When does the operation timeout? | 120 | * When does the operation timeout? |
@@ -125,13 +125,13 @@ struct PolicyUploadContext | |||
125 | * How long must the account be valid? Determines whether we should | 125 | * How long must the account be valid? Determines whether we should |
126 | * trigger payment, and if so how much. | 126 | * trigger payment, and if so how much. |
127 | */ | 127 | */ |
128 | struct GNUNET_TIME_Absolute end_date; | 128 | struct GNUNET_TIME_Timestamp end_date; |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * How long is the account already valid? | 131 | * How long is the account already valid? |
132 | * Determines how much the user needs to pay. | 132 | * Determines how much the user needs to pay. |
133 | */ | 133 | */ |
134 | struct GNUNET_TIME_Absolute paid_until; | 134 | struct GNUNET_TIME_Timestamp paid_until; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Expected total upload size. | 137 | * Expected total upload size. |
@@ -475,7 +475,7 @@ check_payment_cb (void *cls, | |||
475 | case TALER_MERCHANT_OSC_CLAIMED: | 475 | case TALER_MERCHANT_OSC_CLAIMED: |
476 | break; | 476 | break; |
477 | } | 477 | } |
478 | if (0 != puc->existing_pi_timestamp.abs_value_us) | 478 | if (! GNUNET_TIME_absolute_is_zero (puc->existing_pi_timestamp.abs_time)) |
479 | { | 479 | { |
480 | /* repeat payment request */ | 480 | /* repeat payment request */ |
481 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 481 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -815,8 +815,8 @@ AH_handler_policy_post ( | |||
815 | } | 815 | } |
816 | else | 816 | else |
817 | { | 817 | { |
818 | puc->timeout = GNUNET_TIME_relative_to_absolute | 818 | puc->timeout = GNUNET_TIME_relative_to_absolute ( |
819 | (CHECK_PAYMENT_GENERIC_TIMEOUT); | 819 | CHECK_PAYMENT_GENERIC_TIMEOUT); |
820 | } | 820 | } |
821 | } | 821 | } |
822 | 822 | ||
@@ -848,7 +848,7 @@ AH_handler_policy_post ( | |||
848 | { | 848 | { |
849 | years = 0; | 849 | years = 0; |
850 | } | 850 | } |
851 | puc->end_date = GNUNET_TIME_relative_to_absolute ( | 851 | puc->end_date = GNUNET_TIME_relative_to_timestamp ( |
852 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, | 852 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, |
853 | years)); | 853 | years)); |
854 | } | 854 | } |
@@ -860,7 +860,7 @@ AH_handler_policy_post ( | |||
860 | { | 860 | { |
861 | struct GNUNET_TIME_Relative rem; | 861 | struct GNUNET_TIME_Relative rem; |
862 | 862 | ||
863 | rem = GNUNET_TIME_absolute_get_remaining (puc->end_date); | 863 | rem = GNUNET_TIME_absolute_get_remaining (puc->end_date.abs_time); |
864 | puc->years_to_pay = rem.rel_value_us | 864 | puc->years_to_pay = rem.rel_value_us |
865 | / GNUNET_TIME_UNIT_YEARS.rel_value_us; | 865 | / GNUNET_TIME_UNIT_YEARS.rel_value_us; |
866 | if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) | 866 | if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) |
@@ -943,7 +943,7 @@ AH_handler_policy_post ( | |||
943 | GNUNET_STRINGS_relative_time_to_string (rel, | 943 | GNUNET_STRINGS_relative_time_to_string (rel, |
944 | GNUNET_YES), | 944 | GNUNET_YES), |
945 | ANASTASIS_MAX_YEARS_STORAGE); | 945 | ANASTASIS_MAX_YEARS_STORAGE); |
946 | puc->paid_until = GNUNET_TIME_relative_to_absolute (rel); | 946 | puc->paid_until = GNUNET_TIME_relative_to_timestamp (rel); |
947 | qs = db->update_lifetime (db->cls, | 947 | qs = db->update_lifetime (db->cls, |
948 | account_pub, | 948 | account_pub, |
949 | &puc->payment_identifier, | 949 | &puc->payment_identifier, |
@@ -964,7 +964,7 @@ AH_handler_policy_post ( | |||
964 | struct GNUNET_HashCode hc; | 964 | struct GNUNET_HashCode hc; |
965 | enum ANASTASIS_DB_AccountStatus as; | 965 | enum ANASTASIS_DB_AccountStatus as; |
966 | uint32_t version; | 966 | uint32_t version; |
967 | struct GNUNET_TIME_Absolute now; | 967 | struct GNUNET_TIME_Timestamp now; |
968 | struct GNUNET_TIME_Relative rem; | 968 | struct GNUNET_TIME_Relative rem; |
969 | 969 | ||
970 | as = db->lookup_account (db->cls, | 970 | as = db->lookup_account (db->cls, |
@@ -972,11 +972,13 @@ AH_handler_policy_post ( | |||
972 | &puc->paid_until, | 972 | &puc->paid_until, |
973 | &hc, | 973 | &hc, |
974 | &version); | 974 | &version); |
975 | now = GNUNET_TIME_absolute_get (); | 975 | now = GNUNET_TIME_timestamp_get (); |
976 | if (puc->paid_until.abs_value_us < now.abs_value_us) | 976 | if (GNUNET_TIME_timestamp_cmp (puc->paid_until, |
977 | (<), | ||
978 | now)) | ||
977 | puc->paid_until = now; | 979 | puc->paid_until = now; |
978 | rem = GNUNET_TIME_absolute_get_difference (puc->paid_until, | 980 | rem = GNUNET_TIME_absolute_get_difference (puc->paid_until.abs_time, |
979 | puc->end_date); | 981 | puc->end_date.abs_time); |
980 | puc->years_to_pay = rem.rel_value_us | 982 | puc->years_to_pay = rem.rel_value_us |
981 | / GNUNET_TIME_UNIT_YEARS.rel_value_us; | 983 | / GNUNET_TIME_UNIT_YEARS.rel_value_us; |
982 | if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) | 984 | if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) |
@@ -1122,7 +1124,7 @@ AH_handler_policy_post ( | |||
1122 | sizeof (expir_s), | 1124 | sizeof (expir_s), |
1123 | "%llu", | 1125 | "%llu", |
1124 | (unsigned long long) | 1126 | (unsigned long long) |
1125 | (puc->paid_until.abs_value_us | 1127 | (puc->paid_until.abs_time.abs_value_us |
1126 | / GNUNET_TIME_UNIT_SECONDS.rel_value_us)); | 1128 | / GNUNET_TIME_UNIT_SECONDS.rel_value_us)); |
1127 | switch (ss) | 1129 | switch (ss) |
1128 | { | 1130 | { |