gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 05/10: Factor out delete_instance_private_key (shit job


From: gnunet
Subject: [taler-merchant] 05/10: Factor out delete_instance_private_key (shit job)
Date: Tue, 09 May 2023 18:05:18 +0200

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

ivan-avalos pushed a commit to branch master
in repository merchant.

commit 90421ed05ded9e4460cb6fdca5c3e3b494737ece
Author: Iván Ávalos <avalos@disroot.org>
AuthorDate: Mon May 8 21:19:23 2023 -0600

    Factor out delete_instance_private_key (shit job)
---
 src/backenddb/Makefile.am                      |  1 +
 src/backenddb/pg_delete_instance_private_key.c | 50 ++++++++++++++++++++++++++
 src/backenddb/pg_delete_instance_private_key.h | 39 ++++++++++++++++++++
 src/backenddb/plugin_merchantdb_postgres.c     | 36 ++-----------------
 4 files changed, 93 insertions(+), 33 deletions(-)

diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am
index 69c83083..2c4c2dc9 100644
--- a/src/backenddb/Makefile.am
+++ b/src/backenddb/Makefile.am
@@ -69,6 +69,7 @@ libtaler_plugin_merchantdb_postgres_la_SOURCES = \
   pg_insert_instance.h pg_insert_instance.c \
   pg_account_kyc_set_status.h pg_account_kyc_set_status.c \
   pg_account_kyc_get_status.h pg_account_kyc_get_status.c \
+  pg_delete_instance_private_key.h pg_delete_instance_private_key.c \
   plugin_merchantdb_postgres.c  pg_helper.h
 libtaler_plugin_merchantdb_postgres_la_LIBADD = \
   $(LTLIBINTL)
diff --git a/src/backenddb/pg_delete_instance_private_key.c 
b/src/backenddb/pg_delete_instance_private_key.c
new file mode 100644
index 00000000..5c7356ad
--- /dev/null
+++ b/src/backenddb/pg_delete_instance_private_key.c
@@ -0,0 +1,50 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2022 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 backenddb/pg_delete_instance_private_key.c
+ * @brief Implementation of the delete_instance_private_key function for 
Postgres
+ * @author Iván Ávalos
+ */
+#include "platform.h"
+#include <taler/taler_error_codes.h>
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
+#include "pg_delete_instance_private_key.h"
+#include "pg_helper.h"
+
+enum GNUNET_DB_QueryStatus
+TMH_PG_delete_instance_private_key (
+  void *cls,
+  const char *merchant_id)
+{
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_string (merchant_id),
+    GNUNET_PQ_query_param_end
+  };
+
+  check_connection (pg);
+  PREPARE (pg,
+           "delete_key",
+           "DELETE FROM merchant_keys"
+           " USING merchant_instances"
+           " WHERE merchant_keys.merchant_serial"
+           "   = merchant_instances.merchant_serial"
+           " AND merchant_instances.merchant_id = $1");
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "delete_key",
+                                             params);
+}
diff --git a/src/backenddb/pg_delete_instance_private_key.h 
b/src/backenddb/pg_delete_instance_private_key.h
new file mode 100644
index 00000000..9a8b3be6
--- /dev/null
+++ b/src/backenddb/pg_delete_instance_private_key.h
@@ -0,0 +1,39 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2022 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 backenddb/pg_delete_instance_private_key.h
+ * @brief implementation of the delete_instance_private_key function for 
Postgres
+ * @author Christian Grothoff
+ */
+#ifndef PG_DELETE_INSTANCE_PRIVATE_KEY_H
+#define PG_DELETE_INSTANCE_PRIVATE_KEY_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "taler_merchantdb_plugin.h"
+
+/**
+ * Delete private key of an instance from our database.
+ *
+ * @param cls closure
+ * @param merchant_id identifier of the instance
+ * @return database result code
+ */
+enum GNUNET_DB_QueryStatus
+TMH_PG_delete_instance_private_key (void *cls,
+                                    const char *merchant_id);
+
+#endif
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index b1aa8d2c..80f03871 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -47,6 +47,7 @@
 #include "pg_insert_instance.h"
 #include "pg_account_kyc_set_status.h"
 #include "pg_account_kyc_get_status.h"
+#include "pg_delete_instance_private_key.h"
 #include "pg_set_transfer_status_to_confirmed.h"
 
 
@@ -324,31 +325,6 @@ postgres_commit (void *cls)
 }
 
 
-/**
- * Delete private key of an instance from our database.
- *
- * @param cls closure
- * @param merchant_id identifier of the instance
- * @return database result code
- */
-static enum GNUNET_DB_QueryStatus
-postgres_delete_instance_private_key (
-  void *cls,
-  const char *merchant_id)
-{
-  struct PostgresClosure *pg = cls;
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_string (merchant_id),
-    GNUNET_PQ_query_param_end
-  };
-
-  check_connection (pg);
-  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
-                                             "delete_key",
-                                             params);
-}
-
-
 /**
  * Purge an instance and all associated information from our database.
  * Highly likely to cause undesired data loss. Use with caution.
@@ -6712,13 +6688,6 @@ postgres_connect (void *cls)
   struct GNUNET_PQ_PreparedStatement ps[] = {
     GNUNET_PQ_make_prepare ("end_transaction",
                             "COMMIT"),
-    /* for postgres_delete_instance_private_key() */
-    GNUNET_PQ_make_prepare ("delete_key",
-                            "DELETE FROM merchant_keys"
-                            " USING merchant_instances"
-                            " WHERE merchant_keys.merchant_serial"
-                            "   = merchant_instances.merchant_serial"
-                            " AND merchant_instances.merchant_id = $1"),
     /* for postgres_purge_instance() */
     GNUNET_PQ_make_prepare ("purge_instance",
                             "DELETE FROM merchant_instances"
@@ -9074,7 +9043,8 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
     = &TMH_PG_account_kyc_set_status;
   plugin->account_kyc_get_status
     = &TMH_PG_account_kyc_get_status;
-  plugin->delete_instance_private_key = &postgres_delete_instance_private_key;
+  plugin->delete_instance_private_key
+    = &TMH_PG_delete_instance_private_key;
   plugin->purge_instance = &postgres_purge_instance;
   plugin->update_instance = &postgres_update_instance;
   plugin->update_instance_auth = &postgres_update_instance_auth;

-- 
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]