gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-anastasis] 02/02: Worked on postgres plugin


From: gnunet
Subject: [GNUnet-SVN] [taler-anastasis] 02/02: Worked on postgres plugin
Date: Tue, 15 Oct 2019 13:07:38 +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 1219ce3ba0368a32401c5b1c233ad7d910bca72a
Author: Dennis Neufeld <address@hidden>
AuthorDate: Tue Oct 15 13:07:32 2019 +0200

    Worked on postgres plugin
---
 src/backup-db/plugin_anastasis_postgres.c | 66 ++++++++++++++++++++++++++-----
 src/include/anastasis_database_plugin.h   | 17 ++++----
 2 files changed, 66 insertions(+), 17 deletions(-)

diff --git a/src/backup-db/plugin_anastasis_postgres.c 
b/src/backup-db/plugin_anastasis_postgres.c
index da1761e..8e698bf 100644
--- a/src/backup-db/plugin_anastasis_postgres.c
+++ b/src/backup-db/plugin_anastasis_postgres.c
@@ -209,6 +209,53 @@ postgres_commit (void *cls)
                                              params);
 }
 
+/**
+  * FIXME
+  * Upload encrypted recovery document.
+  *
+  * @param cls closure
+  * @param anastasis_pub public key of the user's account
+  * @param data contains encrypted_recovery_document
+  * @param data_size size of data blob
+  * @param payment_secret identifier for the payment, used to later charge on 
uploads
+  * @param version[OUT] set to the version assigned to the document by the 
database
+  * @return transaction status, 0 if upload could not be finished because @a 
payment_secret
+  *         did not have enough upload left; HARD error if @a payment_secret 
is unknown, ...
+  */
+static enum GNUNET_DB_QueryStatus
+postgres_store_recovery_document (void *cls,
+                                  const struct ANASTASIS_AccountPubP 
*anastasis_pub,
+                                  const void *data,
+                                  size_t data_size,
+                                  const struct
+                                  ANASTASIS_PaymentSecretP *payment_secret,
+                                  uint32_t *version)
+{
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
+    GNUNET_PQ_query_param_auto_from_type (&h_contract_terms),
+    GNUNET_PQ_query_param_end
+  };
+
+  if (GNUNET_OK !=
+      TALER_JSON_hash (contract_terms,
+                       &h_contract_terms))
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "inserting contract terms: order_id: %s, anastasis_pub: %s, 
h_contract_terms: %s.\n",
+              order_id,
+              TALER_B2S (anastasis_pub),
+              GNUNET_h2s (&h_contract_terms));
+  check_connection (pg);
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "insert_contract_terms",
+                                             params);
+}
+
 
 /**
  * FIXME
@@ -253,27 +300,28 @@ postgres_find_contract_terms_from_hash (void *cls,
  * Insert proposal data and its hashcode into db
  *
  * @param cls closure
- * @param order_id identificator of the proposal being stored
+ * @param payment_id identifier of the payment
+ * @param amount amount of taler to be paid
  * @param anastasis_pub anastasis's public key
- * @param timestamp timestamp of this proposal data
- * @param contract_terms proposal data to store
+ * @param num_uploads number of uploads the user can make
+ * @param lifetime_inc time the payment is valid till
+ * @param payment_secret payment secret which the user must provide with every 
upload
  * @return transaction status
  */
 static enum GNUNET_DB_QueryStatus
 postgres_record_payment (void *cls,
+                         const *payment_id,
                          const struct TALER_Amount *amount,
-                         const struct ANASTASIS_AccountPubP *account_pub,
-                         unsigned int num_uploads,
+                         const struct ANASTASIS_AccountPubP *anastasis_pub,
+                         unsigned int *num_uploads,
                          struct GNUNET_TIME_Relative lifetime_inc,
                          const struct ANASTASIS_PaymentSecretP *payment_secret)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_string (order_id),
+    GNUNET_PQ_query_param_string (payment_id),
     GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
