summaryrefslogtreecommitdiff
path: root/src/auditordb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-10-28 11:30:02 +0100
committerChristian Grothoff <christian@grothoff.org>2018-10-28 11:30:02 +0100
commitbd40aad7dc22c9f5d723f82384c5d57204205b7a (patch)
tree1a2c4433d8781c2b2f7f8d3ea28f22234784b624 /src/auditordb
parentfb0d7110e80546f77d8c562ecfeb2ae06e2f4b6b (diff)
downloadexchange-bd40aad7dc22c9f5d723f82384c5d57204205b7a.tar.gz
exchange-bd40aad7dc22c9f5d723f82384c5d57204205b7a.tar.bz2
exchange-bd40aad7dc22c9f5d723f82384c5d57204205b7a.zip
track number of coins issued per denomination in auditor (not yet used)
Diffstat (limited to 'src/auditordb')
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c44
-rw-r--r--src/auditordb/test_auditordb.c39
2 files changed, 50 insertions, 33 deletions
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index 159e4503..2f426b99 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -308,18 +308,18 @@ postgres_create_tables (void *cls)
",wire_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
")"),
/* Table with all of the outstanding denomination coins that the
- exchange is aware of. "last_deposit_serial_id" marks the
- deposit_serial_id from "deposits" about this denomination key
- that the auditor is aware of; "last_melt_serial_id" marks the
- last melt from "refresh_sessions" that the auditor is aware
- of; "refund_serial_id" tells us the last entry in "refunds"
- for this denom_pub that the auditor is aware of. */
+ exchange is aware of and what the respective balances are
+ (outstanding as well as issued overall which implies the
+ maximum value at risk). We also count the number of coins
+ issued (withdraw, refresh-reveal) and the number of coins seen
+ at the exchange (refresh-commit, deposit), not just the amounts. */
GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_denomination_pending"
"(denom_pub_hash BYTEA PRIMARY KEY"
" REFERENCES auditor_denominations (denom_pub_hash) ON DELETE CASCADE"
",denom_balance_val INT8 NOT NULL"
",denom_balance_frac INT4 NOT NULL"
",denom_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
+ ",num_issued INT8 NOT NULL"
",denom_risk_val INT8 NOT NULL"
",denom_risk_frac INT4 NOT NULL"
",denom_risk_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
@@ -818,28 +818,31 @@ postgres_prepare (PGconn *db_conn)
",denom_balance_val"
",denom_balance_frac"
",denom_balance_curr"
+ ",num_issued"
",denom_risk_val"
",denom_risk_frac"
",denom_risk_curr"
- ") VALUES ($1,$2,$3,$4,$5,$6,$7);",
- 7),
+ ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);",
+ 8),
/* Used in #postgres_update_denomination_balance() */
GNUNET_PQ_make_prepare ("auditor_denomination_pending_update",
"UPDATE auditor_denomination_pending SET"
" denom_balance_val=$1"
",denom_balance_frac=$2"
",denom_balance_curr=$3"
- ",denom_risk_val=$4"
- ",denom_risk_frac=$5"
- ",denom_risk_curr=$6"
- " WHERE denom_pub_hash=$7",
- 7),
+ ",num_issued=$4"
+ ",denom_risk_val=$5"
+ ",denom_risk_frac=$6"
+ ",denom_risk_curr=$7"
+ " WHERE denom_pub_hash=$8",
+ 8),
/* Used in #postgres_get_denomination_balance() */
GNUNET_PQ_make_prepare ("auditor_denomination_pending_select",
"SELECT"
" denom_balance_val"
",denom_balance_frac"
",denom_balance_curr"
+ ",num_issued"
",denom_risk_val"
",denom_risk_frac"
",denom_risk_curr"
@@ -2458,6 +2461,7 @@ postgres_get_wire_fee_summary (void *cls,
* @param denom_pub_hash hash of the denomination public key
* @param denom_balance value of coins outstanding with this denomination key
* @param denom_risk value of coins issued with this denomination key
+ * @param num_issued how many coins of this denomination did the exchange blind-sign
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -2465,11 +2469,13 @@ postgres_insert_denomination_balance (void *cls,
struct TALER_AUDITORDB_Session *session,
const struct GNUNET_HashCode *denom_pub_hash,
const struct TALER_Amount *denom_balance,
- const struct TALER_Amount *denom_risk)
+ const struct TALER_Amount *denom_risk,
+ uint64_t num_issued)
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
TALER_PQ_query_param_amount (denom_balance),
+ GNUNET_PQ_query_param_uint64 (&num_issued),
TALER_PQ_query_param_amount (denom_risk),
GNUNET_PQ_query_param_end
};
@@ -2489,6 +2495,7 @@ postgres_insert_denomination_balance (void *cls,
* @param denom_pub_hash hash of the denomination public key
* @param denom_balance value of coins outstanding with this denomination key
* @param denom_risk value of coins issued with this denomination key
+ * @param num_issued how many coins of this denomination did the exchange blind-sign
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -2496,10 +2503,12 @@ postgres_update_denomination_balance (void *cls,
struct TALER_AUDITORDB_Session *session,
const struct GNUNET_HashCode *denom_pub_hash,
const struct TALER_Amount *denom_balance,
- const struct TALER_Amount *denom_risk)
+ const struct TALER_Amount *denom_risk,
+ uint64_t num_issued)
{
struct GNUNET_PQ_QueryParam params[] = {
TALER_PQ_query_param_amount (denom_balance),
+ GNUNET_PQ_query_param_uint64 (&num_issued),
TALER_PQ_query_param_amount (denom_risk),
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
GNUNET_PQ_query_param_end
@@ -2519,6 +2528,7 @@ postgres_update_denomination_balance (void *cls,
* @param denom_pub_hash hash of the denomination public key
* @param[out] denom_balance value of coins outstanding with this denomination key
* @param[out] denom_risk value of coins issued with this denomination key
+ * @param[out] num_issued how many coins of this denomination did the exchange blind-sign
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -2526,7 +2536,8 @@ postgres_get_denomination_balance (void *cls,
struct TALER_AUDITORDB_Session *session,
const struct GNUNET_HashCode *denom_pub_hash,
struct TALER_Amount *denom_balance,
- struct TALER_Amount *denom_risk)
+ struct TALER_Amount *denom_risk,
+ uint64_t *num_issued)
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
@@ -2535,6 +2546,7 @@ postgres_get_denomination_balance (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
TALER_PQ_result_spec_amount ("denom_balance", denom_balance),
TALER_PQ_result_spec_amount ("denom_risk", denom_risk),
+ GNUNET_PQ_result_spec_uint64 ("num_issued", num_issued),
GNUNET_PQ_result_spec_end
};
diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c
index 1b8a4223..65ea38e7 100644
--- a/src/auditordb/test_auditordb.c
+++ b/src/auditordb/test_auditordb.c
@@ -364,6 +364,7 @@ run (void *cls)
struct TALER_Amount refund_fee_balance2;
struct TALER_Amount rbalance;
struct TALER_Amount rbalance2;
+ uint64_t nissued;
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":12.345678",
@@ -386,7 +387,8 @@ run (void *cls)
session,
&denom_pub_hash,
&denom_balance,
- &rbalance));
+ &rbalance,
+ 42));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: update_denomination_balance\n");
@@ -401,7 +403,8 @@ run (void *cls)
session,
&denom_pub_hash,
&denom_balance,
- &rbalance));
+ &rbalance,
+ 62));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: get_denomination_balance\n");
@@ -410,10 +413,12 @@ run (void *cls)
session,
&denom_pub_hash,
&denom_balance2,
- &rbalance2));
+ &rbalance2,
+ &nissued));
FAILIF (0 != memcmp (&denom_balance2, &denom_balance, sizeof (denom_balance)));
FAILIF (0 != memcmp (&rbalance2, &rbalance, sizeof (rbalance)));
+ FAILIF (62 != nissued);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -421,26 +426,26 @@ run (void *cls)
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_balance_summary (plugin->cls,
- session,
- &master_pub,
- &refund_fee_balance,
- &melt_fee_balance,
- &deposit_fee_balance,
- &denom_balance,
- &rbalance));
+ session,
+ &master_pub,
+ &refund_fee_balance,
+ &melt_fee_balance,
+ &deposit_fee_balance,
+ &denom_balance,
+ &rbalance));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: update_balance_summary\n");
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->update_balance_summary (plugin->cls,
- session,
- &master_pub,
- &denom_balance,
- &deposit_fee_balance,
- &melt_fee_balance,
- &refund_fee_balance,
- &rbalance));
+ session,
+ &master_pub,
+ &denom_balance,
+ &deposit_fee_balance,
+ &melt_fee_balance,
+ &refund_fee_balance,
+ &rbalance));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: get_balance_summary\n");