summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backenddb/Makefile.am2
-rw-r--r--src/backenddb/pg_purge_instance.c54
-rw-r--r--src/backenddb/pg_purge_instance.h40
-rw-r--r--src/backenddb/pg_update_instance.c80
-rw-r--r--src/backenddb/pg_update_instance.h39
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c99
6 files changed, 221 insertions, 93 deletions
diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am
index 2c4c2dc9..da0b4a5b 100644
--- a/src/backenddb/Makefile.am
+++ b/src/backenddb/Makefile.am
@@ -70,6 +70,8 @@ libtaler_plugin_merchantdb_postgres_la_SOURCES = \
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 \
+ pg_purge_instance.h pg_purge_instance.c \
+ pg_update_instance.h pg_update_instance.c \
plugin_merchantdb_postgres.c pg_helper.h
libtaler_plugin_merchantdb_postgres_la_LIBADD = \
$(LTLIBINTL)
diff --git a/src/backenddb/pg_purge_instance.c b/src/backenddb/pg_purge_instance.c
new file mode 100644
index 00000000..74ca5613
--- /dev/null
+++ b/src/backenddb/pg_purge_instance.c
@@ -0,0 +1,54 @@
+/*
+ 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_purge_instance.c
+ * @brief Implementation of the purge_instance 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_purge_instance.h"
+#include "pg_helper.h"
+
+/**
+ * Purge an instance and all associated information from our database.
+ * Highly likely to cause undesired data loss. Use with caution.
+ *
+ * @param cls closure
+ * @param merchant_id identifier of the instance
+ * @return database result code
+ */
+enum GNUNET_DB_QueryStatus
+TMH_PG_purge_instance (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,
+ "purge_instance",
+ "DELETE FROM merchant_instances"
+ " WHERE merchant_instances.merchant_id = $1");
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "purge_instance",
+ params);
+}
diff --git a/src/backenddb/pg_purge_instance.h b/src/backenddb/pg_purge_instance.h
new file mode 100644
index 00000000..3df05bd8
--- /dev/null
+++ b/src/backenddb/pg_purge_instance.h
@@ -0,0 +1,40 @@
+/*
+ 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_purge_instance.h
+ * @brief implementation of the purge_instance function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef PG_PURGE_INSTANCE_H
+#define PG_PURGE_INSTANCE_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "taler_merchantdb_plugin.h"
+
+/**
+ * Purge an instance and all associated information from our database.
+ * Highly likely to cause undesired data loss. Use with caution.
+ *
+ * @param cls closure
+ * @param merchant_id identifier of the instance
+ * @return database result code
+ */
+enum GNUNET_DB_QueryStatus
+TMH_PG_purge_instance (void *cls,
+ const char *merchant_id);
+
+#endif
diff --git a/src/backenddb/pg_update_instance.c b/src/backenddb/pg_update_instance.c
new file mode 100644
index 00000000..5de6032d
--- /dev/null
+++ b/src/backenddb/pg_update_instance.c
@@ -0,0 +1,80 @@
+/*
+ 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_update_instance.c
+ * @brief Implementation of the update_instance 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_update_instance.h"
+#include "pg_helper.h"
+
+enum GNUNET_DB_QueryStatus
+TMH_PG_update_instance (void *cls,
+ const struct TALER_MERCHANTDB_InstanceSettings *is)
+{
+ struct PostgresClosure *pg = cls;
+ uint32_t ut32 = (uint32_t) is->ut;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (is->id),
+ GNUNET_PQ_query_param_string (is->name),
+ TALER_PQ_query_param_json (is->address),
+ TALER_PQ_query_param_json (is->jurisdiction),
+ TALER_PQ_query_param_amount (&is->default_max_deposit_fee),
+ TALER_PQ_query_param_amount (&is->default_max_wire_fee),
+ GNUNET_PQ_query_param_uint32 (&is->default_wire_fee_amortization),
+ GNUNET_PQ_query_param_relative_time (
+ &is->default_wire_transfer_delay),
+ GNUNET_PQ_query_param_relative_time (&is->default_pay_delay),
+ (NULL == is->website)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (is->website),
+ (NULL == is->email)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (is->email),
+ (NULL == is->logo)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (is->logo),
+ GNUNET_PQ_query_param_uint32 (&ut32),
+ GNUNET_PQ_query_param_end
+ };
+
+ check_connection (pg);
+ PREPARE (pg,
+ "update_instance",
+ "UPDATE merchant_instances SET"
+ " merchant_name=$2"
+ ",address=$3"
+ ",jurisdiction=$4"
+ ",default_max_deposit_fee_val=$5"
+ ",default_max_deposit_fee_frac=$6"
+ ",default_max_wire_fee_val=$7"
+ ",default_max_wire_fee_frac=$8"
+ ",default_wire_fee_amortization=$9"
+ ",default_wire_transfer_delay=$10"
+ ",default_pay_delay=$11"
+ ",website=$12"
+ ",email=$13"
+ ",logo=$14"
+ ",user_type=$15"
+ " WHERE merchant_id=$1");
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "update_instance",
+ params);
+}
diff --git a/src/backenddb/pg_update_instance.h b/src/backenddb/pg_update_instance.h
new file mode 100644
index 00000000..9c8c1d22
--- /dev/null
+++ b/src/backenddb/pg_update_instance.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_update_instance.h
+ * @brief implementation of the update_instance function for Postgres
+ * @author Iván Ávalos
+ */
+#ifndef PG_UPDATE_INSTANCE_H
+#define PG_UPDATE_INSTANCE_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "taler_merchantdb_plugin.h"
+
+/**
+ * Update information about an instance into our database.
+ *
+ * @param cls closure
+ * @param is details about the instance
+ * @return database result code
+ */
+enum GNUNET_DB_QueryStatus
+TMH_PG_update_instance (void *cls,
+ const struct TALER_MERCHANTDB_InstanceSettings *is);
+
+#endif
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 80f03871..61e35837 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -48,6 +48,8 @@
#include "pg_account_kyc_set_status.h"
#include "pg_account_kyc_get_status.h"
#include "pg_delete_instance_private_key.h"
+#include "pg_purge_instance.h"
+#include "pg_update_instance.h"
#include "pg_set_transfer_status_to_confirmed.h"
@@ -326,75 +328,6 @@ postgres_commit (void *cls)
/**
- * Purge an instance and all associated information from our database.
- * Highly likely to cause undesired data loss. Use with caution.
- *
- * @param cls closure
- * @param merchant_id identifier of the instance
- * @return database result code
- */
-static enum GNUNET_DB_QueryStatus
-postgres_purge_instance (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,
- "purge_instance",
- params);
-}
-
-
-/**
- * Update information about an instance into our database.
- *
- * @param cls closure
- * @param is details about the instance
- * @return database result code
- */
-static enum GNUNET_DB_QueryStatus
-postgres_update_instance (void *cls,
- const struct TALER_MERCHANTDB_InstanceSettings *is)
-{
- struct PostgresClosure *pg = cls;
- uint32_t ut32 = (uint32_t) is->ut;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (is->id),
- GNUNET_PQ_query_param_string (is->name),
- TALER_PQ_query_param_json (is->address),
- TALER_PQ_query_param_json (is->jurisdiction),
- TALER_PQ_query_param_amount (&is->default_max_deposit_fee),
- TALER_PQ_query_param_amount (&is->default_max_wire_fee),
- GNUNET_PQ_query_param_uint32 (&is->default_wire_fee_amortization),
- GNUNET_PQ_query_param_relative_time (
- &is->default_wire_transfer_delay),
- GNUNET_PQ_query_param_relative_time (&is->default_pay_delay),
- (NULL == is->website)
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_string (is->website),
- (NULL == is->email)
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_string (is->email),
- (NULL == is->logo)
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_string (is->logo),
- GNUNET_PQ_query_param_uint32 (&ut32),
- GNUNET_PQ_query_param_end
- };
-
- check_connection (pg);
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "update_instance",
- params);
-}
-
-
-/**
* Update information about an instance's authentication settings
* into our database.
*
@@ -6688,28 +6621,6 @@ postgres_connect (void *cls)
struct GNUNET_PQ_PreparedStatement ps[] = {
GNUNET_PQ_make_prepare ("end_transaction",
"COMMIT"),
- /* for postgres_purge_instance() */
- GNUNET_PQ_make_prepare ("purge_instance",
- "DELETE FROM merchant_instances"
- " WHERE merchant_instances.merchant_id = $1"),
- /* for postgres_update_instance() */
- GNUNET_PQ_make_prepare ("update_instance",
- "UPDATE merchant_instances SET"
- " merchant_name=$2"
- ",address=$3"
- ",jurisdiction=$4"
- ",default_max_deposit_fee_val=$5"
- ",default_max_deposit_fee_frac=$6"
- ",default_max_wire_fee_val=$7"
- ",default_max_wire_fee_frac=$8"
- ",default_wire_fee_amortization=$9"
- ",default_wire_transfer_delay=$10"
- ",default_pay_delay=$11"
- ",website=$12"
- ",email=$13"
- ",logo=$14"
- ",user_type=$15"
- " WHERE merchant_id=$1"),
/* for postgres_update_instance_auth() */
GNUNET_PQ_make_prepare ("update_instance_auth",
"UPDATE merchant_instances SET"
@@ -9045,8 +8956,10 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
= &TMH_PG_account_kyc_get_status;
plugin->delete_instance_private_key
= &TMH_PG_delete_instance_private_key;
- plugin->purge_instance = &postgres_purge_instance;
- plugin->update_instance = &postgres_update_instance;
+ plugin->purge_instance
+ = &TMH_PG_purge_instance;
+ plugin->update_instance
+ = &TMH_PG_update_instance;
plugin->update_instance_auth = &postgres_update_instance_auth;
plugin->activate_account = &postgres_activate_account;
plugin->inactivate_account = &postgres_inactivate_account;