gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 02/03: worked on recovery upload


From: gnunet
Subject: [taler-anastasis] 02/03: worked on recovery upload
Date: Mon, 30 Nov 2020 21:58:44 +0100

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

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit f6a9ade590bc199a28ce4d1b9799910857ddb556
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Sat Nov 28 19:17:09 2020 +0100

    worked on recovery upload
---
 src/cli/test_anastasis_reducer_enter_secret.sh |   7 +-
 src/lib/anastasis.c                            |   4 +-
 src/lib/anastasis_api_backup_redux.c           | 113 +++++++++++++++++--------
 src/stasis/plugin_anastasis_postgres.c         |   3 +-
 4 files changed, 83 insertions(+), 44 deletions(-)

diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh 
b/src/cli/test_anastasis_reducer_enter_secret.sh
index 1cac54a..e43c86d 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -101,11 +101,7 @@ AUDITOR_URL=http://localhost:8083/
 # patch configuration
 taler-config -c $CONF -s exchange -o MASTER_PUBLIC_KEY -V $MASTER_PUB
 taler-config -c $CONF -s merchant-exchange-default -o MASTER_KEY -V $MASTER_PUB
-# FIXME: SQL_DIR not usefull in general
-taler-config -c $CONF -s exchangedb-postgres -o SQL_DIR -V 
${HOME}/.local/share/taler/sql/exchange/
 taler-config -c $CONF -s exchangedb-postgres -o CONFIG -V postgres:///$TALER_DB
-# FIXME: SQL_DIR not usefull in general
-taler-config -c $CONF -s auditordb-postgres -o SQL_DIR -V 
${HOME}/.local/share/taler/sql/exchange/
 taler-config -c $CONF -s auditordb-postgres -o CONFIG -V postgres:///$TALER_DB
 taler-config -c $CONF -s merchantdb-postgres -o CONFIG -V postgres:///$TALER_DB
 taler-config -c $CONF -s bank -o database -V postgres:///$TALER_DB
@@ -129,13 +125,14 @@ mkdir -p $ABD
 mv a2e.dat $ABD
 
 # Launch services
-echo "Launching anastasis service"
+echo "Launching taler service"
 taler-bank-manage-testing $CONF postgres:///$TALER_DB serve &
 taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
 taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log &
 taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
 taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log &
 
+echo "Launching anastasis service"
 anastasis-httpd -c $CONF_1 2> anastasis-httpd_1.log &
 anastasis-httpd -c $CONF_2 2> anastasis-httpd_2.log &
 anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 4e81a4c..98ca8e9 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -2084,7 +2084,9 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                                               ss->pss[l]->recovery_data,
                                               ss->pss[l]->recovery_data_size,
                                               ss->pss[l]->payment_requested,
-                                              &ss->pss[l]->payment_secret,
+                                              (pds_len > 0)
+                                              ? &ss->pss[l]->payment_secret
+                                              : NULL,
                                               &policy_store_cb,
                                               ss->pss[l]);
     if (NULL == ss->pss[l]->pso)
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index ce6ba24..cbd1f31 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -266,6 +266,36 @@ typedef struct ANASTASIS_ReduxAction *
                    void *cb_cls);
 
 
+static const char *
+get_provider_url_from_id (const char *id,
+                          json_t *state)
+{
+  const char *key;
+  json_t *method;
+  json_t *methods = json_object_get (state,
+                                     "authentication_providers");
+
+  json_object_foreach (methods, key, method)
+  {
+    GNUNET_assert (json_is_array (method));
+    json_t *method_data;
+    size_t index;
+
+    json_array_foreach (method, index, method_data)
+    {
+      json_t *provider_id = json_object_get (method_data, id);
+      if (NULL == provider_id)
+        continue;
+
+      const char *url = json_string_value (json_object_get (provider_id,
+                                                            "provider_url"));
+      return url;
+    }
+  }
+  return NULL;
+}
+
+
 static void
 set_state (json_t *state,
            const char *new_backup_state)
@@ -1189,6 +1219,9 @@ initialize_policies (json_t *state)
                                            "policies");
 
   GNUNET_assert (json_is_array (json_policies));
