gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-anastasis] branch master updated: major FTBFS


From: gnunet
Subject: [GNUnet-SVN] [taler-anastasis] branch master updated: major FTBFS
Date: Thu, 24 Oct 2019 10:38:51 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 8ac5778  major FTBFS
8ac5778 is described below

commit 8ac57784174e6bcbbac99af6dfb0a784cce53bc9
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Oct 24 10:38:47 2019 +0200

    major FTBFS
---
 src/backup-db/plugin_anastasis_postgres.c | 410 ++++++++++++++----------------
 src/include/anastasis_database_plugin.h   |  34 +--
 2 files changed, 193 insertions(+), 251 deletions(-)

diff --git a/src/backup-db/plugin_anastasis_postgres.c 
b/src/backup-db/plugin_anastasis_postgres.c
index 59f7207..37ca7af 100644
--- a/src/backup-db/plugin_anastasis_postgres.c
+++ b/src/backup-db/plugin_anastasis_postgres.c
@@ -131,13 +131,16 @@ postgres_preflight (void *cls)
 
 
 static int
-begin_transaction (struct PostgresClosure *pg)
+begin_transaction (struct PostgresClosure *pg,
+                   const char *name)
 {
   struct GNUNET_PQ_ExecuteStatement es[] = {
     GNUNET_PQ_make_execute ("START TRANSACTION ISOLATION LEVEL SERIALIZABLE"),
     GNUNET_PQ_EXECUTE_STATEMENT_END
   };
 
+  postgres_preflight (pg);
+  pg->transaction_name = name;
   if (GNUNET_OK !=
       GNUNET_PQ_exec_statements (pg->conn,
                                  es))
@@ -165,21 +168,26 @@ rollback (struct PostgresClosure *pg)
     TALER_LOG_ERROR ("Failed to rollback transaction\n");
     GNUNET_break (0);
   }
+  pg->transaction_name = NULL;
 }
 
 
 static enum GNUNET_DB_QueryStatus
 commit_transaction (struct PostgresClosure *pg)
 {
+  enum GNUNET_DB_QueryStatus qs;
   struct GNUNET_PQ_QueryParam no_params[] = {
     GNUNET_PQ_query_param_end
   };
 
-  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
-                                             "do_commit",
-                                             no_params);
+  qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                           "do_commit",
+                                           no_params);
+  pg->transaction_name = NULL;
+  return qs;
 }
 
+
 /**
   * Upload encrypted recovery document.
   *
@@ -200,35 +208,38 @@ postgres_store_recovery_document (void *cls,
                                   size_t data_size,
                                   const struct
                                   ANASTASIS_PaymentSecretP *payment_secret,
-                                  uint32_t **version)
+                                  uint32_t *version)
 {
   struct PostgresClosure *pg = cls;
   enum GNUNET_DB_QueryStatus qs;
   uint32_t postcounter;
+  struct GNUNET_TIME_Absolute paid_until;
 
   check_connection (pg);
-  if (GNUNET_OK != begin_transaction (pg))
+  if (GNUNET_OK != begin_transaction (pg,
+                                      "store_recovery_document"))
   {
     GNUNET_break (0);
     return GNUNET_DB_STATUS_HARD_ERROR;
   }
 
-  // Check if user has paid
-  struct GNUNET_TIME_Absolute paid_until;
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
-    GNUNET_PQ_query_param_end
-  };
-  struct GNUNET_PQ_ResultSpec rs[] = {
-    TALER_PQ_result_spec_absolute_time ("paid_until",
-                                        &paid_until),
-    GNUNET_PQ_result_spec_end
-  };
+  /* Check if user has paid */
+  {
+    struct GNUNET_PQ_QueryParam params[] = {
+      GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
+      GNUNET_PQ_query_param_end
+    };
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      TALER_PQ_result_spec_absolute_time ("paid_until",
+                                          &paid_until),
+      GNUNET_PQ_result_spec_end
+    };
 
