gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: update error codes


From: gnunet
Subject: [taler-anastasis] branch master updated: update error codes
Date: Sun, 08 Nov 2020 01:13:13 +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 9402ff9  update error codes
9402ff9 is described below

commit 9402ff93a39c7d8823a75d9965c076734cace2c2
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Nov 8 01:11:31 2020 +0100

    update error codes
---
 src/backend/anastasis-httpd.c                     | 20 ++++++-
 src/backend/anastasis-httpd_policy.c              | 67 ++++++++--------------
 src/backend/anastasis-httpd_policy.h              | 19 ++++---
 src/backend/anastasis-httpd_policy_upload.c       | 69 ++++++++---------------
 src/backend/anastasis-httpd_truth.c               | 14 ++---
 src/backend/anastasis-httpd_truth_upload.c        | 66 ++++++++--------------
 src/backend/anastasis_authorization_plugin_file.c |  4 +-
 src/include/anastasis_error_codes.h               |  2 +-
 src/lib/anastasis_api_backup_redux.c              | 12 ++--
 src/lib/anastasis_api_redux.c                     |  7 ++-
 10 files changed, 120 insertions(+), 160 deletions(-)

diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 6f9e529..d7e09b0 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -325,19 +325,33 @@ url_handler (void *cls,
                     "/policy/",
                     strlen ("/policy/")))
   {
-    // return handle_policy (...);
+    const char *account = url + strlen ("/policy/");
+    struct ANASTASIS_CRYPTO_AccountPublicKeyP account_pub;
+
+    if (GNUNET_OK !=
+        GNUNET_STRINGS_string_to_data (
+          account,
+          strlen (account),
+          &account_pub,
+          sizeof (struct ANASTASIS_CRYPTO_AccountPublicKeyP)))
+    {
+      return TALER_MHD_reply_with_error (connection,
+                                         MHD_HTTP_BAD_REQUEST,
+                                         42, // FIXME: reasonable ec
+                                         "account public key malformed");
+    }
     if (0 == strcmp (method,
                      MHD_HTTP_METHOD_GET))
     {
       return AH_policy_get (connection,
-                            url);
+                            &account_pub);
     }
     if (0 == strcmp (method,
                      MHD_HTTP_METHOD_POST))
     {
       return AH_handler_policy_post (connection,
                                      hc,
-                                     url + strlen ("/policy/"),
+                                     &account_pub,
                                      upload_data,
                                      upload_data_size);
     }
diff --git a/src/backend/anastasis-httpd_policy.c 
b/src/backend/anastasis-httpd_policy.c
index 2dc61f7..80d8203 100644
--- a/src/backend/anastasis-httpd_policy.c
+++ b/src/backend/anastasis-httpd_policy.c
@@ -34,7 +34,7 @@
  * How long do we hold an HTTP client connection if
  * we are awaiting payment before giving up?
  */
-#define CHECK_PAYMENT_TIMEOUT GNUNET_TIME_relative_multiply ( \
+#define CHECK_PAYMENT_GENERIC_TIMEOUT GNUNET_TIME_relative_multiply ( \
     GNUNET_TIME_UNIT_MINUTES, 30)
 
 
@@ -106,31 +106,31 @@ AH_return_policy (struct MHD_Connection *connection,
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_INTERNAL_INVARIANT_FAILURE,
+                                       
TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
                                        "unexpected return status (backup 
mismatch)");
   case ANASTASIS_DB_STATUS_PAYMENT_REQUIRED:
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_INTERNAL_INVARIANT_FAILURE,
+                                       
TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
                                        "unexpected return status (payment 
required)");
   case ANASTASIS_DB_STATUS_HARD_ERROR:
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_HARD_FETCH_ERROR,
-                                       "hard database failure");
+                                       TALER_EC_GENERIC_DB_FETCH_FAILED,
+                                       "recovery document");
   case ANASTASIS_DB_STATUS_SOFT_ERROR:
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_SOFT_FETCH_ERROR,
-                                       "soft database failure");
+                                       TALER_EC_GENERIC_DB_SOFT_FAILURE,
+                                       NULL);
   case ANASTASIS_DB_STATUS_NO_RESULTS:
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       
TALER_EC_SYNC_DB_INCONSISTENT_FETCH_ERROR,
+                                       TALER_EC_GENERIC_DB_INVARIANT_FAILURE,
                                        "unexpected empty result set (try 
