summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-02-09 23:21:55 +0100
committerChristian Grothoff <christian@grothoff.org>2024-02-09 23:21:55 +0100
commitfeed3903671edc872c5fb8cfaad677727047d203 (patch)
treec6332c55de5d4d12d5843a76799bb448698ce237
parentba18887d6277134f090649cabbe753a86abab716 (diff)
downloadmerchant-feed3903671edc872c5fb8cfaad677727047d203.tar.gz
merchant-feed3903671edc872c5fb8cfaad677727047d203.tar.bz2
merchant-feed3903671edc872c5fb8cfaad677727047d203.zip
trying again on #8348 fix
-rw-r--r--src/backend/taler-merchant-wirewatch.c53
-rw-r--r--src/backenddb/pg_lookup_orders.c24
2 files changed, 62 insertions, 15 deletions
diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c
index f273aaec..6242ddbc 100644
--- a/src/backend/taler-merchant-wirewatch.c
+++ b/src/backend/taler-merchant-wirewatch.c
@@ -351,6 +351,7 @@ credit_cb (
enum GNUNET_DB_QueryStatus qs;
char *exchange_url;
struct TALER_WireTransferIdentifierRawP wtid;
+ char *credit_payto;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received wire transfer `%s' over %s\n",
@@ -372,22 +373,60 @@ credit_cb (
/* FIXME: consider grouping multiple inserts
into one bigger transaction with just one
notify! */
+ credit_payto = TALER_payto_normalize (details->credit_account_uri);
qs = db_plugin->insert_transfer (db_plugin->cls,
w->instance_id,
exchange_url,
&wtid,
&details->amount,
- details->credit_account_uri,
+ credit_payto,
true /* confirmed */);
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
{
- /* FIXME: this *also* logs if the entry simply
- already exists. Modify code to distinguish! */
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Inserting transfer for %s into database failed. Is the credit account %s configured correctly?\n",
- w->instance_id,
- details->credit_account_uri);
+ struct TALER_Amount total;
+ struct TALER_Amount wfee;
+ struct TALER_Amount eamount;
+ struct GNUNET_TIME_Timestamp timestamp;
+ bool have_esig;
+ bool verified;
+
+ qs = db_plugin->lookup_transfer (db_plugin->cls,
+ w->instance_id,
+ exchange_url,
+ &wtid,
+ &total,
+ &wfee,
+ &eamount,
+ &timestamp,
+ &have_esig,
+ &verified);
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Inserting transfer for %s into database failed. Is the credit account %s configured correctly?\n",
+ w->instance_id,
+ credit_payto);
+ }
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
+ {
+ if (0 !=
+ TALER_amount_cmp (&total,
+ &details->amount))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Inserting transfer for %s into database failed. An entry exists for a different transfer amount (%s)!\n",
+ w->instance_id,
+ TALER_amount2s (&total));
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Inserting transfer for %s into database failed. An equivalent entry already exists.\n",
+ w->instance_id);
+ }
+ }
}
+ GNUNET_free (credit_payto);
GNUNET_free (exchange_url);
if (qs < 0)
{
diff --git a/src/backenddb/pg_lookup_orders.c b/src/backenddb/pg_lookup_orders.c
index 63494c3a..632638f6 100644
--- a/src/backenddb/pg_lookup_orders.c
+++ b/src/backenddb/pg_lookup_orders.c
@@ -110,16 +110,19 @@ TMH_PG_lookup_orders (void *cls,
};
uint64_t limit = (of->delta > 0) ? of->delta : -of->delta;
struct GNUNET_PQ_QueryParam params[] = {
+ /* $1 */
GNUNET_PQ_query_param_string (instance_id),
GNUNET_PQ_query_param_uint64 (&limit),
GNUNET_PQ_query_param_uint64 (&of->start_row),
GNUNET_PQ_query_param_timestamp (&of->date),
GNUNET_PQ_query_param_bool ((TALER_EXCHANGE_YNA_ALL == of->paid)),
+ /* $6 */
GNUNET_PQ_query_param_bool ((TALER_EXCHANGE_YNA_YES == of->paid)),
GNUNET_PQ_query_param_bool ((TALER_EXCHANGE_YNA_ALL == of->refunded)),
GNUNET_PQ_query_param_bool ((TALER_EXCHANGE_YNA_YES == of->refunded)),
GNUNET_PQ_query_param_bool ((TALER_EXCHANGE_YNA_ALL == of->wired)),
GNUNET_PQ_query_param_bool ((TALER_EXCHANGE_YNA_YES == of->wired)),
+ /* $11 */
GNUNET_PQ_query_param_bool (NULL == of->session_id),
NULL == of->session_id
? GNUNET_PQ_query_param_null ()
@@ -133,6 +136,11 @@ TMH_PG_lookup_orders (void *cls,
enum GNUNET_DB_QueryStatus qs;
char stmt[128];
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Looking up orders, using filter paid:%d, refunded: %d, wired: %d\n",
+ of->paid,
+ of->refunded,
+ of->wired);
GNUNET_snprintf (stmt,
sizeof (stmt),
"lookup_orders_%s",
@@ -153,11 +161,11 @@ TMH_PG_lookup_orders (void *cls,
" AND"
" creation_time < $4"
" AND ($5 OR "
- " NOT CAST($6 as BOOL))" /* unclaimed orders are never paid */
+ " NOT BOOL($6))" /* unclaimed orders are never paid */
" AND ($7 OR "
- " NOT CAST($8 as BOOL))"/* unclaimed orders are never refunded */
+ " NOT BOOL($8))"/* unclaimed orders are never refunded */
" AND ($9 OR "
- " NOT CAST($10 as BOOL))" /* unclaimed orders are never wired */
+ " NOT BOOL($10))" /* unclaimed orders are never wired */
" AND"
" order_serial NOT IN"
" (SELECT order_serial"
@@ -198,7 +206,7 @@ TMH_PG_lookup_orders (void *cls,
" LIMIT $2)"
" ORDER BY order_serial DESC"
" LIMIT $2");
-
+
PREPARE (pg,
"lookup_orders_inc",
"(SELECT"
@@ -215,11 +223,11 @@ TMH_PG_lookup_orders (void *cls,
" AND"
" creation_time > $4"
" AND ($5 OR "
- " NOT CAST($6 as BOOL))" /* unclaimed orders are never paid */
+ " NOT BOOL($6))" /* unclaimed orders are never paid */
" AND ($7 OR "
- " NOT CAST($8 as BOOL))"/* unclaimed orders are never refunded */
+ " NOT BOOL($8))"/* unclaimed orders are never refunded */
" AND ($9 OR "
- " NOT CAST($10 as BOOL))" /* unclaimed orders are never wired */
+ " NOT BOOL($10))" /* unclaimed orders are never wired */
" AND"
" (order_serial NOT IN"
" (SELECT order_serial"
@@ -260,7 +268,7 @@ TMH_PG_lookup_orders (void *cls,
" LIMIT $2)"
" ORDER BY order_serial ASC"
" LIMIT $2");
-
+
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
stmt,
params,