-  qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
-                                                 "user_select",
-                                                 params,
-                                                 rs);
+    qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                   "user_select",
+                                                   params,
+                                                   rs);
+  }
   switch (qs)
   {
   case GNUNET_DB_STATUS_HARD_ERROR:
@@ -239,7 +250,7 @@ postgres_store_recovery_document (void *cls,
     rollback (pg);
     return qs;
   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
-    return GNUNET_DB_STATUS_UNKNOWN_USER; // FIXME: This status has to be 
defined!
+    return -42; // GNUNET_DB_STATUS_UNKNOWN_USER; // FIXME: This status has to 
be defined!
   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
     paid_until = GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_get (),
                                            paid_until);
@@ -247,29 +258,30 @@ postgres_store_recovery_document (void *cls,
   }
 
   // rollback if user hasn't paid
-  if (GNUNET_TIME_absolute_get_difference (GNUNET_TIME_absolute_get,
-                                           (paid_until == 0) ))
+  if (GNUNET_TIME_absolute_get_difference (GNUNET_TIME_absolute_get (),
+                                           paid_until).rel_value_us == 0)
   {
     rollback (pg);
     return GNUNET_DB_STATUS_SOFT_ERROR;   // FIXME maybe differnet errorcode?
   }
 
   // lookup if the user has enough uploads left and decrement
+  {
+    struct GNUNET_PQ_QueryParam params[] = {
+      GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
+      GNUNET_PQ_query_param_auto_from_type (payment_secret),
+      GNUNET_PQ_query_param_end
+    };
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_uint32 ("post_counter", &postcounter),
+      GNUNET_PQ_result_spec_end
+    };
 
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
-    GNUNET_PQ_query_param_auto_from_type (payment_secret),
-    GNUNET_PQ_query_param_end
-  };
-
-  struct GNUNET_PQ_ResultSpec rs[] = {
-    GNUNET_PQ_result_spec_uint32 ("post_counter", &postcounter),
-    GNUNET_PQ_result_spec_end
-  };
-
-
-  qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,"postcounter_select",
-                                                 params, rs);
+    qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                   "postcounter_select",
+                                                   params,
+                                                   rs);
+  }
 
   switch (qs)
   {
@@ -296,15 +308,18 @@ postgres_store_recovery_document (void *cls,
   postcounter--;
 
   // update the postcounter
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (&postcounter),
-    GNUNET_PQ_query_param_absolute_time (anastasis_pub),
-    GNUNET_PQ_query_param_auto_from_type (payment_secret),
-    GNUNET_PQ_query_param_end
-  };
-  qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,"postcounter_update",
-                                           params);
+  {
+    struct GNUNET_PQ_QueryParam params[] = {
+      GNUNET_PQ_query_param_uint32 (&postcounter),
+      GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
+      GNUNET_PQ_query_param_auto_from_type (payment_secret),
+      GNUNET_PQ_query_param_end
+    };
 
+    qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "postcounter_update",
+                                             params);
+  }
   switch (qs)
   {
   case GNUNET_DB_STATUS_HARD_ERROR:
@@ -313,7 +328,6 @@ postgres_store_recovery_document (void *cls,
   case GNUNET_DB_STATUS_SOFT_ERROR:
     rollback (pg);
     return qs;
-
   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
     GNUNET_break (0);
     rollback (pg);
@@ -323,21 +337,21 @@ postgres_store_recovery_document (void *cls,
   }
 
   // get the version for the recoverydocument
+  {
+    struct GNUNET_PQ_QueryParam params[] = {
+      GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
+      GNUNET_PQ_query_param_end
+    };
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_uint32 ("version", version),
+      GNUNET_PQ_result_spec_end
+    };
 
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
-    GNUNET_PQ_query_param_end
-  };
-
-  struct GNUNET_PQ_ResultSpec rs[] = {
-    GNUNET_PQ_result_spec_uint32 ("version", version),
-    GNUNET_PQ_result_spec_end
-  };
-
-  qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
-                                                 
"latest_recovery_version_select",
-                                                 params, rs);
-
+    qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                   
"latest_recovery_version_select",
+                                                   params,
+                                                   rs);
+  }
   switch (qs)
   {
   case GNUNET_DB_STATUS_HARD_ERROR:
@@ -348,23 +362,24 @@ postgres_store_recovery_document (void *cls,
     rollback (pg);
     return qs;
   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
-    version = 1;
+    *version = 1;
     break;
   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
-    version++;
+    (*version)++;
     break;
   }
 
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
-    GNUNET_PQ_query_param_auto_from_type (version),
-    GNUNET_PQ_query_param_fixed_size (data, data_size),
-    GNUNET_PQ_query_param_end
-  };
-
-  qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,"recovery_document_insert",
-                                           params);
-
+  {
+    struct GNUNET_PQ_QueryParam params[] = {
+      GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
+      GNUNET_PQ_query_param_auto_from_type (version),
+      GNUNET_PQ_query_param_fixed_size (data, data_size),
+      GNUNET_PQ_query_param_end
+    };
+    qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "recovery_document_insert",
+                                             params);
+  }
 
   switch (qs)
   {
@@ -398,7 +413,7 @@ postgres_store_recovery_document (void *cls,
  * @param cls closure
  * @param amount amount of taler to be paid
  * @param anastasis_pub anastasis's public key
- * @param num_uploads number of uploads the user can make
+ * @param initial_post_counter how many uploads does @a amount pay for
  * @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
@@ -407,7 +422,7 @@ static enum GNUNET_DB_QueryStatus
 postgres_record_payment (void *cls,
                          const struct TALER_Amount *amount,
                          const struct ANASTASIS_AccountPubP *anastasis_pub,
-                         unsigned int *num_uploads,
+                         unsigned int initial_post_counter,
                          struct GNUNET_TIME_Relative lifetime_inc,
                          const struct ANASTASIS_PaymentSecretP *payment_secret)
 {
@@ -417,7 +432,8 @@ postgres_record_payment (void *cls,
 
   check_connection (pg);
   if (GNUNET_OK !=
-      begin_transaction (pg))
+      begin_transaction (pg,
+                         "record_payment"))
   {
     GNUNET_break (0);
     return GNUNET_DB_STATUS_HARD_ERROR;
@@ -504,7 +520,7 @@ postgres_record_payment (void *cls,
   {
     struct GNUNET_PQ_QueryParam params[] = {
       GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
-      GNUNET_PQ_query_param_uint32 (post_counter),
+      GNUNET_PQ_query_param_uint32 (&initial_post_counter),
       GNUNET_PQ_query_param_auto_from_type (payment_secret),
       GNUNET_PQ_query_param_end
     };
@@ -547,7 +563,6 @@ postgres_record_payment (void *cls,
  * @param truth_expiration time till the according data will be stored
  * @return transaction status
  */
-
 static enum GNUNET_DB_QueryStatus
 postgres_store_truth (void *cls,
                       const struct ANASTASIS_uuid *uuid,
@@ -558,24 +573,28 @@ postgres_store_truth (void *cls,
   struct PostgresClosure *pg = cls;
   enum GNUNET_DB_QueryStatus qs;
   struct GNUNET_TIME_Absolute expiration = GNUNET_TIME_absolute_get ();
-  expiration = GNUNET_TIME_absolute_add (expiration, truth_expiration);
-
 
+  expiration = GNUNET_TIME_absolute_add (expiration, truth_expiration);
   check_connection (pg);
-  if (GNUNET_OK != begin_transaction (pg))
+  if (GNUNET_OK != begin_transaction (pg,
+                                      "store_truth"))
   {
     GNUNET_break (0);
     return GNUNET_DB_STATUS_HARD_ERROR;
   }
 
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (uuid),
-    GNUNET_PQ_query_param_fixed_size (truth_data, truth_data_size),
-    GNUNET_PQ_query_param_auto_from_type (expiration),
-    GNUNET_PQ_query_param_end
-  };
+  {
+    struct GNUNET_PQ_QueryParam params[] = {
+      GNUNET_PQ_query_param_auto_from_type (uuid),
+      GNUNET_PQ_query_param_fixed_size (truth_data, truth_data_size),
+      TALER_PQ_query_param_absolute_time (&expiration),
+      GNUNET_PQ_query_param_end
+    };
 
-  qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,"truth_insert", params);
+    qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "truth_insert",
+                                             params);
+  }
   switch (qs)
   {
   case GNUNET_DB_STATUS_HARD_ERROR:
@@ -602,86 +621,42 @@ postgres_store_truth (void *cls,
 }
 
 
-
-
 /**
-  * @param cls closure
-  * @param uuid the identifier for the Truth
-  * @param response the challenge response of the user
-  * @param size_response size of the response
-  * @param data contains the encrypted key share (bytearray)
-  * @param data_size size of data
-  * @param truth_dec_key key to decrypt the truth_data
-  * @return transaction status
-  */
+ * DOCUMENT.
+ *
+ * @param cls closure
+ * @param uuid the identifier for the Truth
+ * @param truth contains the truth (base32 encoded)
+ * @param truth_size size of truth
+ * @param truth_mime mime type of truth
+ * @return transaction status
+ */
 enum GNUNET_DB_QueryStatus
-(*get_encrypted_key_share)(void *cls,
-                           const struct ANASTASIS_uuid *uuid,
-                           char *response,
-                           size_t size_response,
-                           void **data,
-                           size_t *data_size,
-                           uint32_t truth_dec_key[8])
-
-
-
+postgres_get_escrow_challenge (void *cls,
+                               const struct ANASTASIS_uuid *uuid,
+                               void **truth,
+                               size_t *truth_size,
+                               char **truth_mime)
 {
   struct PostgresClosure *pg = cls;
-  check_connection (pg);
-
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (uuid),
     GNUNET_PQ_query_param_end
   };
-
   struct GNUNET_PQ_ResultSpec rs[] = {
-    GNUNET_PQ_result_spec_variable_size ("truth", data, data_size),
+    GNUNET_PQ_result_spec_variable_size ("truth",
+                                         truth,
+                                         truth_size),
+    GNUNET_PQ_result_spec_string ("truth_mime",
+                                  truth_mime),
     GNUNET_PQ_result_spec_end
   };
 
-  GNUNET_PQ_eval_prepared_singleton_select (pg->conn,"truth_select", params,
-                                            rs);
-
-  // FIXME Pattern match ?
-  // return nur von recovery teil
-
-}
-
-
-/**
-* @param cls closure
-* @param uuid the identifier for the Truth
-* @param truth contains the truth (base32 encoded)
-* @param truth_size size of truth
-* @param truth_mime mime type of truth
-* @param truth_mime_size size of truth_mime
-* @return transaction status
-*/
-enum GNUNET_DB_QueryStatus
-(*get_escrow_challenge)(void *cls,
-                        const struct ANASTASIS_uuid *uuid,
-                        char **truth,
-                        size_t *truth_size,
-                        char **truth_mime,
-                        size_t *truth_mime_size)
-{
-  struct PostgresClosure *pg = cls;
   check_connection (pg);
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (uuid),
-    GNUNET_PQ_query_param_end
-  };
-
-  struct GNUNET_PQ_ResultSpec rs[] = {
-    GNUNET_PQ_result_spec_variable_size ("truth", data, data_size),
-    GNUNET_PQ_result_spec_end
-  };
-
-  GNUNET_PQ_eval_prepared_singleton_select (pg->conn,"truth_select", params,
-                                            rs);
-
-  // FIXME return nur von challange teil
-
+  return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                   "truth_select",
+                                                   params,
+                                                   rs);
 }
 
 
@@ -696,31 +671,33 @@ enum GNUNET_DB_QueryStatus
  * @return transaction status
  */
 enum GNUNET_DB_QueryStatus
-(*get_latest_recovery_document)(void *cls,
-                                const struct
-                                ANASTASIS_AccountPubP *anastasis_pub,
-                                size_t *data_size,
-                                void **data,
-                                uint32_t *version)
+postgres_get_latest_recovery_document (void *cls,
+                                       const struct
+                                       ANASTASIS_AccountPubP *anastasis_pub,
+                                       size_t *data_size,
+                                       void **data,
+                                       uint32_t *version)
 {
-  check_connection (pq);
   struct PostgresClosure *pg = cls;
-
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
     GNUNET_PQ_query_param_end
   };
-
   struct GNUNET_PQ_ResultSpec rs[] = {
-    GNUNET_PQ_result_spec_variable_size ("recovery_data", data, data_size),
+    GNUNET_PQ_result_spec_variable_size ("recovery_data",
+                                         data,
+                                         data_size),
     GNUNET_PQ_result_spec_end
   };
 
+  check_connection (pg);
   return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
                                                    
"latest_recoverydocument_select",
-                                                   params, rs);
+                                                   params,
+                                                   rs);
 }
 
+
 /**
  * Fetch recovery document for user.
  *
@@ -732,31 +709,35 @@ enum GNUNET_DB_QueryStatus
  * @return transaction status
  */
 enum GNUNET_DB_QueryStatus
-(*get_recovery_document)(void *cls,
-                         const struct ANASTASIS_AccountPubP *anastasis_pub,
-                         uint32_t version,
-                         size_t *data_size,
-                         void **data)
+postgres_get_recovery_document (void *cls,
+                                const struct
+                                ANASTASIS_AccountPubP *anastasis_pub,
+                                uint32_t version,
+                                size_t *data_size,
+                                void **data)
 
 {
-  check_connection (pq);
   struct PostgresClosure *pg = cls;
-
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
-    GNUNET_PQ_query_param_uint32 (version),
+    GNUNET_PQ_query_param_uint32 (&version),
     GNUNET_PQ_query_param_end
   };
   struct GNUNET_PQ_ResultSpec rs[] = {
-    GNUNET_PQ_result_spec_variable_size ("recovery_data", data, data_size),
+    GNUNET_PQ_result_spec_variable_size ("recovery_data",
+                                         data,
+                                         data_size),
     GNUNET_PQ_result_spec_end
   };
 
+  check_connection (pg);
   return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
                                                    "recoverydocument_select",
-                                                   params, rs);
+                                                   params,
+                                                   rs);
 }
 