again?)");
   case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
     /* interesting case below */
@@ -138,8 +138,8 @@ AH_return_policy (struct MHD_Connection *connection,
   default:
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_HARD_FETCH_ERROR,
-                                       "hard database failure");
+                                       TALER_EC_GENERIC_DB_FETCH_FAILED,
+                                       "unexpected query status");
 
   }
   resp = MHD_create_response_from_buffer (res_recovery_data_size,
@@ -186,42 +186,19 @@ AH_return_policy (struct MHD_Connection *connection,
 
 /**
  * @param connection the MHD connection to handle
- * @param url handles a URL of the format 
"/policy/$ACCOUNT_PUB[&version=$NUMBER]"
- * @param con_cls
+ * @param account_pub public key of the account
  * @return MHD result code
  */
 MHD_RESULT
 AH_policy_get (struct MHD_Connection *connection,
-               const char *url)
+               const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub)
 {
   struct GNUNET_HashCode recovery_data_hash;
   enum ANASTASIS_DB_QueryStatus qs;
   MHD_RESULT ret;
-  struct ANASTASIS_CRYPTO_AccountPublicKeyP account_pub;
-
-  GNUNET_assert (0 == strncmp (url,
-                               "/policy/",
-                               strlen ("/policy/")));
-  {
-    const char *account;
-
-    account = &url[strlen ("/policy/")];
-    if (GNUNET_OK !=
-        GNUNET_STRINGS_string_to_data (account,
-                                       strlen (account),
-                                       &account_pub,
-                                       sizeof (struct
-                                               
ANASTASIS_CRYPTO_AccountPublicKeyP)))
-    {
-      return TALER_MHD_reply_with_error (connection,
-                                         MHD_HTTP_BAD_REQUEST,
-                                         42, // FIXME: reasonable ec
-                                         "account public key malformed");
-    }
-  }
 
   qs = db->lookup_account (db->cls,
-                           &account_pub,
+                           account_pub,
                            &recovery_data_hash);
   switch (qs)
   {
@@ -229,25 +206,25 @@ AH_policy_get (struct MHD_Connection *connection,
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_INTERNAL_INVARIANT_FAILURE,
+                                       
TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
                                        "unexpected return status (backup 
missing)");
   case ANASTASIS_DB_STATUS_PAYMENT_REQUIRED:
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_NOT_FOUND,
                                        TALER_EC_SYNC_ACCOUNT_UNKNOWN,
-                                       "account");
+                                       NULL);
   case ANASTASIS_DB_STATUS_HARD_ERROR:
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_HARD_FETCH_ERROR,
-                                       "hard database failure");
+                                       TALER_EC_GENERIC_DB_FETCH_FAILED,
+                                       "lookup account");
   case ANASTASIS_DB_STATUS_SOFT_ERROR:
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_SOFT_FETCH_ERROR,
-                                       "soft database failure");
+                                       TALER_EC_GENERIC_DB_SOFT_FAILURE,
+                                       NULL);
   case ANASTASIS_DB_STATUS_NO_RESULTS:
     {
       struct MHD_Response *resp;
@@ -308,11 +285,11 @@ AH_policy_get (struct MHD_Connection *connection,
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_HARD_FETCH_ERROR,
-                                       "hard database failure");
+                                       TALER_EC_GENERIC_DB_FETCH_FAILED,
+                                       "unexpected database status code");
 
   }
   return AH_return_policy (connection,
-                           &account_pub,
+                           account_pub,
                            MHD_HTTP_OK);
 }
diff --git a/src/backend/anastasis-httpd_policy.h 
b/src/backend/anastasis-httpd_policy.h
index ff2b8c9..b525443 100644
--- a/src/backend/anastasis-httpd_policy.h
+++ b/src/backend/anastasis-httpd_policy.h
@@ -34,27 +34,30 @@ AH_resume_all_bc (void);
 
 /**
  * @param connection the MHD connection to handle
- * @param url handles a URL of the format 
"/policy/$ACCOUNT_PUB[&version=$NUMBER]"
+ * @param account_pub public key of the account
  * @return MHD result code
  */
 MHD_RESULT
 AH_policy_get (struct MHD_Connection *connection,
-               const char *url);
+               const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub);
+
 
 /**
  * @param connection the MHD connection to handle
  * @param con_cls the connection's closure
- * @param account name of the account of the format "$ACCOUNT_PUB"
+ * @param account_pub public key of the account
  * @param upload_data upload data
  * @param upload_data_size number of bytes (left) in @a upload_data
  * @return MHD result code
  */
 MHD_RESULT
