commit ecc22e18512a964773d27bd7ef7096ff57e6dec2
parent c54c0f00f56a1f9d94c7f14e6c271d4bc011d52f
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date: Wed, 29 May 2024 12:46:44 +0200
work on pg_insert_submitted_receipts
Diffstat:
3 files changed, 68 insertions(+), 32 deletions(-)
diff --git a/src/donaudb/pg_insert_submitted_receipts.c b/src/donaudb/pg_insert_submitted_receipts.c
@@ -36,22 +36,20 @@ DH_PG_insert_submitted_receipts (
uint64_t donation_year)
{
struct PostgresClosure *pg = cls;
- const struct DONAU_DonationUnitHashP *h_donation_unit_pubs[GNUNET_NZL (num_dr)
- ];
- const struct DONAU_UniqueDonorIdentifierNonce *nonces[GNUNET_NZL (num_dr)];
- const struct DONAU_DonationUnitSignature *donation_unit_sigs[GNUNET_NZL (
- num_dr)];
+ struct DONAU_DonationUnitHashP h_donation_unit_pubs[GNUNET_NZL (num_dr)];
+ struct DONAU_UniqueDonorIdentifierNonce nonces[GNUNET_NZL (num_dr)];
+ struct DONAU_DonationUnitSignature donation_unit_sigs[GNUNET_NZL (num_dr)];
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (h_donor_tax_id),
- GNUNET_PQ_query_param_array_ptrs_auto_from_type (num_dr,
- h_donation_unit_pubs,
- pg->conn),
- GNUNET_PQ_query_param_array_ptrs_auto_from_type (num_dr,
- nonces,
- pg->conn),
- GNUNET_PQ_query_param_array_ptrs_auto_from_type (num_dr,
- donation_unit_sigs,
- pg->conn),
+ GNUNET_PQ_query_param_array_auto_from_type (num_dr,
+ h_donation_unit_pubs,
+ pg->conn),
+ GNUNET_PQ_query_param_array_auto_from_type (num_dr,
+ nonces,
+ pg->conn),
+ DONAU_PQ_query_param_array_donation_unit_sig (num_dr,
+ donation_unit_sigs,
+ pg->conn),
GNUNET_PQ_query_param_uint64 (&donation_year),
GNUNET_PQ_query_param_end
};
@@ -71,9 +69,9 @@ DH_PG_insert_submitted_receipts (
{
const struct DONAU_DonationReceipt *dr = &donation_receipts[i];
- h_donation_unit_pubs[i] = &dr->h_donation_unit_pub;
- nonces[i] = &dr->nonce;
- donation_unit_sigs[i] = &dr->donation_unit_sig;
+ h_donation_unit_pubs[i] = dr->h_donation_unit_pub;
+ nonces[i] = dr->nonce;
+ donation_unit_sigs[i] = dr->donation_unit_sig;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Do insert submitted receipt\n");
diff --git a/src/include/donau_pq_lib.h b/src/include/donau_pq_lib.h
@@ -55,6 +55,21 @@ DONAU_PQ_query_param_array_blinded_donation_unit_sig (
/**
+ * Generate query parameter for an array of donation unit signatures
+ *
+ * @param num number of elements in @e du_sigs
+ * @param du_sigs array of donation unit signatures
+ * @param db context for the db-connection
+ */
+struct GNUNET_PQ_QueryParam
+DONAU_PQ_query_param_array_donation_unit_sig (
+ size_t num,
+ const struct DONAU_DonationUnitSignature *du_sigs,
+ struct GNUNET_PQ_Context *db
+ );
+
+
+/**
* Donation unit public key expected.
*
* @param name name of the field in the table
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c
@@ -261,14 +261,14 @@ qconv_array (
same_sized = (0 != meta->same_size);
#define RETURN_UNLESS(cond) \
- do { \
- if (! (cond)) \
- { \
- GNUNET_break ((cond)); \
- noerror = false; \
- goto DONE; \
- } \
- } while (0)
+ do { \
+ if (! (cond)) \
+ { \
+ GNUNET_break ((cond)); \
+ noerror = false; \
+ goto DONE; \
+ } \
+ } while (0)
/* Calculate sizes and check bounds */
{
@@ -649,6 +649,29 @@ DONAU_PQ_query_param_array_blinded_donation_unit_sig (
}
+struct GNUNET_PQ_QueryParam
+DONAU_PQ_query_param_array_donation_unit_sig (
+ size_t num,
+ const struct DONAU_DonationUnitSignature *du_sigs,
+ struct GNUNET_PQ_Context *db)
+{
+ Oid oid;
+
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_PQ_get_oid_by_name (db,
+ "bytea",
+ &oid));
+ return query_param_array_generic (num,
+ true,
+ du_sigs,
+ NULL,
+ 0,
+ // TALER_PQ_array_of_blinded_du_sig,
+ oid,
+ NULL);
+}
+
+
/**
* Extract data from a Postgres database @a result as array of a specific type
* from row @a row. The type information and optionally additional
@@ -684,13 +707,13 @@ extract_array_generic (
*((void **) dst) = NULL;
#define FAIL_IF(cond) \
- do { \
- if ((cond)) \
- { \
- GNUNET_break (! (cond)); \
- goto FAIL; \
- } \
- } while (0)
+ do { \
+ if ((cond)) \
+ { \
+ GNUNET_break (! (cond)); \
+ goto FAIL; \
+ } \
+ } while (0)
col_num = PQfnumber (result, fname);
FAIL_IF (0 > col_num);