gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-donau] branch master updated: [db] added pg transactions


From: gnunet
Subject: [taler-donau] branch master updated: [db] added pg transactions
Date: Mon, 23 Oct 2023 23:30:48 +0200

This is an automated email from the git hooks/post-receive script.

johannes-casaburi pushed a commit to branch master
in repository donau.

The following commit(s) were added to refs/heads/master by this push:
     new 2c88077  [db] added pg transactions
2c88077 is described below

commit 2c88077c75c7fd1e944eb61f02db9be50de473ed
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
AuthorDate: Mon Oct 23 23:30:22 2023 +0200

    [db] added pg transactions
---
 src/donaudb/pg_add_donation_unit_key.h             |  8 ++--
 src/donaudb/pg_insert_charity.c                    |  2 +-
 ..._insert_charity.c => pg_insert_history_entry.c} | 44 +++++++++-----------
 src/donaudb/pg_insert_history_entry.h              | 44 ++++++++++++++++++++
 ...insert_charity.c => pg_insert_issued_receipt.c} | 47 ++++++++++-----------
 src/donaudb/pg_insert_issued_receipt.h             | 45 ++++++++++++++++++++
 ...ert_charity.c => pg_insert_submitted_receipt.c} | 48 +++++++++++-----------
 src/donaudb/pg_insert_submitted_receipt.h          | 46 +++++++++++++++++++++
 8 files changed, 204 insertions(+), 80 deletions(-)

diff --git a/src/donaudb/pg_add_donation_unit_key.h 
b/src/donaudb/pg_add_donation_unit_key.h
index 8cde55b..fec4c2c 100644
--- a/src/donaudb/pg_add_donation_unit_key.h
+++ b/src/donaudb/pg_add_donation_unit_key.h
@@ -14,8 +14,8 @@
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file donaudb/pg_add_denomination_key.h
- * @brief implementation of the add_denomination_key function for Postgres
+ * @file donaudb/pg_add_donation_unit_key.h
+ * @brief implementation of the add_donation_unit_key function for Postgres
  * @author Johannes Casaburi
  */
 #ifndef PG_ADD_DONATION_UNIT_KEY_H
@@ -37,6 +37,6 @@
 enum GNUNET_DB_QueryStatus
 TEH_PG_add_donation_unit_key (
   void *cls,
-  const struct TALER_DenominationPublicKey *denom_pub,
-  const struct TALER_DONAUDB_DenominationKeyMetaInfo *meta)
+  const struct TALER_DonationUnitPublicKey *donation_unit_pub,
+  const struct TALER_DONAUDB_DonationUnitKeyMetaInfo *meta)
 #endif
diff --git a/src/donaudb/pg_insert_charity.c b/src/donaudb/pg_insert_charity.c
index 883acac..9104dee 100644
--- a/src/donaudb/pg_insert_charity.c
+++ b/src/donaudb/pg_insert_charity.c
@@ -16,7 +16,7 @@
 /**
  * @file exchangedb/pg_insert_charity.c
  * @brief Implementation of the insert_charity function for Postgres
- * @author Christian Grothoff
+ * @author Johannes Casaburi
  */
 #include "platform.h"
 #include "taler_error_codes.h"
diff --git a/src/donaudb/pg_insert_charity.c 
b/src/donaudb/pg_insert_history_entry.c
similarity index 51%
copy from src/donaudb/pg_insert_charity.c
copy to src/donaudb/pg_insert_history_entry.c
index 883acac..858a82e 100644
--- a/src/donaudb/pg_insert_charity.c
+++ b/src/donaudb/pg_insert_history_entry.c
@@ -14,47 +14,41 @@
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file exchangedb/pg_insert_charity.c
- * @brief Implementation of the insert_charity function for Postgres
- * @author Christian Grothoff
+ * @file exchangedb/pg_insert_history_entry.c
+ * @brief Implementation of the insert_history_entry function for Postgres
+ * @author Johannes Casaburi
  */
 #include "platform.h"
 #include "taler_error_codes.h"
 #include "taler_dbevents.h"
 #include "taler_pq_lib.h"
