summaryrefslogtreecommitdiff
path: root/src/auditordb
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditordb')
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c17
-rw-r--r--src/auditordb/test_auditordb.c17
2 files changed, 25 insertions, 9 deletions
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index 9450ae94f..287bef28a 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -329,6 +329,7 @@ postgres_create_tables (void *cls)
",withdraw_fee_balance_frac INT4 NOT NULL"
",expiration_date INT8 NOT NULL"
",auditor_reserves_rowid BIGSERIAL UNIQUE"
+ ",origin_account TEXT"
")"),
GNUNET_PQ_make_try_execute ("CREATE INDEX auditor_reserves_by_reserve_pub "
"ON auditor_reserves(reserve_pub)"),
@@ -777,8 +778,9 @@ postgres_prepare (PGconn *db_conn)
",withdraw_fee_balance_val"
",withdraw_fee_balance_frac"
",expiration_date"
- ") VALUES ($1,$2,$3,$4,$5,$6,$7);",
- 7),
+ ",origin_account"
+ ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);",
+ 8),
/* Used in #postgres_update_reserve_info() */
GNUNET_PQ_make_prepare ("auditor_reserves_update",
"UPDATE auditor_reserves SET"
@@ -798,6 +800,7 @@ postgres_prepare (PGconn *db_conn)
",withdraw_fee_balance_frac"
",expiration_date"
",auditor_reserves_rowid"
+ ",origin_account"
" FROM auditor_reserves"
" WHERE reserve_pub=$1 AND master_pub=$2;",
2),
@@ -2475,6 +2478,7 @@ postgres_get_wire_auditor_progress (void *cls,
* @param withdraw_fee_balance amount the exchange gained in withdraw fees
* due to withdrawals from this reserve
* @param expiration_date expiration date of the reserve
+ * @param origin_account where did the money in the reserve originally come from
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -2484,7 +2488,8 @@ postgres_insert_reserve_info (void *cls,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_Amount *reserve_balance,
const struct TALER_Amount *withdraw_fee_balance,
- struct GNUNET_TIME_Absolute expiration_date)
+ struct GNUNET_TIME_Absolute expiration_date,
+ const char *origin_account)
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
@@ -2492,6 +2497,7 @@ postgres_insert_reserve_info (void *cls,
TALER_PQ_query_param_amount (reserve_balance),
TALER_PQ_query_param_amount (withdraw_fee_balance),
TALER_PQ_query_param_absolute_time (&expiration_date),
+ GNUNET_PQ_query_param_string (origin_account),
GNUNET_PQ_query_param_end
};
@@ -2586,6 +2592,7 @@ postgres_del_reserve_info (void *cls,
* @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees
* due to withdrawals from this reserve
* @param[out] expiration_date expiration date of the reserve
+ * @param[out] sender_account from where did the money in the reserve originally come from
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -2596,7 +2603,8 @@ postgres_get_reserve_info (void *cls,
uint64_t *rowid,
struct TALER_Amount *reserve_balance,
struct TALER_Amount *withdraw_fee_balance,
- struct GNUNET_TIME_Absolute *expiration_date)
+ struct GNUNET_TIME_Absolute *expiration_date,
+ char **sender_account)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@@ -2609,6 +2617,7 @@ postgres_get_reserve_info (void *cls,
TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance", withdraw_fee_balance),
TALER_PQ_result_spec_absolute_time ("expiration_date", expiration_date),
GNUNET_PQ_result_spec_uint64 ("auditor_reserves_rowid", rowid),
+ GNUNET_PQ_result_spec_string ("origin_account", sender_account),
GNUNET_PQ_result_spec_end
};
diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c
index 8f1b7da8a..3968f0218 100644
--- a/src/auditordb/test_auditordb.c
+++ b/src/auditordb/test_auditordb.c
@@ -291,6 +291,7 @@ run (void *cls)
TALER_string_to_amount (CURRENCY ":23.456789",
&withdraw_fee_balance));
+
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_reserve_info (plugin->cls,
session,
@@ -298,7 +299,8 @@ run (void *cls)
&master_pub,
&reserve_balance,
&withdraw_fee_balance,
- past));
+ past,
+ "payto://bla/blub"));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: update_reserve_info\n");
@@ -315,6 +317,8 @@ run (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: get_reserve_info\n");
+ char *payto;
+
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_reserve_info (plugin->cls,
session,
@@ -323,8 +327,11 @@ run (void *cls)
&rowid,
&reserve_balance2,
&withdraw_fee_balance2,
- &date));
-
+ &date,
+ &payto));
+ FAILIF (0 != strcmp (payto,
+ "payto://bla/blub"));
+ GNUNET_free (payto);
FAILIF (0 != GNUNET_memcmp (&date, &future)
|| 0 != GNUNET_memcmp (&reserve_balance2, &reserve_balance)
|| 0 != GNUNET_memcmp (&withdraw_fee_balance2,
@@ -725,7 +732,7 @@ run (void *cls)
result = 0;
- drop:
+drop:
if (NULL != session)
{
plugin->rollback (plugin->cls,
@@ -746,7 +753,7 @@ run (void *cls)
GNUNET_break (GNUNET_OK ==
plugin->drop_tables (plugin->cls,
GNUNET_YES));
- unload:
+unload:
TALER_AUDITORDB_plugin_unload (plugin);
plugin = NULL;
}