summaryrefslogtreecommitdiff
path: root/src/auditordb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-01-17 15:00:22 +0100
committerChristian Grothoff <christian@grothoff.org>2020-01-17 15:00:32 +0100
commit01456098909a4ebddf5a84729242be235af2fdbb (patch)
treee06394fcadf2266687b886ec797837a0f90a0b35 /src/auditordb
parente369dcfc25f1a25c59e0e6dd816397855a45d5bd (diff)
downloadexchange-01456098909a4ebddf5a84729242be235af2fdbb.tar.gz
exchange-01456098909a4ebddf5a84729242be235af2fdbb.tar.bz2
exchange-01456098909a4ebddf5a84729242be235af2fdbb.zip
fix FIXME: total up irregular paybacks and add to report
Diffstat (limited to 'src/auditordb')
-rw-r--r--src/auditordb/0001.sql2
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c29
-rw-r--r--src/auditordb/test_auditordb.c17
3 files changed, 38 insertions, 10 deletions
diff --git a/src/auditordb/0001.sql b/src/auditordb/0001.sql
index 425436e2..f770d67e 100644
--- a/src/auditordb/0001.sql
+++ b/src/auditordb/0001.sql
@@ -172,6 +172,8 @@ CREATE TABLE IF NOT EXISTS auditor_balance_summary
,risk_frac INT4 NOT NULL
,loss_val INT8 NOT NULL
,loss_frac INT4 NOT NULL
+ ,irregular_payback_val INT8 NOT NULL
+ ,irregular_payback_frac INT4 NOT NULL
);
-- Table with historic profits; basically, when a denom_pub has
-- expired and everything associated with it is garbage collected,
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index 0d552ff1..a1e71ade 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -614,9 +614,11 @@ postgres_get_session (void *cls)
",risk_frac"
",loss_val"
",loss_frac"
+ ",irregular_payback_val"
+ ",irregular_payback_frac"
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,"
- " $11,$12,$13);",
- 13),
+ " $11,$12,$13,$14,$15);",
+ 15),
/* Used in #postgres_update_balance_summary() */
GNUNET_PQ_make_prepare ("auditor_balance_summary_update",
"UPDATE auditor_balance_summary SET"
@@ -632,8 +634,10 @@ postgres_get_session (void *cls)
",risk_frac=$10"
",loss_val=$11"
",loss_frac=$12"
- " WHERE master_pub=$13;",
- 13),
+ ",irregular_payback_val=$13"
+ ",irregular_payback_frac=$14"
+ " WHERE master_pub=$15;",
+ 15),
/* Used in #postgres_get_balance_summary() */
GNUNET_PQ_make_prepare ("auditor_balance_summary_select",
"SELECT"
@@ -649,6 +653,8 @@ postgres_get_session (void *cls)
",risk_frac"
",loss_val"
",loss_frac"
+ ",irregular_payback_val"
+ ",irregular_payback_frac"
" FROM auditor_balance_summary"
" WHERE master_pub=$1;",
1),
@@ -2620,6 +2626,7 @@ postgres_get_denomination_balance (void *cls,
* @param refund_fee_balance total refund fees collected for this DK
* @param risk maximum risk exposure of the exchange
* @param loss materialized @a risk from payback
+ * @param irregular_payback paybacks on non-revoked coins
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -2632,7 +2639,8 @@ postgres_insert_balance_summary (void *cls,
const struct TALER_Amount *melt_fee_balance,
const struct TALER_Amount *refund_fee_balance,
const struct TALER_Amount *risk,
- const struct TALER_Amount *loss)
+ const struct TALER_Amount *loss,
+ const struct TALER_Amount *irregular_payback)
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (master_pub),
@@ -2642,6 +2650,7 @@ postgres_insert_balance_summary (void *cls,
TALER_PQ_query_param_amount (refund_fee_balance),
TALER_PQ_query_param_amount (risk),
TALER_PQ_query_param_amount (loss),
+ TALER_PQ_query_param_amount (irregular_payback),
GNUNET_PQ_query_param_end
};
@@ -2675,6 +2684,7 @@ postgres_insert_balance_summary (void *cls,
* @param refund_fee_balance total refund fees collected for this DK
* @param risk maximum risk exposure of the exchange
* @param loss materialized @a risk from payback
+ * @param irregular_payback paybacks made on non-revoked coins
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -2687,7 +2697,8 @@ postgres_update_balance_summary (void *cls,
const struct TALER_Amount *melt_fee_balance,
const struct TALER_Amount *refund_fee_balance,
const struct TALER_Amount *risk,
- const struct TALER_Amount *loss)
+ const struct TALER_Amount *loss,
+ const struct TALER_Amount *irregular_payback)
{
struct GNUNET_PQ_QueryParam params[] = {
TALER_PQ_query_param_amount (denom_balance),
@@ -2696,6 +2707,7 @@ postgres_update_balance_summary (void *cls,
TALER_PQ_query_param_amount (refund_fee_balance),
TALER_PQ_query_param_amount (risk),
TALER_PQ_query_param_amount (loss),
+ TALER_PQ_query_param_amount (irregular_payback),
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
@@ -2718,6 +2730,7 @@ postgres_update_balance_summary (void *cls,
* @param[out] refund_fee_balance total refund fees collected for this DK
* @param[out] risk maximum risk exposure of the exchange
* @param[out] loss losses from payback (on revoked denominations)
+ * @param[out] irregular_payback paybacks on NOT revoked denominations
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -2729,7 +2742,8 @@ postgres_get_balance_summary (void *cls,
struct TALER_Amount *melt_fee_balance,
struct TALER_Amount *refund_fee_balance,
struct TALER_Amount *risk,
- struct TALER_Amount *loss)
+ struct TALER_Amount *loss,
+ struct TALER_Amount *irregular_payback)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@@ -2743,6 +2757,7 @@ postgres_get_balance_summary (void *cls,
TALER_PQ_RESULT_SPEC_AMOUNT ("refund_fee_balance", refund_fee_balance),
TALER_PQ_RESULT_SPEC_AMOUNT ("risk", risk),
TALER_PQ_RESULT_SPEC_AMOUNT ("loss", loss),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("irregular_payback", irregular_payback),
GNUNET_PQ_result_spec_end
};
diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c
index 9b97d47b..863b20cc 100644
--- a/src/auditordb/test_auditordb.c
+++ b/src/auditordb/test_auditordb.c
@@ -392,6 +392,8 @@ run (void *cls)
struct TALER_Amount rbalance2;
struct TALER_Amount loss;
struct TALER_Amount loss2;
+ struct TALER_Amount iirp;
+ struct TALER_Amount iirp2;
uint64_t nissued;
GNUNET_assert (GNUNET_OK ==
@@ -415,6 +417,9 @@ run (void *cls)
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.6",
&loss));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (CURRENCY ":1.1",
+ &iirp));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_denomination_balance (plugin->cls,
@@ -474,7 +479,8 @@ run (void *cls)
&deposit_fee_balance,
&denom_balance,
&rbalance,
- &loss));
+ &loss,
+ &iirp));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: update_balance_summary\n");
@@ -488,7 +494,8 @@ run (void *cls)
&melt_fee_balance,
&refund_fee_balance,
&rbalance,
- &loss));
+ &loss,
+ &iirp));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: get_balance_summary\n");
@@ -499,6 +506,7 @@ run (void *cls)
ZR_BLK (&refund_fee_balance2);
ZR_BLK (&rbalance2);
ZR_BLK (&loss2);
+ ZR_BLK (&iirp2);
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_balance_summary (plugin->cls,
@@ -509,7 +517,8 @@ run (void *cls)
&melt_fee_balance2,
&refund_fee_balance2,
&rbalance2,
- &loss2));
+ &loss2,
+ &iirp2));
FAILIF ( (0 != GNUNET_memcmp (&denom_balance2,
&denom_balance) ) ||
@@ -523,6 +532,8 @@ run (void *cls)
&rbalance));
FAILIF (0 != GNUNET_memcmp (&loss2,
&loss));
+ FAILIF (0 != GNUNET_memcmp (&iirp2,
+ &iirp));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,