[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-donau] branch master updated: [donaudb] add lookup issued receipt
From: |
gnunet |
Subject: |
[taler-donau] branch master updated: [donaudb] add lookup issued receipts pg request |
Date: |
Tue, 19 Mar 2024 16:11:38 +0100 |
This is an automated email from the git hooks/post-receive script.
lukas-matyja pushed a commit to branch master
in repository donau.
The following commit(s) were added to refs/heads/master by this push:
new 4388d7c [donaudb] add lookup issued receipts pg request
4388d7c is described below
commit 4388d7c28f1fd261f92ea529e801332a6463b935
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
AuthorDate: Tue Mar 19 16:03:00 2024 +0100
[donaudb] add lookup issued receipts pg request
---
src/donau/donau-httpd_post-batch-issue.c | 4 +-
src/donaudb/Makefile.am | 3 +-
src/donaudb/pg_lookup_charity.h | 4 +-
src/donaudb/pg_lookup_issued_receipts.c | 61 ++++++++++++++++++++++
...ookup_charity.h => pg_lookup_issued_receipts.h} | 21 ++++----
src/donaudb/plugin_donaudb_postgres.c | 5 +-
src/include/donau_crypto_lib.h | 8 +++
src/include/donaudb_plugin.h | 21 ++++++++
8 files changed, 109 insertions(+), 18 deletions(-)
diff --git a/src/donau/donau-httpd_post-batch-issue.c
b/src/donau/donau-httpd_post-batch-issue.c
index 1638511..6060b51 100644
--- a/src/donau/donau-httpd_post-batch-issue.c
+++ b/src/donau/donau-httpd_post-batch-issue.c
@@ -28,7 +28,7 @@
#include <taler/taler_mhd_lib.h>
#include <taler/taler_signatures.h>
#include "donaudb_plugin.h"
-#include "donau-httpd_charity.h"
+#include "donau-httpd_post-batch-issue.h"
#include "donau-httpd_db.h"
#include "donau-httpd_metrics.h"
@@ -204,10 +204,8 @@ DH_handler_issue_receipts_post (struct DH_RequestContext
*rc,
}
// Get charity pub
-
struct DONAUDB_CharityMetaData meta;
enum GNUNET_DB_QueryStatus qs;
- //MHD_RESULT result;
qs = DH_plugin->lookup_charity (DH_plugin->cls,
(uint64_t) charity_id,
diff --git a/src/donaudb/Makefile.am b/src/donaudb/Makefile.am
index 0904ee2..3d31e59 100644
--- a/src/donaudb/Makefile.am
+++ b/src/donaudb/Makefile.am
@@ -87,8 +87,9 @@ libtaler_plugin_donaudb_postgres_la_SOURCES = \
pg_get_charities.h pg_get_charities.c \
pg_insert_charity.h pg_insert_charity.c \
pg_do_charity_delete.h pg_do_charity_delete.c \
- pg_lookup_charity.h pg_lookup_charity.c \
pg_insert_history_entry.h pg_insert_history_entry.c \
+ pg_lookup_charity.h pg_lookup_charity.c \
+ pg_lookup_issued_receipts.h pg_lookup_issued_receipts.c \
pg_insert_issued_receipt.h pg_insert_issued_receipt.c \
pg_insert_submitted_receipt.h pg_insert_submitted_receipt.c
diff --git a/src/donaudb/pg_lookup_charity.h b/src/donaudb/pg_lookup_charity.h
index 5e4c832..cbd0585 100644
--- a/src/donaudb/pg_lookup_charity.h
+++ b/src/donaudb/pg_lookup_charity.h
@@ -18,8 +18,8 @@
* @brief implementation of the lookup_charity function for Postgres
* @author Johannes Casaburi
*/
-#ifndef PG_GET_DONATION_UNIT_INFO_H
-#define PG_GET_DONATION_UNIT_INFO_H
+#ifndef PG_GET_CHARITY_INFO_H
+#define PG_GET_CHARITY_INFO_H
#include <taler/taler_util.h>
#include <taler/taler_json_lib.h>
diff --git a/src/donaudb/pg_lookup_issued_receipts.c
b/src/donaudb/pg_lookup_issued_receipts.c
new file mode 100644
index 0000000..131b4a1
--- /dev/null
+++ b/src/donaudb/pg_lookup_issued_receipts.c
@@ -0,0 +1,61 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2024 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
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file donaudb/pg_lookup_issued_receipts.c
+ * @brief Implementation of the lookup_issued_receipts function for Postgres
+ * @author Lukas Matyja
+ */
+#include <taler/platform.h>
+#include <taler/taler_error_codes.h>
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
+#include "pg_lookup_issued_receipts.h"
+#include "pg_helper.h"
+
+enum GNUNET_DB_QueryStatus
+DH_PG_lookup_issued_receipts (
+ void *cls,
+ struct DONAU_BudiKeyPairsHashP bkp_hash,
+ struct DONAUDB_IssuedReceiptsMetaData *meta)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (&bkp_hash),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_auto_from_type ("charity_sig",
+ &meta->charity_sig),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
+ &meta->amount),
+ GNUNET_PQ_result_spec_uint64 ("charity_id",
+ &meta->charity_id),
+ GNUNET_PQ_result_spec_end
+ };
+
+ PREPARE (pg,
+ "lookup_issued_receipts",
+ "SELECT "
+ " charity_sig"
+ " ,amount"
+ " ,charity_id"
+ " FROM receipts_issued"
+ " WHERE receipt_hash=$1;");
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "lookup_issued_receipts",
+ params,
+ rs);
+}
diff --git a/src/donaudb/pg_lookup_charity.h
b/src/donaudb/pg_lookup_issued_receipts.h
similarity index 71%
copy from src/donaudb/pg_lookup_charity.h
copy to src/donaudb/pg_lookup_issued_receipts.h
index 5e4c832..a527ea5 100644
--- a/src/donaudb/pg_lookup_charity.h
+++ b/src/donaudb/pg_lookup_issued_receipts.h
@@ -14,27 +14,26 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file donaudb/pg_lookup_charity.h
- * @brief implementation of the lookup_charity function for Postgres
- * @author Johannes Casaburi
+ * @file donaudb/pg_lookup_issued_receipts.h
+ * @brief implementation of the lookup_issued_receipts function for Postgres
+ * @author Lukas Matyja
*/
-#ifndef PG_GET_DONATION_UNIT_INFO_H
-#define PG_GET_DONATION_UNIT_INFO_H
+#ifndef PG_GET_ISSUED_RECEIPTS_H
+#define PG_GET_ISSUED_RECEIPTS_H
#include <taler/taler_util.h>
#include <taler/taler_json_lib.h>
#include "donaudb_plugin.h"
/**
- * Fetch information about a donation unit key.
+ * Fetch information about an issued receipts request.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param[out] info information with value and other info about the coin
+ * @param[out] info information with value and other info about the issued
receipts
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
-DH_PG_lookup_charity (
+DH_PG_lookup_issued_receipts (
void *cls,
- uint64_t charity_id,
- struct DONAUDB_CharityMetaData *meta);
-
+ struct DONAU_BudiKeyPairsHashP bkp_hash,
+ struct DONAUDB_IssuedReceiptsMetaData *meta);
#endif
diff --git a/src/donaudb/plugin_donaudb_postgres.c
b/src/donaudb/plugin_donaudb_postgres.c
index 33f73cc..2e40fec 100644
--- a/src/donaudb/plugin_donaudb_postgres.c
+++ b/src/donaudb/plugin_donaudb_postgres.c
@@ -59,6 +59,7 @@
#include "pg_iterate_active_signing_keys.h"
#include "pg_lookup_signing_key.h"
#include "pg_lookup_charity.h"
+#include "pg_lookup_issued_receipts.h"
#include "pg_get_charities.h"
#include "pg_insert_charity.h"
#include "pg_do_charity_delete.h"
@@ -248,8 +249,10 @@ libtaler_plugin_donaudb_postgres_init (void *cls)
= &DH_PG_get_history;
plugin->insert_issued_receipt
= &DH_PG_insert_issued_receipt;
+ plugin->lookup_issued_receipts
+ = &DH_PG_lookup_issued_receipts;
plugin->insert_submitted_receipt
- = &DH_PG_insert_submitted_receipt;
+ = &DH_PG_insert_submitted_receipts;
plugin->insert_signing_key
= &DH_PG_insert_signing_key;
plugin->lookup_signing_key
diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h
index a3e6960..b35b1fd 100644
--- a/src/include/donau_crypto_lib.h
+++ b/src/include/donau_crypto_lib.h
@@ -264,6 +264,14 @@ struct DONAU_BlindedUniqueDonationIdentifierKeyPair
};
+/**
+ * Hash of a budikeypair array
+ */
+struct DONAU_BudiKeyPairsHashP
+{
+ struct GNUNET_HashCode hash;
+};
+
/* ********************* charity eddsa signing ************************** */
diff --git a/src/include/donaudb_plugin.h b/src/include/donaudb_plugin.h
index f38012c..1c960a6 100644
--- a/src/include/donaudb_plugin.h
+++ b/src/include/donaudb_plugin.h
@@ -89,6 +89,27 @@ struct DONAUDB_CharityMetaData
};
+/**
+ * Meta data about issued receipts of a request.
+ */
+struct DONAUDB_IssuedReceiptsMetaData
+{
+ /**
+ * Charity id
+ */
+ uint64_t charity_id;
+
+ /**
+ * total issued amount of the receipts
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * Charity signature
+ */
+ struct DONAU_CharitySignatureP charity_sig;
+
+};
/**
* @brief All information about a donation unit key.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-donau] branch master updated: [donaudb] add lookup issued receipts pg request,
gnunet <=