+
 /**
  * Initialize Postgres database subsystem.
  *
@@ -768,42 +749,35 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg = cls;
   struct PostgresClosure *pg;
-  struct ANASTASIS_DB_Plugin *plugin;
-  const char *ec;
+  struct ANASTASIS_DatabasePlugin *plugin;
   struct GNUNET_PQ_ExecuteStatement es[] = {
     /* Orders created by the frontend, not signed or given a nonce yet.
        The contract terms will change (nonce will be added) when moved to the
        contract terms table */
-    GNUNET_PQ_make_execute (
-      "CREATE TABLE anastasis_truth
-                            ( truth_id UUID PRIMARY KEY NOT NULL,
-                              truth BYTEA NOT NULL,
-                              expiration TIMESTAMP NOT NULL
-                            );"),
-    GNUNET_PQ_make_execute (
-      "CREATE TABLE anastasis_user
-                            ( user_id BYTEA PRIMARY KEY 
CHECK(LENGTH(user_id)=32),
-                              paid_until TIMESTAMP NOT NULL
-                            );"),
-    GNUNET_PQ_make_execute (
-      "CREATE TABLE anastasis_payments
-                            ( payment_id BIGSERIAL PRIMARY KEY,
-                              user_id BYTEA NOT NULL REFERENCES 
anastasis_user(user_id),
-                              post_counter INTEGER,
-                              payment_identifier BYTEA NOT NULL 
CHECK(LENGTH(payment_identifier)=32),
-                              transaction_time TIMESTAMP NOT NULL DEFAULT NOW()
-                            );"),
-    GNUNET_PQ_make_execute (
-      "CREATE TABLE anastasis_recoverydocument
-                            ( user_id BYTEA NOT NULL REFERENCES 
anastasis_user(user_id),
-                              version INTEGER,
-                              recovery_data BYTEA,
-                              PRIMARY KEY (user_id, version)
-                            );"),
+    GNUNET_PQ_make_execute ("CREATE TABLE anastasis_truth"
+                            "( truth_id UUID PRIMARY KEY NOT NULL,"
+                            "truth BYTEA NOT NULL,"
+                            "expiration TIMESTAMP NOT NULL"
+                            ");"),
+    GNUNET_PQ_make_execute ("CREATE TABLE anastasis_user"
+                            "( user_id BYTEA PRIMARY KEY 
CHECK(LENGTH(user_id)=32),"
+                            "  paid_until TIMESTAMP NOT NULL"
+                            ");"),
+    GNUNET_PQ_make_execute ("CREATE TABLE anastasis_payments"
+                            "( payment_id BIGSERIAL PRIMARY KEY,"
+                            "  user_id BYTEA NOT NULL REFERENCES 
anastasis_user(user_id),"
+                            "  post_counter INTEGER,"
+                            "  payment_identifier BYTEA NOT NULL 
CHECK(LENGTH(payment_identifier)=32),"
+                            "  transaction_time TIMESTAMP NOT NULL DEFAULT 
NOW()"
+                            ");"),
+    GNUNET_PQ_make_execute ("CREATE TABLE anastasis_recoverydocument"
+                            "( user_id BYTEA NOT NULL REFERENCES 
anastasis_user(user_id),"
+                            "  version INTEGER,"
+                            "  recovery_data BYTEA,"
+                            "  PRIMARY KEY (user_id, version)"
+                            ");"),
     GNUNET_PQ_EXECUTE_STATEMENT_END
   };
-
-
   struct GNUNET_PQ_PreparedStatement ps[] = {
     GNUNET_PQ_make_prepare ("user_insert",
                             "INSERT INTO anastasis_user "
@@ -832,7 +806,7 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
                             "INSERT INTO anastasis_recoverydocument"
                             "(user_id"
                             ",post_counter"
-                            ",payment_identifier",
+                            ",payment_identifier"
                             ") VALUES "
                             "($1, $2, $3);",
                             3),
@@ -841,7 +815,7 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
                             "INSERT INTO anastasis_truth "
                             "(truth_id"
                             ",truth"
-                            ",expiration",
+                            ",expiration"
                             ") VALUES "
                             "($1, $2, $3);",
                             3),
@@ -849,7 +823,7 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
                             "INSERT INTO anastasis_recoverydocument "
                             "(user_id"
                             ",version"
-                            ",recovery_data",
+                            ",recovery_data"
                             ") VALUES "
                             "($1, $2, $3);",
                             3),
@@ -867,7 +841,6 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
                             "ORDER BY version DESC "
                             "LIMIT 1;",
                             1),
-
     GNUNET_PQ_make_prepare ("latest_recovery_version_select",
                             "SELECT "
                             "version "
@@ -876,7 +849,6 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
                             "ORDER BY version DESC "
                             "LIMIT 1;",
                             1),
-
     GNUNET_PQ_make_prepare ("recoverydocument_select",
                             "SELECT "
                             "recovery_data "
@@ -884,7 +856,6 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
                             "WHERE user_id =$1 "
                             "AND version=$2;",
                             2),
-
     GNUNET_PQ_make_prepare ("postcounter_select",
                             "SELECT "
                             "post_counter "
@@ -892,7 +863,6 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
                             "WHERE user_id =$1 "
                             "AND payment_identifier=$2;",
                             2),
-
     GNUNET_PQ_make_prepare ("postcounter_update",
                             "UPDATE "
                             "anastasis_payments "
@@ -901,7 +871,6 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
                             "WHERE user_id =$2 "
                             "AND payment_identifier=$3;",
                             3),
-
     GNUNET_PQ_PREPARED_STATEMENT_END
   };
 