+  json_t *rec_doc_uploads = json_array ();
+
+  GNUNET_assert (json_is_array (rec_doc_uploads));
   json_array_foreach (json_policies, p_index, json_policy)
   {
     size_t index;
@@ -1209,7 +1242,49 @@ initialize_policies (json_t *state)
       GNUNET_assert (NULL != tus_arr[auth_method_index]->truth);
       truths[truth_index] = tus_arr[auth_method_index]->truth;
       truth_index++;
+
+      {
+        // initialize recovery document uploads array
+        bool existing = false;
+        size_t upload_index;
+        json_t *upload;
+        json_t *provider_id = json_object_get (auth_method,
+                                               "provider");
+        if (0 < json_array_size (rec_doc_uploads))
+        {
+          json_array_foreach (rec_doc_uploads, upload_index, upload)
+          {
+            if (1 == json_equal (provider_id, json_object_get (upload,
+                                                               "provider")))
+            {
+              existing = true;
+              break;
+            }
+          }
+        }
+
+        if (! existing)
+        {
+          const char *id = json_string_value (provider_id);
+          const char *provider_url = get_provider_url_from_id (id,
+                                                               state);
+          GNUNET_assert (0 ==
+                         json_array_append (rec_doc_uploads,
+                                            json_pack ("{s:I, s:s, s:s}",
+                                                       "status",
+                                                       (json_int_t) 0,
+                                                       "provider",
+                                                       id,
+                                                       "provider_url",
+                                                       provider_url)));
+        }
+      }
     }
+    GNUNET_assert (0 ==
+                   json_object_set (state,
+                                    "recovery_document_uploads",
+                                    rec_doc_uploads));
+
     struct ANASTASIS_Policy *policy = ANASTASIS_policy_create (truths,
                                                                truth_index);
     GNUNET_array_append (policy_arr,
@@ -1337,7 +1412,7 @@ secret_share_result_cb (void *cls,
   {
     const char *url = json_string_value (
       json_object_get (upload,
-                       "backend_url"));
+                       "provider_url"));
     if (0 == strcmp (url, server_url))
     {
       GNUNET_assert (0 ==
@@ -1506,42 +1581,6 @@ truth_upload_cb (void *cls,
        == (size_t) tus_arr_length))
   {
     // try uploading recovery document
-    size_t t_index;
-    size_t rd_index;
-    json_t *truth;
-    json_t *truths = json_object_get (tus->state,
-                                      "truths");
-    json_t *rec_doc_uploads = json_array ();
-
-    GNUNET_assert (json_is_array (truths));
-    GNUNET_assert (json_is_array (rec_doc_uploads));
-    json_array_foreach (truths, t_index, truth)
-    {
-      json_t *upload;
-      json_t *backend_url = json_object_get (truth,
-                                             "backend_url");
-
-      json_array_foreach (rec_doc_uploads, rd_index, upload)
-      {
-        if (1 == json_equal (backend_url, json_object_get (upload,
-                                                           "backend_url")))
-          break;
-
-        GNUNET_assert (0 ==
-                       json_object_set_new (upload,
-                                            "backend_url",
-                                            backend_url));
-        GNUNET_assert (0 ==
-                       json_object_set_new (upload,
-                                            "status",
-                                            json_integer ((json_int_t) 0)));
-      }
-    }
-    GNUNET_assert (0 ==
-                   json_object_set_new (tus->state,
-                                        "recovery_document_uploads",
-                                        rec_doc_uploads));
-
     upload_rec_documents (tus->state,
                           tus->ctx,
                           tus->cb,
diff --git a/src/stasis/plugin_anastasis_postgres.c 
b/src/stasis/plugin_anastasis_postgres.c
index a0f97be..104c73f 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -758,7 +758,8 @@ postgres_increment_lifetime (void *cls,
       GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
       GNUNET_PQ_query_param_end
     };
-
+    check_connection (pg);
+    postgres_preflight (pg);
     qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
                                              "recdoc_payment_done",
                                              params);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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