summaryrefslogtreecommitdiff
path: root/src/auditordb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-11-30 17:17:37 +0100
committerChristian Grothoff <christian@grothoff.org>2017-11-30 17:17:37 +0100
commit5540747ca2e5f37f2df504d689b850d1078fcdc5 (patch)
tree0e8be904bdedfe74a7cf78e1c27f7edc614c6301 /src/auditordb
parent78b77ee8d515c80ac85ca7af59e3e82c2baaeb68 (diff)
downloadexchange-5540747ca2e5f37f2df504d689b850d1078fcdc5.tar.gz
exchange-5540747ca2e5f37f2df504d689b850d1078fcdc5.tar.bz2
exchange-5540747ca2e5f37f2df504d689b850d1078fcdc5.zip
patch to address #5183: always round time before giving it to DB, tolerate DB answering without rounded time
Diffstat (limited to 'src/auditordb')
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c46
-rw-r--r--src/auditordb/test_auditordb.c3
2 files changed, 25 insertions, 24 deletions
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index b699a76f..2f881ae2 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -1014,7 +1014,7 @@ postgres_gc (void *cls)
struct PostgresClosure *pc = cls;
struct GNUNET_TIME_Absolute now;
struct GNUNET_PQ_QueryParam params_time[] = {
- GNUNET_PQ_query_param_absolute_time (&now),
+ TALER_PQ_query_param_absolute_time (&now),
GNUNET_PQ_query_param_end
};
PGconn *conn;
@@ -1063,10 +1063,10 @@ postgres_insert_denomination_info (void *cls,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (&issue->denom_hash),
GNUNET_PQ_query_param_auto_from_type (&issue->master),
- GNUNET_PQ_query_param_absolute_time_nbo (&issue->start),
- GNUNET_PQ_query_param_absolute_time_nbo (&issue->expire_withdraw),
- GNUNET_PQ_query_param_absolute_time_nbo (&issue->expire_deposit),
- GNUNET_PQ_query_param_absolute_time_nbo (&issue->expire_legal),
+ TALER_PQ_query_param_absolute_time_nbo (&issue->start),
+ TALER_PQ_query_param_absolute_time_nbo (&issue->expire_withdraw),
+ TALER_PQ_query_param_absolute_time_nbo (&issue->expire_deposit),
+ TALER_PQ_query_param_absolute_time_nbo (&issue->expire_legal),
TALER_PQ_query_param_amount_nbo (&issue->value),
TALER_PQ_query_param_amount_nbo (&issue->fee_withdraw),
TALER_PQ_query_param_amount_nbo (&issue->fee_deposit),
@@ -1145,10 +1145,10 @@ denomination_info_cb (void *cls,
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &issue.denom_hash),
- GNUNET_PQ_result_spec_absolute_time_nbo ("valid_from", &issue.start),
- GNUNET_PQ_result_spec_absolute_time_nbo ("expire_withdraw", &issue.expire_withdraw),
- GNUNET_PQ_result_spec_absolute_time_nbo ("expire_deposit", &issue.expire_deposit),
- GNUNET_PQ_result_spec_absolute_time_nbo ("expire_legal", &issue.expire_legal),
+ TALER_PQ_result_spec_absolute_time_nbo ("valid_from", &issue.start),
+ TALER_PQ_result_spec_absolute_time_nbo ("expire_withdraw", &issue.expire_withdraw),
+ TALER_PQ_result_spec_absolute_time_nbo ("expire_deposit", &issue.expire_deposit),
+ TALER_PQ_result_spec_absolute_time_nbo ("expire_legal", &issue.expire_legal),
TALER_PQ_result_spec_amount_nbo ("coin", &issue.value),
TALER_PQ_result_spec_amount_nbo ("fee_withdraw", &issue.fee_withdraw),
TALER_PQ_result_spec_amount_nbo ("fee_deposit", &issue.fee_deposit),
@@ -1358,7 +1358,7 @@ postgres_insert_wire_auditor_progress (void *cls,
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),
- GNUNET_PQ_query_param_absolute_time (&pp->last_timestamp),
+ TALER_PQ_query_param_absolute_time (&pp->last_timestamp),
GNUNET_PQ_query_param_fixed_size (in_wire_off,
wire_off_size),
GNUNET_PQ_query_param_fixed_size (out_wire_off,
@@ -1394,7 +1394,7 @@ postgres_update_wire_auditor_progress (void *cls,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),
- GNUNET_PQ_query_param_absolute_time (&pp->last_timestamp),
+ TALER_PQ_query_param_absolute_time (&pp->last_timestamp),
GNUNET_PQ_query_param_fixed_size (in_wire_off,
wire_off_size),
GNUNET_PQ_query_param_fixed_size (out_wire_off,
@@ -1438,7 +1438,7 @@ postgres_get_wire_auditor_progress (void *cls,
&pp->last_reserve_in_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_wire_wire_out_serial_id",
&pp->last_wire_out_serial_id),
- GNUNET_PQ_result_spec_absolute_time ("last_timestamp",
+ TALER_PQ_result_spec_absolute_time ("last_timestamp",
&pp->last_timestamp),
GNUNET_PQ_result_spec_variable_size ("wire_in_off",
in_wire_off,
@@ -1491,7 +1491,7 @@ postgres_insert_reserve_info (void *cls,
GNUNET_PQ_query_param_auto_from_type (master_pub),
TALER_PQ_query_param_amount (reserve_balance),
TALER_PQ_query_param_amount (withdraw_fee_balance),
- GNUNET_PQ_query_param_absolute_time (&expiration_date),
+ TALER_PQ_query_param_absolute_time (&expiration_date),
GNUNET_PQ_query_param_end
};
@@ -1531,7 +1531,7 @@ postgres_update_reserve_info (void *cls,
struct GNUNET_PQ_QueryParam params[] = {
TALER_PQ_query_param_amount (reserve_balance),
TALER_PQ_query_param_amount (withdraw_fee_balance),
- GNUNET_PQ_query_param_absolute_time (&expiration_date),
+ TALER_PQ_query_param_absolute_time (&expiration_date),
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
@@ -1606,7 +1606,7 @@ postgres_get_reserve_info (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
TALER_PQ_result_spec_amount ("reserve_balance", reserve_balance),
TALER_PQ_result_spec_amount ("withdraw_fee_balance", withdraw_fee_balance),
- GNUNET_PQ_result_spec_absolute_time ("expiration_date", expiration_date),
+ TALER_PQ_result_spec_absolute_time ("expiration_date", expiration_date),
GNUNET_PQ_result_spec_uint64 ("auditor_reserves_rowid", rowid),
GNUNET_PQ_result_spec_end
};
@@ -2066,7 +2066,7 @@ postgres_insert_historic_denom_revenue (void *cls,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
- GNUNET_PQ_query_param_absolute_time (&revenue_timestamp),
+ TALER_PQ_query_param_absolute_time (&revenue_timestamp),
TALER_PQ_query_param_amount (revenue_balance),
GNUNET_PQ_query_param_end
};
@@ -2122,7 +2122,7 @@ historic_denom_revenue_cb (void *cls,
struct TALER_Amount revenue_balance;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &denom_pub_hash),
- GNUNET_PQ_result_spec_absolute_time ("revenue_timestamp", &revenue_timestamp),
+ TALER_PQ_result_spec_absolute_time ("revenue_timestamp", &revenue_timestamp),
TALER_PQ_result_spec_amount ("revenue_balance", &revenue_balance),
GNUNET_PQ_result_spec_end
};
@@ -2213,7 +2213,7 @@ postgres_insert_historic_losses (void *cls,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
- GNUNET_PQ_query_param_absolute_time (&loss_timestamp),
+ TALER_PQ_query_param_absolute_time (&loss_timestamp),
TALER_PQ_query_param_amount (loss_balance),
GNUNET_PQ_query_param_end
};
@@ -2269,7 +2269,7 @@ losses_cb (void *cls,
struct TALER_Amount loss_balance;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &denom_pub_hash),
- GNUNET_PQ_result_spec_absolute_time ("loss_timestamp", &loss_timestamp),
+ TALER_PQ_result_spec_absolute_time ("loss_timestamp", &loss_timestamp),
TALER_PQ_result_spec_amount ("loss_balance", &loss_balance),
GNUNET_PQ_result_spec_end
};
@@ -2354,8 +2354,8 @@ postgres_insert_historic_reserve_revenue (void *cls,
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_absolute_time (&start_time),
- GNUNET_PQ_query_param_absolute_time (&end_time),
+ TALER_PQ_query_param_absolute_time (&start_time),
+ TALER_PQ_query_param_absolute_time (&end_time),
TALER_PQ_query_param_amount (reserve_profits),
GNUNET_PQ_query_param_end
};
@@ -2410,8 +2410,8 @@ historic_reserve_revenue_cb (void *cls,
struct GNUNET_TIME_Absolute end_date;
struct TALER_Amount reserve_profits;
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_absolute_time ("start_date", &start_date),
- GNUNET_PQ_result_spec_absolute_time ("end_date", &end_date),
+ TALER_PQ_result_spec_absolute_time ("start_date", &start_date),
+ TALER_PQ_result_spec_absolute_time ("end_date", &end_date),
TALER_PQ_result_spec_amount ("reserve_profits", &reserve_profits),
GNUNET_PQ_result_spec_end
};
diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c
index 04c6d23b..a5e8ba71 100644
--- a/src/auditordb/test_auditordb.c
+++ b/src/auditordb/test_auditordb.c
@@ -164,6 +164,7 @@ run (void *cls)
struct GNUNET_TIME_Absolute now, past, future, date;
now = GNUNET_TIME_absolute_get ();
+ (void) GNUNET_TIME_round_abs (&now);
past = GNUNET_TIME_absolute_subtract (now,
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS,
4));
@@ -357,7 +358,7 @@ run (void *cls)
(0 != memcmp (&withdraw_fee_balance2,
&withdraw_fee_balance,
sizeof (withdraw_fee_balance))) ) );
-
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: insert_denomination_balance\n");