@@ -916,13 +885,12 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
     GNUNET_free (pg);
     return NULL;
   }
-  plugin = GNUNET_new (struct ANASTASIS_DB_Plugin);
+  plugin = GNUNET_new (struct ANASTASIS_DatabasePlugin);
   plugin->cls = pg;
   plugin->drop_tables = &postgres_drop_tables;
-  plugin->start = postgres_start;
-  plugin->commit = postgres_commit;
-  plugin->preflight = postgres_preflight;
-  plugin->rollback = postgres_rollback;
+  plugin->store_recovery_document = &postgres_store_recovery_document;
+  plugin->record_payment = &postgres_record_payment;
+  plugin->store_truth = &postgres_store_truth;
 
   return plugin;
 }
@@ -937,10 +905,10 @@ libtaler_plugin_anastasis_db_postgres_init (void *cls)
 void *
 plugin_anastasis_db_postgres_done (void *cls)
 {
-  struct ANASTASIS_DB_Plugin *plugin = cls;
+  struct ANASTASIS_DatabasePlugin *plugin = cls;
   struct PostgresClosure *pg = plugin->cls;
 
-  GNUNE_PQ_disconnect (pg->conn);
+  GNUNET_PQ_disconnect (pg->conn);
   GNUNET_free (pg);
   GNUNET_free (plugin);
   return NULL;
diff --git a/src/include/anastasis_database_plugin.h 
b/src/include/anastasis_database_plugin.h
index 8e673e9..bcf6df1 100644
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@ -51,12 +51,6 @@ struct ANASTASIS_uuid
 };
 
 
