summaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-08-19 17:19:27 +0200
committerChristian Grothoff <christian@grothoff.org>2018-08-19 17:19:27 +0200
commit190a1fadafd65d8716f9bcf0704e2bd68c9eeedd (patch)
tree246c096bf863411b48430a4a509469d4203911ea /src/exchangedb
parent0df2028f96f5977739d4659bf253e0c6d9468326 (diff)
downloadexchange-190a1fadafd65d8716f9bcf0704e2bd68c9eeedd.tar.gz
exchange-190a1fadafd65d8716f9bcf0704e2bd68c9eeedd.tar.bz2
exchange-190a1fadafd65d8716f9bcf0704e2bd68c9eeedd.zip
re-init logging so we can tell by PID who it is
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/perf_taler_exchangedb_interpreter.c1
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c56
-rw-r--r--src/exchangedb/test_exchangedb.c2
3 files changed, 42 insertions, 17 deletions
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c
index 2d0ec396c..6c0460321 100644
--- a/src/exchangedb/perf_taler_exchangedb_interpreter.c
+++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c
@@ -1410,6 +1410,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
qs = state->plugin->get_coin_transactions (state->plugin->cls,
state->session,
&coin->public_info.coin_pub,
+ GNUNET_YES,
&transactions);
GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
GNUNET_assert (transactions != NULL);
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index d3efb9314..f24b8f713 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1579,7 +1579,7 @@ postgres_prepare (PGconn *db_conn)
",denoms.denom_pub"
",coins.denom_sig"
" FROM payback"
- " JOIN known_coins coins"
+ " JOIN kown_coins coins"
" USING (coin_pub)"
" JOIN denominations denoms"
" USING (denom_pub_hash)"
@@ -4277,6 +4277,23 @@ add_coin_payback (void *cls,
/**
+ * Work we need to do.
+ */
+struct Work
+{
+ /**
+ * SQL prepared statement name.
+ */
+ const char *statement;
+
+ /**
+ * Function to call to handle the result(s).
+ */
+ GNUNET_PQ_PostgresResultHandler cb;
+};
+
+
+/**
* Compile a list of all (historic) transactions performed
* with the given coin (/refresh/melt, /deposit and /refund operations).
*
@@ -4290,25 +4307,22 @@ static enum GNUNET_DB_QueryStatus
postgres_get_coin_transactions (void *cls,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ int include_payback,
struct TALER_EXCHANGEDB_TransactionList **tlp)
{
- struct CoinHistoryContext chc;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (coin_pub),
- GNUNET_PQ_query_param_end
+ static const struct Work work_op[] = {
+ /** #TALER_EXCHANGEDB_TT_DEPOSIT */
+ { "get_deposit_with_coin_pub",
+ &add_coin_deposit },
+ /** #TALER_EXCHANGEDB_TT_REFRESH_MELT */
+ { "get_refresh_session_by_coin",
+ &add_coin_melt },
+ /** #TALER_EXCHANGEDB_TT_REFUND */
+ { "get_refunds_by_coin",
+ &add_coin_refund },
+ { NULL, NULL }
};
- enum GNUNET_DB_QueryStatus qs;
- struct {
- /**
- * SQL prepared statement name.
- */
- const char *statement;
-
- /**
- * Function to call to handle the result(s).
- */
- GNUNET_PQ_PostgresResultHandler cb;
- } work[] = {
+ static const struct Work work_wp[] = {
/** #TALER_EXCHANGEDB_TT_DEPOSIT */
{ "get_deposit_with_coin_pub",
&add_coin_deposit },
@@ -4323,7 +4337,15 @@ postgres_get_coin_transactions (void *cls,
&add_coin_payback },
{ NULL, NULL }
};
+ struct CoinHistoryContext chc;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (coin_pub),
+ GNUNET_PQ_query_param_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+ const struct Work * work;
+ work = (GNUNET_YES == include_payback) ? work_wp : work_op;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Getting transactions for coin %s\n",
TALER_B2S (coin_pub));
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 8666f1a5d..f69127ece 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -718,6 +718,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
qs = plugin->get_coin_transactions (plugin->cls,
session,
&refresh_session.coin.coin_pub,
+ GNUNET_YES,
&tl);
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs);
plugin->free_coin_transaction_list (plugin->cls,
@@ -2132,6 +2133,7 @@ run (void *cls)
qs = plugin->get_coin_transactions (plugin->cls,
session,
&refund.coin.coin_pub,
+ GNUNET_YES,
&tl);
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs);
GNUNET_assert (NULL != tl);