commit ac1461a3ec60fbaa0b2b95bd4613f655620fcd39
parent 3a8f74247916bcf9168574e14a6fa281ce1eadb5
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 13 Feb 2025 17:35:54 +0100
-modernize code, use GNUNET_PQ_result_spec_bool()
Diffstat:
2 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c
@@ -309,9 +309,10 @@ add_order (void *cls,
struct TALER_Amount order_amount;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Adding order `%s' (%llu) to result set\n",
+ "Adding order `%s' (%llu) to result set at instance `%s'\n",
orig_order_id,
- (unsigned long long) order_serial);
+ (unsigned long long) order_serial,
+ po->instance_id);
qs = TMH_db->lookup_order_status_by_serial (TMH_db->cls,
po->instance_id,
order_serial,
diff --git a/src/backenddb/pg_lookup_order_status_by_serial.c b/src/backenddb/pg_lookup_order_status_by_serial.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2022-2025 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -26,17 +26,15 @@
#include "pg_helper.h"
enum GNUNET_DB_QueryStatus
-TMH_PG_lookup_order_status_by_serial (void *cls,
- const char *instance_id,
- uint64_t order_serial,
- char **order_id,
- struct TALER_PrivateContractHashP *
- h_contract_terms,
- bool *paid)
+TMH_PG_lookup_order_status_by_serial (
+ void *cls,
+ const char *instance_id,
+ uint64_t order_serial,
+ char **order_id,
+ struct TALER_PrivateContractHashP *h_contract_terms,
+ bool *paid)
{
struct PostgresClosure *pg = cls;
- uint8_t paid8;
- enum GNUNET_DB_QueryStatus qs;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (instance_id),
GNUNET_PQ_query_param_uint64 (&order_serial),
@@ -45,14 +43,15 @@ TMH_PG_lookup_order_status_by_serial (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
h_contract_terms),
- GNUNET_PQ_result_spec_auto_from_type ("paid",
- &paid8),
GNUNET_PQ_result_spec_string ("order_id",
order_id),
+ GNUNET_PQ_result_spec_bool ("paid",
+ paid),
GNUNET_PQ_result_spec_end
};
check_connection (pg);
+ *paid = false; /* just to be safe(r) */
PREPARE (pg,
"lookup_order_status_by_serial",
"SELECT"
@@ -65,13 +64,8 @@ TMH_PG_lookup_order_status_by_serial (void *cls,
" FROM merchant_instances"
" WHERE merchant_id=$1)"
" AND order_serial=$2");
- qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_order_status_by_serial",
- params,
- rs);
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
- *paid = (0 != paid8);
- else
- *paid = false; /* just to be safe(r) */
- return qs;
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "lookup_order_status_by_serial",
+ params,
+ rs);
}