-/**
- * Handle to interact with the database.
- */
-struct Anastasis_DB_Plugin;
-
-
 /**
  * Handle to interact with the database.
  *
@@ -66,7 +60,7 @@ struct Anastasis_DB_Plugin;
  * setup a transaction scope.  Functions without a suffix are
  * simple, single SQL queries that MAY be used either way.
  */
-struct AnastasisDatabasePlugin
+struct ANASTASIS_DatabasePlugin
 {
 
   /**
@@ -182,7 +176,7 @@ struct AnastasisDatabasePlugin
                              size_t data_size,
                              const struct
                              ANASTASIS_PaymentSecretP *payment_secret,
-                             uint32_t **version);
+                             uint32_t *version);
 
   /**
    * Fetch recovery document for user.
@@ -236,24 +230,6 @@ struct AnastasisDatabasePlugin
                  size_t truth_data_size,
                  struct GNUNET_TIME_Relative truth_expiration);
 
-  /**
-  * @param cls closure
-  * @param uuid the identifier for the Truth
-  * @param response the challenge response of the user
-  * @param size_response size of the response
-  * @param data contains the encrypted key share (bytearray)
-  * @param data_size size of data
-  * @param truth_dec_key key to decrypt the truth_data
-  * @return transaction status
-  */
-  enum GNUNET_DB_QueryStatus
-  (*get_encrypted_key_share)(void *cls,
-                             const struct ANASTASIS_uuid *uuid,
-                             char *response,
-                             size_t size_response,
-                             void **data,
-                             size_t *data_size,
-                             uint32_t truth_dec_key[8]);
 
   /**
   * @param cls closure
@@ -261,16 +237,14 @@ struct AnastasisDatabasePlugin
   * @param truth contains the truth (base32 encoded)
   * @param truth_size size of truth
   * @param truth_mime mime type of truth
-  * @param truth_mime_size size of truth_mime
   * @return transaction status
   */
   enum GNUNET_DB_QueryStatus
   (*get_escrow_challenge)(void *cls,
                           const struct ANASTASIS_uuid *uuid,
-                          char **truth,
+                          void **truth,
                           size_t *truth_size,
-                          char **truth_mime,
-                          size_t *truth_mime_size);
+                          char **truth_mime);
 };
 
 #endif

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



reply via email to

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