-#include "pg_insert_charity.h"
+#include "pg_insert_history_entry.h"
 #include "pg_helper.h"
 
 enum GNUNET_DB_QueryStatus
-TEH_PG_insert_charity (void *cls,
-                       const struct TALER_CharityPublicKeyP *charity_pub,
-                       const char *charity_url,
-                       const char *charity_name,
-                       uint64_t current_year,
-                       struct TALER_Amount *receipts_to_date)
+TEH_PG_insert_history_entry (void *cls,
+                       const uint64_t charity_id,
+                       const struct TALER_Amount *final_amount,
+                       const uint64_t donation_year)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (charity_pub),
-    GNUNET_PQ_query_param_string (charity_name),
-    GNUNET_PQ_query_param_string (charity_url),
-    GNUNET_PQ_query_param_uint64 (current_year),
-    TALER_PQ_query_param_amount (receipts_to_date),
+    GNUNET_PQ_query_param_uint64 (charity_id),
+    GNUNET_PQ_query_param_amount (final_amount),
+    GNUNET_PQ_query_param_uint64 (donation_year),
     GNUNET_PQ_query_param_end
   };
 
-  /* used in #postgres_insert_charity() */
+  /* used in #postgres_insert_history_entry() */
   PREPARE (pg,
-           "insert_charity",
-           "INSERT INTO charities "
-           "(charity_pub"
-           ",charity_name"
-           ",charity_url"
-           ",current_year"
-           ",receipts_to_date"
+           "insert_history_entry",
+           "INSERT INTO history "
+           "(charity_id"
+           ",final_amount"
+           ",donation_year"
            ") VALUES "
-           "($1, $2, $3, $4, $5);");
+           "($1, $2, $3);");
   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
-                                             "insert_charity",
+                                             "insert_history_entry",
                                              params);
 }
diff --git a/src/donaudb/pg_insert_history_entry.h 
b/src/donaudb/pg_insert_history_entry.h
new file mode 100644
index 0000000..867b8b1
--- /dev/null
+++ b/src/donaudb/pg_insert_history_entry.h
@@ -0,0 +1,44 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2023 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 exchangedb/pg_insert_history_entry.h
+ * @brief implementation of the insert_history_entry function for Postgres
+ * @author Johannes Casaburi
+ */
+#ifndef PG_INSERT_HISTORY_ENTRY_H
+#define PG_INSERT_HISTORY_ENTRY_H
+
+#include "taler_util.h"
+#include "taler_json_lib.h"
+#include "taler_donaudb_plugin.h"
+
+/**
+ * Insert information about an auditor that will audit this exchange.
+ *
+ * @param cls closure
+ * @param auditor_pub key of the auditor
+ * @param auditor_url base URL of the auditor's REST service
+ * @param auditor_name name of the auditor (for humans)
+ * @param start_date date when the auditor was added by the offline system
+ *                      (only to be used for replay detection)
+ * @return transaction status code
+ */
+enum GNUNET_DB_QueryStatus
+TEH_PG_insert_history_entry (void *cls,
+                       const uint64_t charity_id,
+                       const struct TALER_Amount *final_amount,
+                       const uint64_t donation_year);
+#endif
diff --git a/src/donaudb/pg_insert_charity.c 
b/src/donaudb/pg_insert_issued_receipt.c
similarity index 51%
copy from src/donaudb/pg_insert_charity.c
copy to src/donaudb/pg_insert_issued_receipt.c
index 883acac..ac4778d 100644
--- a/src/donaudb/pg_insert_charity.c
+++ b/src/donaudb/pg_insert_issued_receipt.c
@@ -14,47 +14,44 @@
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file exchangedb/pg_insert_charity.c
- * @brief Implementation of the insert_charity function for Postgres
- * @author Christian Grothoff
+ * @file donaudb/pg_insert_issed_receipt.c
+ * @brief Implementation of the insert_issued_receipt function for Postgres
+ * @author Johannes Casaburi
  */
 #include "platform.h"
 #include "taler_error_codes.h"
 #include "taler_dbevents.h"
 #include "taler_pq_lib.h"