-AH_handler_policy_post (struct MHD_Connection *connection,
-                        struct TM_HandlerContext *hc,
-                        const char *account,
-                        const char *upload_data,
-                        size_t *upload_data_size);
+AH_handler_policy_post (
+  struct MHD_Connection *connection,
+  struct TM_HandlerContext *hc,
+  const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
+  const char *upload_data,
+  size_t *upload_data_size);
+
 
 /**
  * Return the current recoverydocument of @a account on @a connection
diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index 3063d4b..0b64415 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -34,7 +34,7 @@
  * How long do we hold an HTTP client connection if
  * we are awaiting payment before giving up?
  */
-#define CHECK_PAYMENT_TIMEOUT GNUNET_TIME_relative_multiply ( \
+#define CHECK_PAYMENT_GENERIC_TIMEOUT GNUNET_TIME_relative_multiply ( \
     GNUNET_TIME_UNIT_MINUTES, 30)
 
 
@@ -344,8 +344,9 @@ proposal_cb (void *cls,
   if (0 >= qs)
   {
     GNUNET_break (0);
-    puc->resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_CREATE_DB_ERROR,
-                                      "Failed to persist payment request in 
anastasis database");
+    puc->resp = TALER_MHD_make_error (
+      TALER_EC_GENERIC_DB_STORE_FAILED,
+      "record recdoc payment");
     puc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
     return;
   }
@@ -426,8 +427,9 @@ check_payment_cb (void *cls,
     if (0 <= qs)
       return; /* continue as planned */
     GNUNET_break (0);
-    puc->resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_CONFIRM_DB_ERROR,
-                                      "Failed to persist payment confirmation 
in sync database");
+    puc->resp = TALER_MHD_make_error (
+      TALER_EC_GENERIC_DB_FETCH_FAILED,
+      "increment lifetime");
     puc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
     return; /* continue as planned */
   }
@@ -443,7 +445,7 @@ check_payment_cb (void *cls,
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Timeout waiting for payment\n");
-  puc->resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_TIMEOUT,
+  puc->resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_GENERIC_TIMEOUT,
                                     "Timeout awaiting promised payment");
   GNUNET_assert (NULL != puc->resp);
   puc->response_code = MHD_HTTP_REQUEST_TIMEOUT;
@@ -508,8 +510,9 @@ begin_payment (struct PolicyUploadContext *puc,
     struct MHD_Response *resp;
     MHD_RESULT ret;
 
-    resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_CHECK_ORDER_DB_ERROR,
-                                 "Failed to check for expired payment in 
anastasis database");
+    resp = TALER_MHD_make_error (
+      TALER_EC_GENERIC_DB_FETCH_FAILED,
+      "pending payments by account");
     ret = MHD_queue_response (puc->con,
                               MHD_HTTP_INTERNAL_SERVER_ERROR,
                               resp);
@@ -611,7 +614,7 @@ handle_database_error (struct PolicyUploadContext *puc,
                     "Payment required, awaiting completion of `%s'\n",
                     order_id);
         await_payment (puc,
-                       CHECK_PAYMENT_TIMEOUT,
+                       CHECK_PAYMENT_GENERIC_TIMEOUT,
                        order_id);
         GNUNET_free (order_id);
       }
@@ -622,8 +625,8 @@ handle_database_error (struct PolicyUploadContext *puc,
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (puc->con,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DATABASE_FETCH_ERROR,
-                                       "failed to fetch existing record from 
database");
+                                       TALER_EC_GENERIC_DB_FETCH_FAILED,
+                                       NULL);
   case ANASTASIS_DB_STATUS_NO_RESULTS:
     GNUNET_assert (0);
     return MHD_NO;
@@ -637,23 +640,15 @@ handle_database_error (struct PolicyUploadContext *puc,
 }
 
 
-/**
- * @param connection the MHD connection to handle
- * @param con_cls the connection's closure
- * @param account name of the account of the format "$ACCOUNT_PUB"
- * @param recovery_data upload data
- * @param recovery_data_size number of bytes (left) in @a recovery_data
- * @return MHD result code
- */
 MHD_RESULT
 AH_handler_policy_post (struct MHD_Connection *connection,
                         struct TM_HandlerContext *hc,
-                        const char *account,
+                        const struct
+                        ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
                         const char *recovery_data,
                         size_t *recovery_data_size)
 {
   struct PolicyUploadContext *puc = hc->ctx;
-  struct ANASTASIS_CRYPTO_AccountPublicKeyP accountPubP;
   struct TALER_Amount zero_amount;
   bool zero_cost = false;
 
@@ -694,27 +689,11 @@ AH_handler_policy_post (struct MHD_Connection *connection,
         puc->payment_identifier_provided = true;
       }
     }
-
-
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d handler is policy_post\n", __FILE__, __LINE__);
-
-    /* extract publickey from url */
-    {
-      if (GNUNET_OK !=
-          GNUNET_CRYPTO_eddsa_public_key_from_string (account,
-                                                      strlen (account),
-                                                      &accountPubP.pub))
-      {
-        return TALER_MHD_reply_with_error (connection,
-                                           MHD_HTTP_BAD_REQUEST,
-                                           
TALER_EC_REQUEST_PARAMETER_MALFORMED,
-                                           "account public key (after /policy/ 
in URL)");
-      }
-    }
-    puc->account = accountPubP;
+    puc->account = *account_pub;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d public key is %s-%llu b\n", __FILE__, __LINE__,
+                "At %s:%d public key is %s-%llu b\n",
+                __FILE__,
+                __LINE__,
                 TALER_B2S (&puc->account),
                 (unsigned long long) sizeof (struct
                                              
ANASTASIS_CRYPTO_AccountPublicKeyP));
@@ -844,7 +823,7 @@ AH_handler_policy_post (struct MHD_Connection *connection,
           GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD,
                                       &usp,
                                       &puc->account_sig.eddsa_sig,
-                                      &accountPubP.pub))
+                                      &account_pub->pub))
       {
         GNUNET_break_op (0);
         return TALER_MHD_reply_with_error (connection,
@@ -917,14 +896,14 @@ AH_handler_policy_post (struct MHD_Connection *connection,
           int post_counter = 10;
 
           qs = db->record_recdoc_payment (db->cls,
-                                          &accountPubP,
+                                          account_pub,
                                           post_counter,
                                           &puc->payment_identifier,
                                           &AH_annual_fee);
           if (qs >= 0)
           {
             qs = db->increment_lifetime (db->cls,
-                                         &accountPubP,
+                                         account_pub,
                                          &puc->payment_identifier,
                                          GNUNET_TIME_UNIT_YEARS);
           }
@@ -945,7 +924,7 @@ AH_handler_policy_post (struct MHD_Connection *connection,
       }
 
       qs = db->lookup_account (db->cls,
-                               &accountPubP,
+                               account_pub,
                                &hc);
 
       if (qs < 0)
diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 8aadf38..a30f77c 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -259,8 +259,8 @@ proposal_cb (void *cls,
   if (0 >= qs)
   {
     GNUNET_break (0);
-    gc->resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_CREATE_DB_ERROR,
-                                     "Failed to persist payment request in 
anastasis database");
+    gc->resp = TALER_MHD_make_error (TALER_EC_GENERIC_DB_STORE_FAILED,
+                                     "record challenge payment");
     gc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
     return;
   }
@@ -374,8 +374,8 @@ check_payment_cb (void *cls,
     if (0 <= qs)
       return; /* continue as planned */
     GNUNET_break (0);
-    gc->resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_CONFIRM_DB_ERROR,
-                                     "Failed to persist payment confirmation 
in sync database");
+    gc->resp = TALER_MHD_make_error (TALER_EC_GENERIC_DB_STORE_FAILED,
+                                     "challenge payment");
     gc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
     return; /* continue as planned */
   }
@@ -391,7 +391,7 @@ check_payment_cb (void *cls,
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Timeout waiting for payment\n");
-  gc->resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_TIMEOUT,
+  gc->resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_GENERIC_TIMEOUT,
                                    "Timeout awaiting promised payment");
   GNUNET_assert (NULL != gc->resp);
   gc->response_code = MHD_HTTP_REQUEST_TIMEOUT;
@@ -455,8 +455,8 @@ begin_payment (struct GetContext *gc,
     struct MHD_Response *resp;
     MHD_RESULT ret;
 
-    resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_CHECK_ORDER_DB_ERROR,
-                                 "Failed to check for expired payment in 
anastasis database");
+    resp = TALER_MHD_make_error (TALER_EC_GENERIC_DB_FETCH_FAILED,
+                                 "challenge payment");
     ret = MHD_queue_response (gc->connection,
                               MHD_HTTP_INTERNAL_SERVER_ERROR,
                               resp);
diff --git a/src/backend/anastasis-httpd_truth_upload.c 
b/src/backend/anastasis-httpd_truth_upload.c
index 7a50c70..7228d99 100644
--- a/src/backend/anastasis-httpd_truth_upload.c
+++ b/src/backend/anastasis-httpd_truth_upload.c
@@ -30,32 +30,6 @@
 #include <taler/taler_merchant_service.h>
 #include <taler/taler_signatures.h>
 
-/**
- * @param connection the MHD connection to handle
- * @param truth information about the truth
- * @return MHD result code
- */
-static int
-verify_and_execute_truth (struct MHD_Connection *connection,
-                          struct ANASTASIS_DB_Truth *truth,
-                          const struct
-                          ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key)
-{
-  enum ANASTASIS_DB_QueryStatus qs;
-  qs = db->store_truth (db->cls,
-                        truth_public_key,
-                        &truth->keyshare_data,
-                        truth->truth_mime,
-                        truth->encrypted_truth,
-                        truth->encrypted_truth_size,
-                        truth->method,
-                        AH_truth_expiration);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Store truth db status: %i\n",
-              qs);
-  return qs;
-}
-
 
 static void
 cleanup_parse_post_json (struct TM_HandlerContext *hc)
@@ -84,6 +58,7 @@ AH_handler_truth_post (struct MHD_Connection *connection,
   struct ANASTASIS_CRYPTO_TruthPublicKeyP truth_public_key;
   int res;
   struct ANASTASIS_DB_Truth truth;
+  enum ANASTASIS_DB_QueryStatus qs;
 
   /* extract public key from url */
   {
@@ -125,31 +100,38 @@ AH_handler_truth_post (struct MHD_Connection *connection,
       return MHD_NO; /* hard failure */
     if (GNUNET_NO == res)
       return MHD_YES; /* failure */
-    res = verify_and_execute_truth (connection,
-                                    &truth,
-                                    &truth_public_key);
+    qs = db->store_truth (db->cls,
+                          &truth_public_key,
+                          &truth.keyshare_data,
+                          truth.truth_mime,
+                          truth.encrypted_truth,
+                          truth.encrypted_truth_size,
+                          truth.method,
+                          AH_truth_expiration);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Store truth db status: %i\n",
+                qs);
     json_decref (json);
     GNUNET_JSON_parse_free (spec);
-    if (GNUNET_OK == res)
+    if (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT == qs)
     {
-      {
-        struct MHD_Response *resp;
+      struct MHD_Response *resp;
 
-        resp = MHD_create_response_from_buffer (0,
-                                                NULL,
-                                                MHD_RESPMEM_PERSISTENT);
-        TALER_MHD_add_global_headers (resp);
-        ret = MHD_queue_response (connection,
-                                  MHD_HTTP_NO_CONTENT,
-                                  resp);
-        MHD_destroy_response (resp);
-      }
+      resp = MHD_create_response_from_buffer (0,
+                                              NULL,
+                                              MHD_RESPMEM_PERSISTENT);
+      TALER_MHD_add_global_headers (resp);
+      ret = MHD_queue_response (connection,
+                                MHD_HTTP_NO_CONTENT,
+                                resp);
+      MHD_destroy_response (resp);
       return ret;
     }
     GNUNET_break (0);
+    // FIXME: probably should consider 'qs' values in more detail here...
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       
TALER_EC_SYNC_DB_INCONSISTENT_FETCH_ERROR,
+                                       TALER_EC_GENERIC_DB_INVARIANT_FAILURE,
                                        "database failure");
   }
 }
diff --git a/src/backend/anastasis_authorization_plugin_file.c 
b/src/backend/anastasis_authorization_plugin_file.c
index 827f449..bd81c67 100644
--- a/src/backend/anastasis_authorization_plugin_file.c
+++ b/src/backend/anastasis_authorization_plugin_file.c
@@ -150,7 +150,7 @@ file_process (struct ANASTASIS_AUTHORIZATION_State *as,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Could not open file");
-    resp = TALER_MHD_make_error (TALER_EC_INTERNAL_INVARIANT_FAILURE,
+    resp = TALER_MHD_make_error (TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
                                  "Failed to open filebuffer");
     mres = MHD_queue_response (connection,
                                MHD_HTTP_INTERNAL_SERVER_ERROR,
@@ -165,7 +165,7 @@ file_process (struct ANASTASIS_AUTHORIZATION_State *as,
   if (0 >= fprintf (f, "%lu", as->code))
   {
     fclose (f);
-    resp = TALER_MHD_make_error (TALER_EC_INTERNAL_INVARIANT_FAILURE,
+    resp = TALER_MHD_make_error (TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
                                  "Failed to write to file");
     mres = MHD_queue_response (connection,
                                MHD_HTTP_INTERNAL_SERVER_ERROR,
diff --git a/src/include/anastasis_error_codes.h 
b/src/include/anastasis_error_codes.h
index 7fda5ab..a6e051e 100644
--- a/src/include/anastasis_error_codes.h
+++ b/src/include/anastasis_error_codes.h
@@ -53,7 +53,7 @@ enum ANASTASIS_ErrorCode
   /**
    * Special code to indicate that a parameter in the request was malformed.
    */
-  ANASTASIS_EC_PARAMETER_MALFORMED = 6002,
+  ANASTASIS_EC_GENERIC_PARAMETER_MALFORMED = 6002,
 
   /**
    * The specified User was unknown
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index 54c7d28..96d51d3 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -278,7 +278,8 @@ add_authentication (json_t *state,
   {
     json_t *error = json_pack ("{s:I, s:s}",
                                "code",
-                               (json_int_t) ANASTASIS_EC_PARAMETER_MALFORMED,
+                               (json_int_t)
+                               ANASTASIS_EC_GENERIC_PARAMETER_MALFORMED,
                                "hint",
                                "Authentication method not supported!");
     cb (cb_cls,
@@ -291,7 +292,8 @@ add_authentication (json_t *state,
   {
     json_t *error = json_pack ("{s:I, s:s}",
                                "code",
-                               (json_int_t) ANASTASIS_EC_PARAMETER_MALFORMED,
+                               (json_int_t)
+                               ANASTASIS_EC_GENERIC_PARAMETER_MALFORMED,
                                "hint",
                                "Authentication data missing!");
     cb (cb_cls,
@@ -715,7 +717,8 @@ add_policy (json_t *state,
   {
     json_t *error = json_pack ("{s:I, s:s}",
                                "code",
-                               (json_int_t) ANASTASIS_EC_PARAMETER_MALFORMED,
+                               (json_int_t)
+                               ANASTASIS_EC_GENERIC_PARAMETER_MALFORMED,
                                "hint",
                                "Policy is malformed!");
     cb (cb_cls,
@@ -1111,7 +1114,8 @@ enter_secret (json_t *state,
   {
     json_t *error = json_pack ("{s:I, s:s}",
                                "code",
-                               (json_int_t) ANASTASIS_EC_PARAMETER_MALFORMED,
+                               (json_int_t)
+                               ANASTASIS_EC_GENERIC_PARAMETER_MALFORMED,
                                "hint",
                                "Secret is malformed!");
     cb (cb_cls,
diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index 1959ae5..0eed76d 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -67,7 +67,7 @@ ANASTASIS_generic_state_to_string (enum 
ANASTASIS_GenericState gs)
  * 60s is very generous, given the tiny bandwidth required, even for the most
  * remote locations.
  */
-#define CONFIG_TIMEOUT GNUNET_TIME_UNIT_MINUTES
+#define CONFIG_GENERIC_TIMEOUT GNUNET_TIME_UNIT_MINUTES
 
 
 struct SelectCountryHandle;
@@ -818,7 +818,7 @@ select_country (json_t *state,
       }
       else
       {
-        cr->tt = GNUNET_SCHEDULER_add_delayed (CONFIG_TIMEOUT,
+        cr->tt = GNUNET_SCHEDULER_add_delayed (CONFIG_GENERIC_TIMEOUT,
                                                &config_request_timeout,
                                                cr);
       }
@@ -970,7 +970,8 @@ enter_user_attributes (json_t *state,
     {
       json_t *error = json_pack ("{s:I, s:s}",
                                  "code",
-                                 (json_int_t) ANASTASIS_EC_PARAMETER_MALFORMED,
+                                 (json_int_t)
+                                 ANASTASIS_EC_GENERIC_PARAMETER_MALFORMED,
                                  "hint",
                                  "Validation of AHV number failed. Please 
check if number is correct.");
       cb (cb_cls,

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