-    GNUNET_PQ_query_param_absolute_time (&timestamp),
-    TALER_PQ_query_param_json (contract_terms),
-    GNUNET_PQ_query_param_auto_from_type (&h_contract_terms),
+    GNUNET_PQ_query_param_absolute_time (&lifetime_inc),
     GNUNET_PQ_query_param_end
   };
 
diff --git a/src/include/anastasis_database_plugin.h 
b/src/include/anastasis_database_plugin.h
index 433c7aa..1ff906d 100644
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@ -111,8 +111,9 @@ struct AnastasisDatabasePlugin
    * Record user payment.
    *
    * @param cls closure
+   * @param payment_id identifier of the payment
    * @param amount how much was paid
-   * @param account_pub public key of the user's account
+   * @param anastasis_pub public key of the user's account
    * @param num_uploads how many uploads does @a amount pay for
    * @param lifetime_inc for how long does @a amount pay for account 
maintenance
    * @param payment_secret identifier for the payment, used to later charge on 
uploads
@@ -121,7 +122,7 @@ struct AnastasisDatabasePlugin
   enum GNUNET_DB_QueryStatus
   (*record_payment)(void *cls,
                     const struct TALER_Amount *amount,
-                    const struct ANASTASIS_AccountPubP *account_pub,
+                    const struct ANASTASIS_AccountPubP *anastasis_pub,
                     unsigned int num_uploads,
                     struct GNUNET_TIME_Relative lifetime_inc,
                     const struct ANASTASIS_PaymentSecretP *payment_secret);
@@ -130,7 +131,7 @@ struct AnastasisDatabasePlugin
    * Upload encrypted recovery document.
    *
    * @param cls closure
-   * @param account_pub public key of the user's account
+   * @param anastasis_pub public key of the user's account
    * @param data contains encrypted_recovery_document
    * @param data_size size of data blob
    * @param payment_secret identifier for the payment, used to later charge on 
uploads
@@ -140,7 +141,7 @@ struct AnastasisDatabasePlugin
    */
   enum GNUNET_DB_QueryStatus
   (*store_recovery_document)(void *cls,
-                             const struct ANASTASIS_AccountPubP *account_pub,
+                             const struct ANASTASIS_AccountPubP *anastasis_pub,
                              const void *data,
                              size_t data_size,
                              const struct
@@ -151,7 +152,7 @@ struct AnastasisDatabasePlugin
    * Fetch recovery document for user.
    *
    * @param cls closure
-   * @param account_pub public key of the user's account
+   * @param anastasis_pub public key of the user's account
    * @param version[OUT] set to the version number of the policy the user 
requested
    * @param data_size size of data blob
    * @param data blob which contains the recovery document
@@ -159,7 +160,7 @@ struct AnastasisDatabasePlugin
    */
   enum GNUNET_DB_QueryStatus
   (*get_recovery_document)(void *cls,
-                           const struct ANASTASIS_AccountPubP *account_pub,
+                           const struct ANASTASIS_AccountPubP *anastasis_pub,
                            uint32_t version,
                            size_t *data_size,
                            void **data);
@@ -168,7 +169,7 @@ struct AnastasisDatabasePlugin
    * Fetch latest recovery document for user.
    *
    * @param cls closure
-   * @param account_pub public key of the user's account
+   * @param anastasis_pub public key of the user's account
    * @param version[OUT] set to the version number of the policy being returned
    * @param data_size size of data blob
    * @param data blob which contains the recovery document
@@ -177,7 +178,7 @@ struct AnastasisDatabasePlugin
   enum GNUNET_DB_QueryStatus
   (*get_latest_recovery_document)(void *cls,
                                   const struct
-                                  ANASTASIS_AccountPubP *account_pub,
+                                  ANASTASIS_AccountPubP *anastasis_pub,
                                   size_t *data_size,
                                   void **data,
                                   uint32_t *version);

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]