[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 04/05: db
From: |
gnunet |
Subject: |
[taler-anastasis] 04/05: db |
Date: |
Tue, 07 Apr 2020 01:02:16 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit 3b4bd7e6588bc2e3b071a35f58deb15ec3a07727
Author: Dennis Neufeld <address@hidden>
AuthorDate: Mon Apr 6 22:55:38 2020 +0000
db
---
src/backend/anastasis-httpd_policy_upload.c | 14 ++++++--------
src/stasis/plugin_anastasis_postgres.c | 14 +++++++++++---
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/backend/anastasis-httpd_policy_upload.c
b/src/backend/anastasis-httpd_policy_upload.c
index 9484154..b762d45 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -257,14 +257,8 @@ make_payment_request (const char *order_id)
unsigned int
amount_to_post_counter (const struct TALER_Amount *amount)
{
- /* FIXME: reasonable conversion from Taler Amount to post counter */
- if ((0 == strcmp (amount->currency, "CHF")) || (0 == strcmp
(amount->currency,
- "EUR")))
- {
- // FIXME: check if long long value is in int range
- return (int) amount->value * 10;
- }
- return 0;
+ // FIXME: some logic to convert an amount to an unsigned integer (counter)
+ return 10;
}
@@ -322,7 +316,11 @@ proposal_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Storing payment request for order `%s'\n",
order_id);
+
post_counter = amount_to_post_counter (&AH_annual_fee);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Post counter to save: %i\n",
+ post_counter);
qs = db->record_payment (db->cls,
&puc->account,
post_counter,
diff --git a/src/stasis/plugin_anastasis_postgres.c
b/src/stasis/plugin_anastasis_postgres.c
index 16ca41c..c45ab4c 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -511,7 +511,8 @@ postgres_store_recovery_document (void *cls,
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("post_counter", &postcounter),
+ GNUNET_PQ_result_spec_uint32 ("post_counter",
+ &postcounter),
GNUNET_PQ_result_spec_end
};
@@ -519,6 +520,9 @@ postgres_store_recovery_document (void *cls,
"postcounter_select",
params,
rs);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Post counter from db: %i\n",
+ postcounter);
}
switch (qs)
@@ -837,6 +841,10 @@ postgres_record_payment (void *cls,
const struct ANASTASIS_PaymentSecretP *payment_secret,
const struct TALER_Amount *amount)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Post counter to save: %i\n",
+ post_counter);
+
struct PostgresClosure *pg = cls;
enum ANASTASIS_DB_QueryStatus qs;
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
@@ -857,7 +865,7 @@ postgres_record_payment (void *cls,
// if user exists, otherwise we have to create one
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Public key used to query db: %s\n",
+ "Public key used to query user db: %s\n",
TALER_B2S (anastasis_pub));
struct GNUNET_PQ_QueryParam params[] = {
@@ -1382,7 +1390,7 @@ libanastasis_plugin_db_postgres_init (void *cls)
GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS anastasis_payment"
"(payment_id BIGSERIAL PRIMARY KEY,"
" user_id BYTEA NOT NULL REFERENCES
anastasis_user(user_id),"
- " post_counter INTEGER,"
+ " post_counter INT4 NOT NULL DEFAULT 0
CHECK(post_counter >= 0),"
" amount_val INT8 NOT NULL," /* amount we were
paid */
" amount_frac INT4 NOT NULL,"
" payment_identifier BYTEA NOT NULL
CHECK(LENGTH(payment_identifier)=32),"
--
To stop receiving notification emails like this one, please contact
address@hidden.