aboutsummaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-08-27 00:50:54 +0200
committerChristian Grothoff <christian@grothoff.org>2024-08-27 00:50:54 +0200
commitb7ff489a848d6992f4500fab470f0392ad8c8a1b (patch)
treeaedbe9a6f3bdd1030eea9f5df83bd668a457559b /src/backenddb
parent0891c96a527c827501169f842c02deb04515ddaa (diff)
-misc code cleanups
Diffstat (limited to 'src/backenddb')
-rw-r--r--src/backenddb/pg_insert_deposit_confirmation.c2
-rw-r--r--src/backenddb/pg_insert_spent_token.c20
-rw-r--r--src/backenddb/pg_insert_spent_token.h13
-rw-r--r--src/backenddb/pg_insert_token_family.c59
-rw-r--r--src/backenddb/pg_insert_token_family_key.c37
-rw-r--r--src/backenddb/pg_lookup_all_products.c2
-rw-r--r--src/backenddb/pg_lookup_token_family.c9
-rw-r--r--src/backenddb/pg_select_account.c2
8 files changed, 71 insertions, 73 deletions
diff --git a/src/backenddb/pg_insert_deposit_confirmation.c b/src/backenddb/pg_insert_deposit_confirmation.c
index f23bf252..7e1d01d1 100644
--- a/src/backenddb/pg_insert_deposit_confirmation.c
+++ b/src/backenddb/pg_insert_deposit_confirmation.c
@@ -22,7 +22,7 @@
#include <taler/taler_error_codes.h>
#include <taler/taler_dbevents.h>
#include <taler/taler_pq_lib.h>
-#include "pg_insert_deposit.h"
+#include "pg_insert_deposit_confirmation.h"
#include "pg_helper.h"
diff --git a/src/backenddb/pg_insert_spent_token.c b/src/backenddb/pg_insert_spent_token.c
index 1f11c5a3..bb3ffcdc 100644
--- a/src/backenddb/pg_insert_spent_token.c
+++ b/src/backenddb/pg_insert_spent_token.c
@@ -18,9 +18,6 @@
* @brief Implementation of the insert_spent_token function for Postgres
* @author Christian Blättler
*/
-#ifndef PG_INSERT_SPENT_TOKEN_H
-#define PG_INSERT_SPENT_TOKEN_H
-
#include "platform.h"
#include <taler/taler_error_codes.h>
#include <taler/taler_dbevents.h>
@@ -28,16 +25,17 @@
#include "pg_insert_spent_token.h"
#include "pg_helper.h"
+
enum GNUNET_DB_QueryStatus
-TMH_PG_insert_spent_token (void *cls,
- const struct TALER_PrivateContractHashP *h_contract_terms,
- const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub,
- const struct TALER_TokenUsePublicKeyP *use_pub,
- const struct TALER_TokenUseSignatureP *use_sig,
- const struct TALER_TokenIssueSignatureP *issue_sig)
+TMH_PG_insert_spent_token (
+ void *cls,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub,
+ const struct TALER_TokenUsePublicKeyP *use_pub,
+ const struct TALER_TokenUseSignatureP *use_sig,
+ const struct TALER_TokenIssueSignatureP *issue_sig)
{
struct PostgresClosure *pg = cls;
-
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (h_issue_pub),
GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
@@ -68,5 +66,3 @@ TMH_PG_insert_spent_token (void *cls,
"spent_token_insert",
params);
}
-
-#endif \ No newline at end of file
diff --git a/src/backenddb/pg_insert_spent_token.h b/src/backenddb/pg_insert_spent_token.h
index c2857c45..c618213f 100644
--- a/src/backenddb/pg_insert_spent_token.h
+++ b/src/backenddb/pg_insert_spent_token.h
@@ -36,11 +36,12 @@
* @return database result code
*/
enum GNUNET_DB_QueryStatus
-TMH_PG_insert_spent_token (void *cls,
- const struct TALER_PrivateContractHashP *h_contract_terms,
- const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub,
- const struct TALER_TokenUsePublicKeyP *use_pub,
- const struct TALER_TokenUseSignatureP *use_sig,
- const struct TALER_TokenIssueSignatureP *issue_sig);
+TMH_PG_insert_spent_token (
+ void *cls,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub,
+ const struct TALER_TokenUsePublicKeyP *use_pub,
+ const struct TALER_TokenUseSignatureP *use_sig,
+ const struct TALER_TokenIssueSignatureP *issue_sig);
#endif
diff --git a/src/backenddb/pg_insert_token_family.c b/src/backenddb/pg_insert_token_family.c
index f533a2fb..81a1890b 100644
--- a/src/backenddb/pg_insert_token_family.c
+++ b/src/backenddb/pg_insert_token_family.c
@@ -29,38 +29,25 @@ enum GNUNET_DB_QueryStatus
TMH_PG_insert_token_family (void *cls,
const char *instance_id,
const char *token_family_slug,
- const struct TALER_MERCHANTDB_TokenFamilyDetails *details)
+ const struct TALER_MERCHANTDB_TokenFamilyDetails *
+ details)
{
struct PostgresClosure *pg = cls;
-
const char *kind;
+
switch (details->kind)
{
- case TALER_MERCHANTDB_TFK_Discount:
- kind = "discount";
- break;
- case TALER_MERCHANTDB_TFK_Subscription:
- kind = "subscription";
- break;
- default:
- GNUNET_break (0);
- return GNUNET_DB_STATUS_HARD_ERROR;
+ case TALER_MERCHANTDB_TFK_Discount:
+ kind = "discount";
+ break;
+ case TALER_MERCHANTDB_TFK_Subscription:
+ kind = "subscription";
+ break;
+ default:
+ GNUNET_break (0);
+ return GNUNET_DB_STATUS_HARD_ERROR;
}
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_string (token_family_slug),
- GNUNET_PQ_query_param_string (details->name),
- GNUNET_PQ_query_param_string (details->description),
- TALER_PQ_query_param_json (details->description_i18n),
- GNUNET_PQ_query_param_timestamp (&details->valid_after),
- GNUNET_PQ_query_param_timestamp (&details->valid_before),
- GNUNET_PQ_query_param_relative_time (&details->duration),
- GNUNET_PQ_query_param_relative_time (&details->rounding),
- GNUNET_PQ_query_param_string (kind),
- GNUNET_PQ_query_param_end
- };
-
check_connection (pg);
PREPARE (pg,
"insert_token_family",
@@ -78,7 +65,23 @@ TMH_PG_insert_token_family (void *cls,
" SELECT merchant_serial, $2, $3, $4, $5, $6, $7, $8, $9, $10"
" FROM merchant_instances"
" WHERE merchant_id=$1");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "insert_token_family",
- params);
+ {
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (instance_id),
+ GNUNET_PQ_query_param_string (token_family_slug),
+ GNUNET_PQ_query_param_string (details->name),
+ GNUNET_PQ_query_param_string (details->description),
+ TALER_PQ_query_param_json (details->description_i18n),
+ GNUNET_PQ_query_param_timestamp (&details->valid_after),
+ GNUNET_PQ_query_param_timestamp (&details->valid_before),
+ GNUNET_PQ_query_param_relative_time (&details->duration),
+ GNUNET_PQ_query_param_relative_time (&details->rounding),
+ GNUNET_PQ_query_param_string (kind),
+ GNUNET_PQ_query_param_end
+ };
+
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "insert_token_family",
+ params);
+ }
}
diff --git a/src/backenddb/pg_insert_token_family_key.c b/src/backenddb/pg_insert_token_family_key.c
index b6602931..2fcbf026 100644
--- a/src/backenddb/pg_insert_token_family_key.c
+++ b/src/backenddb/pg_insert_token_family_key.c
@@ -55,20 +55,8 @@ TMH_PG_insert_token_family_key (void *cls,
case GNUNET_CRYPTO_BSA_INVALID:
return GNUNET_DB_STATUS_HARD_ERROR;
}
-
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (token_family_slug),
- GNUNET_PQ_query_param_blind_sign_pub (pub->public_key),
- GNUNET_PQ_query_param_auto_from_type (&pub->public_key->pub_key_hash),
- GNUNET_PQ_query_param_blind_sign_priv (priv->private_key),
- GNUNET_PQ_query_param_timestamp (&valid_after),
- GNUNET_PQ_query_param_timestamp (&valid_before),
- GNUNET_PQ_query_param_string (cipher),
- GNUNET_PQ_query_param_end
- };
-
- GNUNET_assert (pub->public_key->cipher == priv->private_key->cipher);
-
+ GNUNET_assert (pub->public_key->cipher ==
+ priv->private_key->cipher);
GNUNET_assert (0 ==
GNUNET_memcmp (&pub_hash,
&pub->public_key->pub_key_hash));
@@ -90,7 +78,20 @@ TMH_PG_insert_token_family_key (void *cls,
" SELECT token_family_serial, $2, $3, $4, $5, $6, $7"
" FROM merchant_token_families"
" WHERE slug = $1");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "token_family_key_insert",
- params);
-} \ No newline at end of file
+ {
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (token_family_slug),
+ GNUNET_PQ_query_param_blind_sign_pub (pub->public_key),
+ GNUNET_PQ_query_param_auto_from_type (&pub->public_key->pub_key_hash),
+ GNUNET_PQ_query_param_blind_sign_priv (priv->private_key),
+ GNUNET_PQ_query_param_timestamp (&valid_after),
+ GNUNET_PQ_query_param_timestamp (&valid_before),
+ GNUNET_PQ_query_param_string (cipher),
+ GNUNET_PQ_query_param_end
+ };
+
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "token_family_key_insert",
+ params);
+ }
+}
diff --git a/src/backenddb/pg_lookup_all_products.c b/src/backenddb/pg_lookup_all_products.c
index b2dbfe88..1f20a996 100644
--- a/src/backenddb/pg_lookup_all_products.c
+++ b/src/backenddb/pg_lookup_all_products.c
@@ -22,7 +22,7 @@
#include <taler/taler_error_codes.h>
#include <taler/taler_dbevents.h>
#include <taler/taler_pq_lib.h>
-#include "pg_lookup_products.h"
+#include "pg_lookup_all_products.h"
#include "pg_helper.h"
/**
diff --git a/src/backenddb/pg_lookup_token_family.c b/src/backenddb/pg_lookup_token_family.c
index e5c9d518..943e0ee7 100644
--- a/src/backenddb/pg_lookup_token_family.c
+++ b/src/backenddb/pg_lookup_token_family.c
@@ -53,7 +53,6 @@ TMH_PG_lookup_token_family (void *cls,
else
{
char *kind;
-
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_string ("slug",
&details->slug),
@@ -77,6 +76,7 @@ TMH_PG_lookup_token_family (void *cls,
&details->used),
GNUNET_PQ_result_spec_end
};
+ enum GNUNET_DB_QueryStatus qs;
check_connection (pg);
PREPARE (pg,
@@ -97,17 +97,15 @@ TMH_PG_lookup_token_family (void *cls,
" USING (merchant_serial)"
" WHERE merchant_instances.merchant_id=$1"
" AND merchant_token_families.slug=$2");
- enum GNUNET_DB_QueryStatus qs;
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"lookup_token_family",
params,
rs);
-
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
{
- if (0 == strcmp(kind, "discount"))
+ if (0 == strcmp (kind, "discount"))
details->kind = TALER_MERCHANTDB_TFK_Discount;
- else if (0 == strcmp(kind, "subscription"))
+ else if (0 == strcmp (kind, "subscription"))
details->kind = TALER_MERCHANTDB_TFK_Subscription;
else
{
@@ -115,7 +113,6 @@ TMH_PG_lookup_token_family (void *cls,
return GNUNET_DB_STATUS_HARD_ERROR;
}
}
-
return qs;
}
}
diff --git a/src/backenddb/pg_select_account.c b/src/backenddb/pg_select_account.c
index 29fda632..9d48e421 100644
--- a/src/backenddb/pg_select_account.c
+++ b/src/backenddb/pg_select_account.c
@@ -22,7 +22,7 @@
#include <taler/taler_error_codes.h>
#include <taler/taler_dbevents.h>
#include <taler/taler_pq_lib.h>
-#include "pg_select_accounts.h"
+#include "pg_select_account.h"
#include "pg_helper.h"