commit 6de96269d59c66dbede9177f4e65f8d2cc828f2d
parent 362bf0c5bd2270ed6a54dfbdfd83702dca892797
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 20 Jul 2021 20:26:55 +0200
-support Florian DB API
Diffstat:
2 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
@@ -593,6 +593,40 @@ postgres_lookup_instances (void *cls,
/**
+ * Lookup authentication data of an instance.
+ *
+ * @param cls closure
+ * @param instance_id instance to query
+ * @param[out] ias where to store the auth data
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_lookup_instance_auth (
+ void *cls,
+ const char *instance_id,
+ struct TALER_MERCHANTDB_InstanceAuthSettings *ias)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (instance_id),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_auto_from_type ("auth_hash",
+ &ias->auth_hash),
+ GNUNET_PQ_result_spec_auto_from_type ("auth_salt",
+ &ias->auth_salt),
+ GNUNET_PQ_result_spec_end
+ };
+
+ check_connection (pg);
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "lookup_instance_auth",
+ params,
+ rs);
+}
+
+
+/**
* Insert information about an instance into our database.
*
* @param cls closure
@@ -6288,6 +6322,16 @@ postgres_connect (void *cls)
" WHERE merchant_serial=$1",
1),
/* for postgres_lookup_instances() */
+ GNUNET_PQ_make_prepare ("lookup_instance_auth",
+ "SELECT"
+ " auth_hash"
+ ",auth_salt"
+ " FROM merchant_instances"
+ /* only use 'active' instances */
+ " JOIN merchant_keys USING (merchant_id)"
+ " WHERE merchant_id=$1",
+ 1),
+ /* for postgres_lookup_instances() */
GNUNET_PQ_make_prepare ("lookup_instances",
"SELECT"
" merchant_serial"
@@ -8750,6 +8794,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
plugin->rollback = &postgres_rollback;
plugin->commit = &postgres_commit;
plugin->lookup_instances = &postgres_lookup_instances;
+ plugin->lookup_instance_auth = &postgres_lookup_instance_auth;
plugin->insert_instance = &postgres_insert_instance;
plugin->insert_account = &postgres_insert_account;
plugin->delete_instance_private_key = &postgres_delete_instance_private_key;
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
@@ -783,6 +783,19 @@ struct TALER_MERCHANTDB_Plugin
void *cb_cls);
/**
+ * Lookup authentication data of an instance.
+ *
+ * @param cls closure
+ * @param instance_id instance to query
+ * @param[out] ias where to store the auth data
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_instance_auth)(void *cls,
+ const char *instance_id,
+ struct TALER_MERCHANTDB_InstanceAuthSettings *ias);
+
+
+ /**
* Insert information about an instance into our database.
*
* @param cls closure