-#include "pg_insert_charity.h"
+#include "pg_insert_issued_receipt.h"
 #include "pg_helper.h"
 
 enum GNUNET_DB_QueryStatus
-TEH_PG_insert_charity (void *cls,
-                       const struct TALER_CharityPublicKeyP *charity_pub,
-                       const char *charity_url,
-                       const char *charity_name,
-                       uint64_t current_year,
-                       struct TALER_Amount *receipts_to_date)
+TEH_PG_insert_issued_receipt (void *cls,
+                       const struct TALER_CharitySignatureP *charity_sig,
+                       const uint64_t charity_id,
+                       const struct TALER_DonationReceiptHashP h_receipt,
+                       const struct TALER_Amount *amount)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (charity_pub),
-    GNUNET_PQ_query_param_string (charity_name),
-    GNUNET_PQ_query_param_string (charity_url),
-    GNUNET_PQ_query_param_uint64 (current_year),
-    TALER_PQ_query_param_amount (receipts_to_date),
+    GNUNET_PQ_query_param_auto_from_type (charity_sig),
+    GNUNET_PQ_query_param_uint64 (charity_id),
+    GNUNET_PQ_query_param_auto_from_type (h_receipt),
+    GNUNET_PQ_query_param_amount (amount),
     GNUNET_PQ_query_param_end
   };
 
-  /* used in #postgres_insert_charity() */
+  /* used in #postgres_insert_issued_receipt() */
   PREPARE (pg,
-           "insert_charity",
-           "INSERT INTO charities "
-           "(charity_pub"
-           ",charity_name"
-           ",charity_url"
-           ",current_year"
-           ",receipts_to_date"
+           "insert_issued_receipts",
+           "INSERT INTO receipts_issued "
+           "(charity_sig"
+           ",charity_id"
+           ",h_receipt"
+           ",amount"
            ") VALUES "
-           "($1, $2, $3, $4, $5);");
+           "($1, $2, $3, $4);");
   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
-                                             "insert_charity",
+                                             "insert_issued_receipt",
                                              params);
 }
diff --git a/src/donaudb/pg_insert_issued_receipt.h 
b/src/donaudb/pg_insert_issued_receipt.h
new file mode 100644
index 0000000..eec9a10
--- /dev/null
+++ b/src/donaudb/pg_insert_issued_receipt.h
@@ -0,0 +1,45 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2023 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 exchangedb/pg_insert_issued_receipt.h
+ * @brief implementation of the insert_issued_receipt function for Postgres
+ * @author Johannes Casaburi
+ */
+#ifndef PG_INSERT_ISSUED_RECEIPT_H
+#define PG_INSERT_ISSUED_RECEIPT_H
+
+#include "taler_util.h"
+#include "taler_json_lib.h"
+#include "taler_donaudb_plugin.h"
+
+/**
+ * Insert information about an auditor that will audit this exchange.
+ *
+ * @param cls closure
+ * @param auditor_pub key of the auditor
+ * @param auditor_url base URL of the auditor's REST service
+ * @param auditor_name name of the auditor (for humans)
+ * @param start_date date when the auditor was added by the offline system
+ *                      (only to be used for replay detection)
+ * @return transaction status code
+ */
+enum GNUNET_DB_QueryStatus
+TEH_PG_insert_auditor (void *cls,
+                       const struct TALER_CharitySignatureP *charity_sig,
+                       const uint64_t charity_id,
+                       const struct TALER_DonationReceiptHashP *h_receipt,
+                       const struct TALER_Amount *amount);
+#endif
diff --git a/src/donaudb/pg_insert_charity.c 
b/src/donaudb/pg_insert_submitted_receipt.c
similarity index 50%
copy from src/donaudb/pg_insert_charity.c
copy to src/donaudb/pg_insert_submitted_receipt.c
index 883acac..195f693 100644
--- a/src/donaudb/pg_insert_charity.c
+++ b/src/donaudb/pg_insert_submitted_receipt.c
@@ -14,47 +14,45 @@
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file exchangedb/pg_insert_charity.c
- * @brief Implementation of the insert_charity function for Postgres
- * @author Christian Grothoff
+ * @file donaudb/pg_insert_issed_receipt.c
+ * @brief Implementation of the insert_submitted_receipt function for Postgres
+ * @author Johannes Casaburi
  */
 #include "platform.h"
 #include "taler_error_codes.h"
 #include "taler_dbevents.h"
 #include "taler_pq_lib.h"
