gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: work on recovery reducer (WiP)


From: gnunet
Subject: [taler-anastasis] branch master updated: work on recovery reducer (WiP)
Date: Sun, 21 Feb 2021 13:25:18 +0100

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 49494b6  work on recovery reducer (WiP)
49494b6 is described below

commit 49494b60eebfd700d0261d08f5fed906382767c2
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Feb 21 13:25:16 2021 +0100

    work on recovery reducer (WiP)
---
 src/reducer/anastasis_api_recovery_redux.c | 78 +++++++++++++++++++++++++++---
 1 file changed, 71 insertions(+), 7 deletions(-)

diff --git a/src/reducer/anastasis_api_recovery_redux.c 
b/src/reducer/anastasis_api_recovery_redux.c
index 2757f57..797d321 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -133,6 +133,14 @@ struct SelectChallengeContext
    * Our arguments (like answers to the challenge, if already provided).
    */
   json_t *args;
+
+  /**
+   * Task scheduled for delayed success reporting. Needed to make
+   * sure that the solved challenge was really the final result,
+   * cancelled if the solved challenge resulted in the secret being
+   * recovered.
+   */
+  struct GNUNET_SCHEDULER_Task *delayed_report;
 };
 
 
@@ -149,6 +157,11 @@ sctx_free (void *cls)
   ANASTASIS_recovery_abort (sctx->r);
   json_decref (sctx->state);
   json_decref (sctx->args);
+  if (NULL != sctx->delayed_report)
+  {
+    GNUNET_SCHEDULER_cancel (sctx->delayed_report);
+    sctx->delayed_report = NULL;
+  }
   GNUNET_free (sctx);
 }
 
@@ -184,6 +197,27 @@ core_secret_cb (void *cls,
 }
 
 
+/**
+ * A challenge was solved, but we are not yet finished.
+ * Report to caller that the challenge was completed.
+ *
+ * @param cls a `struct SelectChallengeContext`
+ */
+static void
+report_solved (void *cls)
+{
+  struct SelectChallengeContext *sctx = cls;
+
+  sctx->delayed_report = NULL;
+  set_state (sctx->state,
+             ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING);
+  sctx->cb (sctx->cb_cls,
+            TALER_EC_NONE,
+            sctx->state);
+  sctx_free (sctx);
+}
+
+
 /**
  * Defines a callback for the response status for a challenge start
  * operation.
@@ -222,13 +256,43 @@ answer_feedback_cb (
   switch (csr->cs)
   {
   case ANASTASIS_CHALLENGE_STATUS_SOLVED:
-#if FIXME
-    mark_challenge_solved (sctx,
-                           csr->challenge);
-    // => TRICKY: secret recovery success MAY will be reported AFTER
-    //    answer feedback, so need to be prepared for that!
-    // => scheduling task to continue async should suffice!
-#endif
+    {
+      json_t *rd;
+
+      rd = ANASTASIS_recovery_serialize (sctx->r);
+      if (NULL == rd)
+      {
+        GNUNET_break (0);
+        set_state (sctx->state,
+                   ANASTASIS_GENERIC_STATE_ERROR);
+        sctx->cb (sctx->cb_cls,
+                  TALER_EC_INVALID, // FIXME: use better code!
+                  sctx->state);
+        sctx_free (sctx);
+        return;
+      }
+      GNUNET_assert (0 ==
+                     json_object_set_new (sctx->state,
+                                          "recovery_document",
+                                          rd));
+    }
+    {
+      json_t *solved;
+
+      solved = json_pack ("{s:s}",
+                          "state",
+                          "solved");
+      GNUNET_assert (NULL != solved);
+      GNUNET_assert (0 ==
+                     json_object_set_new (feedback,
+                                          uuid,
+                                          solved));
+    }
+    /* Delay reporting challenge success, as we MAY still
+       also see a secret recovery success (and we can only
+       call the callback once) */
+    sctx->delayed_report = GNUNET_SCHEDULER_add_now (&report_solved,
+                                                     sctx);
     return;
   case ANASTASIS_CHALLENGE_STATUS_INSTRUCTIONS:
     {

-- 
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]