aboutsummaryrefslogtreecommitdiff
path: root/src/stasis/plugin_anastasis_postgres.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stasis/plugin_anastasis_postgres.c')
-rw-r--r--src/stasis/plugin_anastasis_postgres.c177
1 files changed, 86 insertions, 91 deletions
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 (
1072 const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub, 1072 const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
1073 const struct ANASTASIS_PaymentSecretP *payment_identifier, 1073 const struct ANASTASIS_PaymentSecretP *payment_identifier,
1074 struct GNUNET_TIME_Relative lifetime, 1074 struct GNUNET_TIME_Relative lifetime,
1075 struct GNUNET_TIME_Absolute *paid_until) 1075 struct GNUNET_TIME_Timestamp *paid_until)
1076{ 1076{
1077 struct PostgresClosure *pg = cls; 1077 struct PostgresClosure *pg = cls;
1078 enum GNUNET_DB_QueryStatus qs; 1078 enum GNUNET_DB_QueryStatus qs;
@@ -1101,7 +1101,7 @@ postgres_increment_lifetime (
1101 { 1101 {
1102 case GNUNET_DB_STATUS_HARD_ERROR: 1102 case GNUNET_DB_STATUS_HARD_ERROR:
1103 rollback (pg); 1103 rollback (pg);
1104 *paid_until = GNUNET_TIME_UNIT_ZERO_ABS; 1104 *paid_until = GNUNET_TIME_UNIT_ZERO_TS;
1105 return qs; 1105 return qs;
1106 case GNUNET_DB_STATUS_SOFT_ERROR: 1106 case GNUNET_DB_STATUS_SOFT_ERROR:
1107 goto retry; 1107 goto retry;
@@ -1120,10 +1120,10 @@ postgres_increment_lifetime (
1120 GNUNET_PQ_query_param_auto_from_type (account_pub), 1120 GNUNET_PQ_query_param_auto_from_type (account_pub),
1121 GNUNET_PQ_query_param_end 1121 GNUNET_PQ_query_param_end
1122 }; 1122 };
1123 struct GNUNET_TIME_Absolute expiration; 1123 struct GNUNET_TIME_Timestamp expiration;
1124 struct GNUNET_PQ_ResultSpec rs[] = { 1124 struct GNUNET_PQ_ResultSpec rs[] = {
1125 GNUNET_PQ_result_spec_absolute_time ("expiration_date", 1125 GNUNET_PQ_result_spec_timestamp ("expiration_date",
1126 &expiration), 1126 &expiration),
1127 GNUNET_PQ_result_spec_end 1127 GNUNET_PQ_result_spec_end
1128 }; 1128 };
1129 1129
@@ -1151,13 +1151,12 @@ postgres_increment_lifetime (
1151 /* user does not exist, create new one */ 1151 /* user does not exist, create new one */
1152 struct GNUNET_PQ_QueryParam params[] = { 1152 struct GNUNET_PQ_QueryParam params[] = {
1153 GNUNET_PQ_query_param_auto_from_type (account_pub), 1153 GNUNET_PQ_query_param_auto_from_type (account_pub),
1154 GNUNET_PQ_query_param_absolute_time (&expiration), 1154 GNUNET_PQ_query_param_timestamp (&expiration),
1155 GNUNET_PQ_query_param_end 1155 GNUNET_PQ_query_param_end
1156 }; 1156 };
1157 1157
1158 expiration = GNUNET_TIME_relative_to_absolute (lifetime); 1158 expiration = GNUNET_TIME_relative_to_timestamp (lifetime);
1159 GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != 1159 GNUNET_break (! GNUNET_TIME_absolute_is_never (expiration.abs_time));
1160 expiration.abs_value_us);
1161 *paid_until = expiration; 1160 *paid_until = expiration;
1162 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, 1161 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
1163 "user_insert", 1162 "user_insert",
@@ -1173,22 +1172,24 @@ postgres_increment_lifetime (
1173 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1172 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1174 "Payment existed, lifetime of account %s unchanged at %s\n", 1173 "Payment existed, lifetime of account %s unchanged at %s\n",
1175 TALER_B2S (account_pub), 1174 TALER_B2S (account_pub),
1176 GNUNET_STRINGS_absolute_time_to_string (*paid_until)); 1175 GNUNET_TIME_timestamp2s (*paid_until));
1177 return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; 1176 return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
1178 } 1177 }
1179 else 1178 else
1180 { 1179 {
1181 /* user exists, update expiration_date */ 1180 /* user exists, update expiration_date */
1182 struct GNUNET_PQ_QueryParam params[] = { 1181 struct GNUNET_PQ_QueryParam params[] = {
1183 GNUNET_PQ_query_param_absolute_time (&expiration), 1182 GNUNET_PQ_query_param_timestamp (&expiration),
1184 GNUNET_PQ_query_param_auto_from_type (account_pub), 1183 GNUNET_PQ_query_param_auto_from_type (account_pub),
1185 GNUNET_PQ_query_param_end 1184 GNUNET_PQ_query_param_end
1186 }; 1185 };
1187 1186
1188 expiration = GNUNET_TIME_absolute_add (expiration, 1187 expiration
1189 lifetime); 1188 = GNUNET_TIME_absolute_to_timestamp (
1190 GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != 1189 GNUNET_TIME_absolute_add (expiration.abs_time,
1191 expiration.abs_value_us); 1190 lifetime));
1191 GNUNET_break (! GNUNET_TIME_absolute_is_never (
1192 expiration.abs_time));
1192 *paid_until = expiration; 1193 *paid_until = expiration;
1193 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, 1194 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
1194 "user_update", 1195 "user_update",
@@ -1220,7 +1221,7 @@ postgres_increment_lifetime (
1220 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1221 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1221 "Incremented lifetime of account %s to %s\n", 1222 "Incremented lifetime of account %s to %s\n",
1222 TALER_B2S (account_pub), 1223 TALER_B2S (account_pub),
1223 GNUNET_STRINGS_absolute_time_to_string (*paid_until)); 1224 GNUNET_TIME_timestamp2s (*paid_until));
1224 return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; 1225 return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
1225retry: 1226retry:
1226 rollback (pg); 1227 rollback (pg);
@@ -1244,7 +1245,7 @@ postgres_update_lifetime (
1244 void *cls, 1245 void *cls,
1245 const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub, 1246 const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
1246 const struct ANASTASIS_PaymentSecretP *payment_identifier, 1247 const struct ANASTASIS_PaymentSecretP *payment_identifier,
1247 struct GNUNET_TIME_Absolute eol) 1248 struct GNUNET_TIME_Timestamp eol)
1248{ 1249{
1249 struct PostgresClosure *pg = cls; 1250 struct PostgresClosure *pg = cls;
1250 enum GNUNET_DB_QueryStatus qs; 1251 enum GNUNET_DB_QueryStatus qs;
@@ -1288,10 +1289,10 @@ postgres_update_lifetime (
1288 GNUNET_PQ_query_param_auto_from_type (account_pub), 1289 GNUNET_PQ_query_param_auto_from_type (account_pub),
1289 GNUNET_PQ_query_param_end 1290 GNUNET_PQ_query_param_end
1290 }; 1291 };
1291 struct GNUNET_TIME_Absolute expiration; 1292 struct GNUNET_TIME_Timestamp expiration;
1292 struct GNUNET_PQ_ResultSpec rs[] = { 1293 struct GNUNET_PQ_ResultSpec rs[] = {
1293 GNUNET_PQ_result_spec_absolute_time ("expiration_date", 1294 GNUNET_PQ_result_spec_timestamp ("expiration_date",
1294 &expiration), 1295 &expiration),
1295 GNUNET_PQ_result_spec_end 1296 GNUNET_PQ_result_spec_end
1296 }; 1297 };
1297 1298
@@ -1311,41 +1312,39 @@ postgres_update_lifetime (
1311 /* user does not exist, create new one */ 1312 /* user does not exist, create new one */
1312 struct GNUNET_PQ_QueryParam params[] = { 1313 struct GNUNET_PQ_QueryParam params[] = {
1313 GNUNET_PQ_query_param_auto_from_type (account_pub), 1314 GNUNET_PQ_query_param_auto_from_type (account_pub),
1314 GNUNET_PQ_query_param_absolute_time (&eol), 1315 GNUNET_PQ_query_param_timestamp (&eol),
1315 GNUNET_PQ_query_param_end 1316 GNUNET_PQ_query_param_end
1316 }; 1317 };
1317 1318
1318 GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != 1319 GNUNET_break (! GNUNET_TIME_absolute_is_never (eol.abs_time));
1319 eol.abs_value_us);
1320 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, 1320 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
1321 "user_insert", 1321 "user_insert",
1322 params); 1322 params);
1323 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1323 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1324 "Created new account %s with expiration %s\n", 1324 "Created new account %s with expiration %s\n",
1325 TALER_B2S (account_pub), 1325 TALER_B2S (account_pub),
1326 GNUNET_STRINGS_absolute_time_to_string (eol)); 1326 GNUNET_TIME_timestamp2s (eol));
1327 } 1327 }
1328 break; 1328 break;
1329 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 1329 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
1330 { 1330 {
1331 /* user exists, update expiration_date */ 1331 /* user exists, update expiration_date */
1332 struct GNUNET_PQ_QueryParam params[] = { 1332 struct GNUNET_PQ_QueryParam params[] = {
1333 GNUNET_PQ_query_param_absolute_time (&expiration), 1333 GNUNET_PQ_query_param_timestamp (&expiration),
1334 GNUNET_PQ_query_param_auto_from_type (account_pub), 1334 GNUNET_PQ_query_param_auto_from_type (account_pub),
1335 GNUNET_PQ_query_param_end 1335 GNUNET_PQ_query_param_end
1336 }; 1336 };
1337 1337
1338 expiration = GNUNET_TIME_absolute_max (expiration, 1338 expiration = GNUNET_TIME_timestamp_max (expiration,
1339 eol); 1339 eol);
1340 GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != 1340 GNUNET_break (! GNUNET_TIME_absolute_is_never (expiration.abs_time));
1341 expiration.abs_value_us);
1342 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, 1341 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
1343 "user_update", 1342 "user_update",
1344 params); 1343 params);
1345 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1344 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1346 "Updated account %s to new expiration %s\n", 1345 "Updated account %s to new expiration %s\n",
1347 TALER_B2S (account_pub), 1346 TALER_B2S (account_pub),
1348 GNUNET_STRINGS_absolute_time_to_string (expiration)); 1347 GNUNET_TIME_timestamp2s (expiration));
1349 } 1348 }
1350 break; 1349 break;
1351 } 1350 }
@@ -1399,14 +1398,14 @@ postgres_record_recdoc_payment (
1399 const struct TALER_Amount *amount) 1398 const struct TALER_Amount *amount)
1400{ 1399{
1401 struct PostgresClosure *pg = cls; 1400 struct PostgresClosure *pg = cls;
1402 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 1401 struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
1403 struct GNUNET_TIME_Absolute expiration; 1402 struct GNUNET_TIME_Timestamp expiration;
1404 struct GNUNET_PQ_QueryParam params[] = { 1403 struct GNUNET_PQ_QueryParam params[] = {
1405 GNUNET_PQ_query_param_auto_from_type (account_pub), 1404 GNUNET_PQ_query_param_auto_from_type (account_pub),
1406 GNUNET_PQ_query_param_uint32 (&post_counter), 1405 GNUNET_PQ_query_param_uint32 (&post_counter),
1407 TALER_PQ_query_param_amount (amount), 1406 TALER_PQ_query_param_amount (amount),
1408 GNUNET_PQ_query_param_auto_from_type (payment_secret), 1407 GNUNET_PQ_query_param_auto_from_type (payment_secret),
1409 GNUNET_PQ_query_param_absolute_time (&now), 1408 GNUNET_PQ_query_param_timestamp (&now),
1410 GNUNET_PQ_query_param_end 1409 GNUNET_PQ_query_param_end
1411 }; 1410 };
1412 enum GNUNET_DB_QueryStatus qs; 1411 enum GNUNET_DB_QueryStatus qs;
@@ -1423,8 +1422,8 @@ postgres_record_recdoc_payment (
1423 GNUNET_PQ_query_param_end 1422 GNUNET_PQ_query_param_end
1424 }; 1423 };
1425 struct GNUNET_PQ_ResultSpec rs[] = { 1424 struct GNUNET_PQ_ResultSpec rs[] = {
1426 GNUNET_PQ_result_spec_absolute_time ("expiration_date", 1425 GNUNET_PQ_result_spec_timestamp ("expiration_date",
1427 &expiration), 1426 &expiration),
1428 GNUNET_PQ_result_spec_end 1427 GNUNET_PQ_result_spec_end
1429 }; 1428 };
1430 1429
@@ -1443,11 +1442,11 @@ postgres_record_recdoc_payment (
1443 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 1442 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
1444 { 1443 {
1445 /* create new user with short lifetime */ 1444 /* create new user with short lifetime */
1446 struct GNUNET_TIME_Absolute exp 1445 struct GNUNET_TIME_Timestamp exp
1447 = GNUNET_TIME_relative_to_absolute (TRANSIENT_LIFETIME); 1446 = GNUNET_TIME_relative_to_timestamp (TRANSIENT_LIFETIME);
1448 struct GNUNET_PQ_QueryParam params[] = { 1447 struct GNUNET_PQ_QueryParam params[] = {
1449 GNUNET_PQ_query_param_auto_from_type (account_pub), 1448 GNUNET_PQ_query_param_auto_from_type (account_pub),
1450 GNUNET_PQ_query_param_absolute_time (&exp), 1449 GNUNET_PQ_query_param_timestamp (&exp),
1451 GNUNET_PQ_query_param_end 1450 GNUNET_PQ_query_param_end
1452 }; 1451 };
1453 1452
@@ -1469,7 +1468,7 @@ postgres_record_recdoc_payment (
1469 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1468 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1470 "Created new account %s with transient life until %s\n", 1469 "Created new account %s with transient life until %s\n",
1471 TALER_B2S (account_pub), 1470 TALER_B2S (account_pub),
1472 GNUNET_STRINGS_absolute_time_to_string (exp)); 1471 GNUNET_TIME_timestamp2s (exp));
1473 break; 1472 break;
1474 } 1473 }
1475 } 1474 }
@@ -1503,11 +1502,12 @@ postgres_record_truth_upload_payment (
1503 struct GNUNET_TIME_Relative duration) 1502 struct GNUNET_TIME_Relative duration)
1504{ 1503{
1505 struct PostgresClosure *pg = cls; 1504 struct PostgresClosure *pg = cls;
1506 struct GNUNET_TIME_Absolute exp = GNUNET_TIME_relative_to_absolute (duration); 1505 struct GNUNET_TIME_Timestamp exp = GNUNET_TIME_relative_to_timestamp (
1506 duration);
1507 struct GNUNET_PQ_QueryParam params[] = { 1507 struct GNUNET_PQ_QueryParam params[] = {
1508 GNUNET_PQ_query_param_auto_from_type (uuid), 1508 GNUNET_PQ_query_param_auto_from_type (uuid),
1509 TALER_PQ_query_param_amount (amount), 1509 TALER_PQ_query_param_amount (amount),
1510 GNUNET_PQ_query_param_absolute_time (&exp), 1510 GNUNET_PQ_query_param_timestamp (&exp),
1511 GNUNET_PQ_query_param_end 1511 GNUNET_PQ_query_param_end
1512 }; 1512 };
1513 1513
@@ -1530,18 +1530,18 @@ static enum GNUNET_DB_QueryStatus
1530postgres_check_truth_upload_paid ( 1530postgres_check_truth_upload_paid (
1531 void *cls, 1531 void *cls,
1532 const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid, 1532 const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid,
1533 struct GNUNET_TIME_Absolute *paid_until) 1533 struct GNUNET_TIME_Timestamp *paid_until)
1534{ 1534{
1535 struct PostgresClosure *pg = cls; 1535 struct PostgresClosure *pg = cls;
1536 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 1536 struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
1537 struct GNUNET_PQ_QueryParam params[] = { 1537 struct GNUNET_PQ_QueryParam params[] = {
1538 GNUNET_PQ_query_param_auto_from_type (uuid), 1538 GNUNET_PQ_query_param_auto_from_type (uuid),
1539 GNUNET_PQ_query_param_absolute_time (&now), 1539 GNUNET_PQ_query_param_timestamp (&now),
1540 GNUNET_PQ_query_param_end 1540 GNUNET_PQ_query_param_end
1541 }; 1541 };
1542 struct GNUNET_PQ_ResultSpec rs[] = { 1542 struct GNUNET_PQ_ResultSpec rs[] = {
1543 GNUNET_PQ_result_spec_absolute_time ("expiration", 1543 GNUNET_PQ_result_spec_timestamp ("expiration",
1544 paid_until), 1544 paid_until),
1545 GNUNET_PQ_result_spec_end 1545 GNUNET_PQ_result_spec_end
1546 }; 1546 };
1547 1547
@@ -1570,12 +1570,12 @@ postgres_record_challenge_payment (
1570 const struct TALER_Amount *amount) 1570 const struct TALER_Amount *amount)
1571{ 1571{
1572 struct PostgresClosure *pg = cls; 1572 struct PostgresClosure *pg = cls;
1573 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 1573 struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
1574 struct GNUNET_PQ_QueryParam params[] = { 1574 struct GNUNET_PQ_QueryParam params[] = {
1575 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 1575 GNUNET_PQ_query_param_auto_from_type (truth_uuid),
1576 TALER_PQ_query_param_amount (amount), 1576 TALER_PQ_query_param_amount (amount),
1577 GNUNET_PQ_query_param_auto_from_type (payment_secret), 1577 GNUNET_PQ_query_param_auto_from_type (payment_secret),
1578 GNUNET_PQ_query_param_absolute_time (&now), 1578 GNUNET_PQ_query_param_timestamp (&now),
1579 GNUNET_PQ_query_param_end 1579 GNUNET_PQ_query_param_end
1580 }; 1580 };
1581 1581
@@ -1634,7 +1634,7 @@ postgres_record_auth_iban_payment (
1634 const struct TALER_Amount *amount, 1634 const struct TALER_Amount *amount,
1635 const char *debit_account, 1635 const char *debit_account,
1636 const char *credit_account, 1636 const char *credit_account,
1637 struct GNUNET_TIME_Absolute execution_date) 1637 struct GNUNET_TIME_Timestamp execution_date)
1638{ 1638{
1639 struct PostgresClosure *pg = cls; 1639 struct PostgresClosure *pg = cls;
1640 struct GNUNET_PQ_QueryParam params[] = { 1640 struct GNUNET_PQ_QueryParam params[] = {
@@ -1643,7 +1643,7 @@ postgres_record_auth_iban_payment (
1643 TALER_PQ_query_param_amount (amount), 1643 TALER_PQ_query_param_amount (amount),
1644 GNUNET_PQ_query_param_string (debit_account), 1644 GNUNET_PQ_query_param_string (debit_account),
1645 GNUNET_PQ_query_param_string (credit_account), 1645 GNUNET_PQ_query_param_string (credit_account),
1646 GNUNET_PQ_query_param_absolute_time (&execution_date), 1646 GNUNET_PQ_query_param_timestamp (&execution_date),
1647 GNUNET_PQ_query_param_end 1647 GNUNET_PQ_query_param_end
1648 }; 1648 };
1649 1649
@@ -1753,7 +1753,7 @@ static enum GNUNET_DB_QueryStatus
1753postgres_test_auth_iban_payment ( 1753postgres_test_auth_iban_payment (
1754 void *cls, 1754 void *cls,
1755 const char *debit_account, 1755 const char *debit_account,
1756 struct GNUNET_TIME_Absolute earliest_date, 1756 struct GNUNET_TIME_Timestamp earliest_date,
1757 ANASTASIS_DB_AuthIbanTransfercheck cb, 1757 ANASTASIS_DB_AuthIbanTransfercheck cb,
1758 void *cb_cls) 1758 void *cb_cls)
1759{ 1759{
@@ -1765,7 +1765,7 @@ postgres_test_auth_iban_payment (
1765 }; 1765 };
1766 struct GNUNET_PQ_QueryParam params[] = { 1766 struct GNUNET_PQ_QueryParam params[] = {
1767 GNUNET_PQ_query_param_string (debit_account), 1767 GNUNET_PQ_query_param_string (debit_account),
1768 TALER_PQ_query_param_absolute_time (&earliest_date), 1768 GNUNET_PQ_query_param_timestamp (&earliest_date),
1769 GNUNET_PQ_query_param_end 1769 GNUNET_PQ_query_param_end
1770 }; 1770 };
1771 enum GNUNET_DB_QueryStatus qs; 1771 enum GNUNET_DB_QueryStatus qs;
@@ -1936,7 +1936,7 @@ postgres_store_truth (
1936 struct GNUNET_TIME_Relative truth_expiration) 1936 struct GNUNET_TIME_Relative truth_expiration)
1937{ 1937{
1938 struct PostgresClosure *pg = cls; 1938 struct PostgresClosure *pg = cls;
1939 struct GNUNET_TIME_Absolute expiration = GNUNET_TIME_absolute_get (); 1939 struct GNUNET_TIME_Timestamp expiration;
1940 struct GNUNET_PQ_QueryParam params[] = { 1940 struct GNUNET_PQ_QueryParam params[] = {
1941 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 1941 GNUNET_PQ_query_param_auto_from_type (truth_uuid),
1942 GNUNET_PQ_query_param_auto_from_type (key_share_data), 1942 GNUNET_PQ_query_param_auto_from_type (key_share_data),
@@ -1944,14 +1944,12 @@ postgres_store_truth (
1944 GNUNET_PQ_query_param_fixed_size (encrypted_truth, 1944 GNUNET_PQ_query_param_fixed_size (encrypted_truth,
1945 encrypted_truth_size), 1945 encrypted_truth_size),
1946 GNUNET_PQ_query_param_string (mime_type), 1946 GNUNET_PQ_query_param_string (mime_type),
1947 TALER_PQ_query_param_absolute_time (&expiration), 1947 GNUNET_PQ_query_param_timestamp (&expiration),
1948 GNUNET_PQ_query_param_end 1948 GNUNET_PQ_query_param_end
1949 }; 1949 };
1950 1950
1951 1951
1952 expiration = GNUNET_TIME_absolute_add (expiration, 1952 expiration = GNUNET_TIME_relative_to_timestamp (truth_expiration);
1953 truth_expiration);
1954 GNUNET_TIME_round_abs (&expiration);
1955 check_connection (pg); 1953 check_connection (pg);
1956 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1954 return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1957 "truth_insert", 1955 "truth_insert",
@@ -2051,7 +2049,7 @@ enum ANASTASIS_DB_AccountStatus
2051postgres_lookup_account ( 2049postgres_lookup_account (
2052 void *cls, 2050 void *cls,
2053 const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub, 2051 const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
2054 struct GNUNET_TIME_Absolute *paid_until, 2052 struct GNUNET_TIME_Timestamp *paid_until,
2055 struct GNUNET_HashCode *recovery_data_hash, 2053 struct GNUNET_HashCode *recovery_data_hash,
2056 uint32_t *version) 2054 uint32_t *version)
2057{ 2055{
@@ -2067,8 +2065,8 @@ postgres_lookup_account (
2067 postgres_preflight (pg)); 2065 postgres_preflight (pg));
2068 { 2066 {
2069 struct GNUNET_PQ_ResultSpec rs[] = { 2067 struct GNUNET_PQ_ResultSpec rs[] = {
2070 GNUNET_PQ_result_spec_absolute_time ("expiration_date", 2068 GNUNET_PQ_result_spec_timestamp ("expiration_date",
2071 paid_until), 2069 paid_until),
2072 GNUNET_PQ_result_spec_auto_from_type ("recovery_data_hash", 2070 GNUNET_PQ_result_spec_auto_from_type ("recovery_data_hash",
2073 recovery_data_hash), 2071 recovery_data_hash),
2074 GNUNET_PQ_result_spec_uint32 ("version", 2072 GNUNET_PQ_result_spec_uint32 ("version",
@@ -2097,8 +2095,8 @@ postgres_lookup_account (
2097 /* check if account exists */ 2095 /* check if account exists */
2098 { 2096 {
2099 struct GNUNET_PQ_ResultSpec rs[] = { 2097 struct GNUNET_PQ_ResultSpec rs[] = {
2100 GNUNET_PQ_result_spec_absolute_time ("expiration_date", 2098 GNUNET_PQ_result_spec_timestamp ("expiration_date",
2101 paid_until), 2099 paid_until),
2102 GNUNET_PQ_result_spec_end 2100 GNUNET_PQ_result_spec_end
2103 }; 2101 };
2104 2102
@@ -2372,17 +2370,16 @@ postgres_verify_challenge_code (
2372 .hashed_code = hashed_code, 2370 .hashed_code = hashed_code,
2373 .pg = pg 2371 .pg = pg
2374 }; 2372 };
2375 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 2373 struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
2376 struct GNUNET_PQ_QueryParam params[] = { 2374 struct GNUNET_PQ_QueryParam params[] = {
2377 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 2375 GNUNET_PQ_query_param_auto_from_type (truth_uuid),
2378 TALER_PQ_query_param_absolute_time (&now), 2376 GNUNET_PQ_query_param_timestamp (&now),
2379 GNUNET_PQ_query_param_end 2377 GNUNET_PQ_query_param_end
2380 }; 2378 };
2381 enum GNUNET_DB_QueryStatus qs; 2379 enum GNUNET_DB_QueryStatus qs;
2382 2380
2383 *satisfied = false; 2381 *satisfied = false;
2384 check_connection (pg); 2382 check_connection (pg);
2385 GNUNET_TIME_round_abs (&now);
2386 qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, 2383 qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
2387 "challengecode_select", 2384 "challengecode_select",
2388 params, 2385 params,
@@ -2447,13 +2444,13 @@ postgres_test_challenge_code_satisfied (
2447 void *cls, 2444 void *cls,
2448 const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid, 2445 const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
2449 const uint64_t code, 2446 const uint64_t code,
2450 struct GNUNET_TIME_Absolute after) 2447 struct GNUNET_TIME_Timestamp after)
2451{ 2448{
2452 struct PostgresClosure *pg = cls; 2449 struct PostgresClosure *pg = cls;
2453 struct GNUNET_PQ_QueryParam params[] = { 2450 struct GNUNET_PQ_QueryParam params[] = {
2454 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 2451 GNUNET_PQ_query_param_auto_from_type (truth_uuid),
2455 GNUNET_PQ_query_param_uint64 (&code), 2452 GNUNET_PQ_query_param_uint64 (&code),
2456 GNUNET_PQ_query_param_absolute_time (&after), 2453 GNUNET_PQ_query_param_timestamp (&after),
2457 GNUNET_PQ_query_param_end 2454 GNUNET_PQ_query_param_end
2458 }; 2455 };
2459 struct GNUNET_PQ_ResultSpec rs[] = { 2456 struct GNUNET_PQ_ResultSpec rs[] = {
@@ -2483,12 +2480,13 @@ postgres_lookup_challenge_payment (
2483{ 2480{
2484 struct PostgresClosure *pg = cls; 2481 struct PostgresClosure *pg = cls;
2485 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 2482 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
2486 struct GNUNET_TIME_Absolute recent 2483 struct GNUNET_TIME_Timestamp recent
2487 = GNUNET_TIME_absolute_subtract (now, 2484 = GNUNET_TIME_absolute_to_timestamp (
2488 ANASTASIS_CHALLENGE_OFFER_LIFETIME); 2485 GNUNET_TIME_absolute_subtract (now,
2486 ANASTASIS_CHALLENGE_OFFER_LIFETIME));
2489 struct GNUNET_PQ_QueryParam params[] = { 2487 struct GNUNET_PQ_QueryParam params[] = {
2490 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 2488 GNUNET_PQ_query_param_auto_from_type (truth_uuid),
2491 GNUNET_PQ_query_param_absolute_time (&recent), 2489 GNUNET_PQ_query_param_timestamp (&recent),
2492 GNUNET_PQ_query_param_end 2490 GNUNET_PQ_query_param_end
2493 }; 2491 };
2494 struct GNUNET_PQ_ResultSpec rs[] = { 2492 struct GNUNET_PQ_ResultSpec rs[] = {
@@ -2555,20 +2553,18 @@ postgres_create_challenge_code (
2555 struct GNUNET_TIME_Relative rotation_period, 2553 struct GNUNET_TIME_Relative rotation_period,
2556 struct GNUNET_TIME_Relative validity_period, 2554 struct GNUNET_TIME_Relative validity_period,
2557 uint32_t retry_counter, 2555 uint32_t retry_counter,
2558 struct GNUNET_TIME_Absolute *retransmission_date, 2556 struct GNUNET_TIME_Timestamp *retransmission_date,
2559 uint64_t *code) 2557 uint64_t *code)
2560{ 2558{
2561 struct PostgresClosure *pg = cls; 2559 struct PostgresClosure *pg = cls;
2562 enum GNUNET_DB_QueryStatus qs; 2560 enum GNUNET_DB_QueryStatus qs;
2563 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 2561 struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
2564 struct GNUNET_TIME_Absolute expiration_date; 2562 struct GNUNET_TIME_Timestamp expiration_date;
2565 struct GNUNET_TIME_Absolute ex_rot; 2563 struct GNUNET_TIME_Absolute ex_rot;
2566 2564
2567 check_connection (pg); 2565 check_connection (pg);
2568 GNUNET_TIME_round_abs (&now); 2566 expiration_date = GNUNET_TIME_relative_to_timestamp (validity_period);
2569 expiration_date = GNUNET_TIME_absolute_add (now, 2567 ex_rot = GNUNET_TIME_absolute_subtract (now.abs_time,
2570 validity_period);
2571 ex_rot = GNUNET_TIME_absolute_subtract (now,
2572 rotation_period); 2568 rotation_period);
2573 for (unsigned int retries = 0; retries<MAX_RETRIES; retries++) 2569 for (unsigned int retries = 0; retries<MAX_RETRIES; retries++)
2574 { 2570 {
@@ -2584,8 +2580,8 @@ postgres_create_challenge_code (
2584 uint32_t old_retry_counter; 2580 uint32_t old_retry_counter;
2585 struct GNUNET_PQ_QueryParam params[] = { 2581 struct GNUNET_PQ_QueryParam params[] = {
2586 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 2582 GNUNET_PQ_query_param_auto_from_type (truth_uuid),
2587 TALER_PQ_query_param_absolute_time (&now), 2583 GNUNET_PQ_query_param_timestamp (&now),
2588 TALER_PQ_query_param_absolute_time (&ex_rot), 2584 GNUNET_PQ_query_param_absolute_time (&ex_rot),
2589 GNUNET_PQ_query_param_end 2585 GNUNET_PQ_query_param_end
2590 }; 2586 };
2591 struct GNUNET_PQ_ResultSpec rs[] = { 2587 struct GNUNET_PQ_ResultSpec rs[] = {
@@ -2593,8 +2589,8 @@ postgres_create_challenge_code (
2593 code), 2589 code),
2594 GNUNET_PQ_result_spec_uint32 ("retry_counter", 2590 GNUNET_PQ_result_spec_uint32 ("retry_counter",
2595 &old_retry_counter), 2591 &old_retry_counter),
2596 GNUNET_PQ_result_spec_absolute_time ("retransmission_date", 2592 GNUNET_PQ_result_spec_timestamp ("retransmission_date",
2597 retransmission_date), 2593 retransmission_date),
2598 GNUNET_PQ_result_spec_end 2594 GNUNET_PQ_result_spec_end
2599 }; 2595 };
2600 enum GNUNET_DB_QueryStatus qs; 2596 enum GNUNET_DB_QueryStatus qs;
@@ -2634,13 +2630,13 @@ postgres_create_challenge_code (
2634 2630
2635 *code = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE, 2631 *code = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE,
2636 NONCE_MAX_VALUE); 2632 NONCE_MAX_VALUE);
2637 *retransmission_date = GNUNET_TIME_UNIT_ZERO_ABS; 2633 *retransmission_date = GNUNET_TIME_UNIT_ZERO_TS;
2638 { 2634 {
2639 struct GNUNET_PQ_QueryParam params[] = { 2635 struct GNUNET_PQ_QueryParam params[] = {
2640 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 2636 GNUNET_PQ_query_param_auto_from_type (truth_uuid),
2641 GNUNET_PQ_query_param_uint64 (code), 2637 GNUNET_PQ_query_param_uint64 (code),
2642 TALER_PQ_query_param_absolute_time (&now), 2638 GNUNET_PQ_query_param_timestamp (&now),
2643 TALER_PQ_query_param_absolute_time (&expiration_date), 2639 GNUNET_PQ_query_param_timestamp (&expiration_date),
2644 GNUNET_PQ_query_param_uint32 (&retry_counter), 2640 GNUNET_PQ_query_param_uint32 (&retry_counter),
2645 GNUNET_PQ_query_param_end 2641 GNUNET_PQ_query_param_end
2646 }; 2642 };
@@ -2699,16 +2695,15 @@ postgres_mark_challenge_sent (
2699 2695
2700 check_connection (pg); 2696 check_connection (pg);
2701 { 2697 {
2702 struct GNUNET_TIME_Absolute now; 2698 struct GNUNET_TIME_Timestamp now;
2703 struct GNUNET_PQ_QueryParam params[] = { 2699 struct GNUNET_PQ_QueryParam params[] = {
2704 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 2700 GNUNET_PQ_query_param_auto_from_type (truth_uuid),
2705 GNUNET_PQ_query_param_uint64 (&code), 2701 GNUNET_PQ_query_param_uint64 (&code),
2706 TALER_PQ_query_param_absolute_time (&now), 2702 GNUNET_PQ_query_param_timestamp (&now),
2707 GNUNET_PQ_query_param_end 2703 GNUNET_PQ_query_param_end
2708 }; 2704 };
2709 2705
2710 now = GNUNET_TIME_absolute_get (); 2706 now = GNUNET_TIME_timestamp_get ();
2711 GNUNET_TIME_round_abs (&now);
2712 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, 2707 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
2713 "challengecode_mark_sent", 2708 "challengecode_mark_sent",
2714 params); 2709 params);
@@ -2741,9 +2736,9 @@ enum GNUNET_DB_QueryStatus
2741postgres_challenge_gc (void *cls) 2736postgres_challenge_gc (void *cls)
2742{ 2737{
2743 struct PostgresClosure *pg = cls; 2738 struct PostgresClosure *pg = cls;
2744 struct GNUNET_TIME_Absolute time_now = GNUNET_TIME_absolute_get (); 2739 struct GNUNET_TIME_Timestamp time_now = GNUNET_TIME_timestamp_get ();
2745 struct GNUNET_PQ_QueryParam params[] = { 2740 struct GNUNET_PQ_QueryParam params[] = {
2746 GNUNET_PQ_query_param_absolute_time (&time_now), 2741 GNUNET_PQ_query_param_timestamp (&time_now),
2747 GNUNET_PQ_query_param_end 2742 GNUNET_PQ_query_param_end
2748 }; 2743 };
2749 2744