summaryrefslogtreecommitdiff
path: root/src/exchangedb/plugin_exchangedb_postgres.c
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/plugin_exchangedb_postgres.c
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/plugin_exchangedb_postgres.c')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index d3efb931..f24b8f71 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));