-#include "pg_insert_charity.h"
+#include "pg_insert_submitted_receipt.h"
 #include "pg_helper.h"
 
 enum GNUNET_DB_QueryStatus
-TEH_PG_insert_charity (void *cls,
-                       const struct TALER_CharityPublicKeyP *charity_pub,
-                       const char *charity_url,
-                       const char *charity_name,
-                       uint64_t current_year,
-                       struct TALER_Amount *receipts_to_date)
+TEH_PG_insert_submitted_receipt (void *cls,
+                       const struct TALER_TaxNumberHashP *h_tax_number,
+                       const struct TALER_CsNonce *nonce,
+                       const struct TALER_DonationUnitPublicKey 
*donation_unit_pub,
+                       const struct TALER_DonauSignatureP *donau_sig,
+                       const uint64_t donation_year)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (charity_pub),
-    GNUNET_PQ_query_param_string (charity_name),
-    GNUNET_PQ_query_param_string (charity_url),
-    GNUNET_PQ_query_param_uint64 (current_year),
-    TALER_PQ_query_param_amount (receipts_to_date),
+    GNUNET_PQ_query_param_auto_from_type (h_tax_number),
+    GNUNET_PQ_query_param_auto_from_type (nonce),
+    GNUNET_PQ_query_param_auto_from_type (donau_sig),
+    GNUNET_PQ_query_param_uint64 (donation_year),
     GNUNET_PQ_query_param_end
   };
 
-  /* used in #postgres_insert_charity() */
+  /* used in #postgres_insert_submitted_receipt() */
   PREPARE (pg,
-           "insert_charity",
-           "INSERT INTO charities "
-           "(charity_pub"
-           ",charity_name"
-           ",charity_url"
-           ",current_year"
-           ",receipts_to_date"
+           "insert_submitted_receipt",
+           "INSERT INTO receipts_submitted "
+           "(h_tax_number"
+           ",nonce"
+           ",donau_sig"
+           ",donation_year"
            ") VALUES "
-           "($1, $2, $3, $4, $5);");
+           "($1, $2, $3, $4);");
   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
-                                             "insert_charity",
+                                             "insert_submitted_receipt",
                                              params);
 }
diff --git a/src/donaudb/pg_insert_submitted_receipt.h 
b/src/donaudb/pg_insert_submitted_receipt.h
new file mode 100644
index 0000000..c7a60ae
--- /dev/null
+++ b/src/donaudb/pg_insert_submitted_receipt.h
@@ -0,0 +1,46 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2023 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 exchangedb/pg_insert_submitted_receipt.h
+ * @brief implementation of the insert_submitted_receipt function for Postgres
+ * @author Johannes Casaburi
+ */
+#ifndef PG_INSERT_SUBMITTED_RECEIPT_H
+#define PG_INSERT_SUBMITTED_RECEIPT_H
+
+#include "taler_util.h"
+#include "taler_json_lib.h"
+#include "taler_donaudb_plugin.h"
+
+/**
+ * Insert information about an auditor that will audit this exchange.
+ *
+ * @param cls closure
+ * @param auditor_pub key of the auditor
+ * @param auditor_url base URL of the auditor's REST service
+ * @param auditor_name name of the auditor (for humans)
+ * @param start_date date when the auditor was added by the offline system
+ *                      (only to be used for replay detection)
+ * @return transaction status code
+ */
+enum GNUNET_DB_QueryStatus
+TEH_PG_insert_submitted_receipt (void *cls,
+                       const struct TALER_TaxNumberHashP *h_tax_number,
+                       const struct TALER_CsNonce *nonce,
+                       const struct TALER_DonationUnitPublicKey 
*donation_unit_pub,
+                       const struct TALER_DonauSignatureP *donau_sig,
+                       const uint64_t donation_year);
+#endif

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]