gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated: preparations for #4


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: preparations for #4840
Date: Thu, 29 Jun 2017 20:46:59 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new f048de9  preparations for #4840
f048de9 is described below

commit f048de97822f29ec3dae5de57fab7a72a1fc4d8a
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Jun 29 20:46:52 2017 +0200

    preparations for #4840
---
 src/exchange-lib/exchange_api_handle.c       | 25 +++++++++++++++++++---
 src/exchange/taler-exchange-httpd_keystate.c | 31 ++++++++++++++++++++++++++--
 src/include/taler_error_codes.h              |  8 ++++++-
 src/include/taler_exchange_service.h         |  7 +++++++
 4 files changed, 65 insertions(+), 6 deletions(-)

diff --git a/src/exchange-lib/exchange_api_handle.c 
b/src/exchange-lib/exchange_api_handle.c
index 590d4de..96ae45b 100644
--- a/src/exchange-lib/exchange_api_handle.c
+++ b/src/exchange-lib/exchange_api_handle.c
@@ -497,7 +497,10 @@ decode_keys_json (const json_t *resp_obj,
   struct GNUNET_HashContext *hash_context;
   struct TALER_ExchangePublicKeyP pub;
 
-  memset (key_data, 0, sizeof (struct TALER_EXCHANGE_Keys));
+  /* FIXME: #4840: handle incremental / cherry-picked /keys! */
+  memset (key_data,
+         0,
+         sizeof (struct TALER_EXCHANGE_Keys));
   if (JSON_OBJECT != json_typeof (resp_obj))
     return GNUNET_SYSERR;
 
@@ -602,7 +605,8 @@ decode_keys_json (const json_t *resp_obj,
       key_data->num_auditors = len;
     }
   }
-
+  key_data->last_issue_date = list_issue_date;
+  
   /* Validate signature... */
   ks.purpose.size = htonl (sizeof (ks));
   ks.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_KEY_SET);
@@ -987,7 +991,22 @@ request_keys (struct TALER_EXCHANGE_Handle *exchange)
   GNUNET_assert (NULL == exchange->kr);
   kr = GNUNET_new (struct KeysRequest);
   kr->exchange = exchange;
-  kr->url = MAH_path_to_url (exchange, "/keys");
+  if (GNUNET_YES == MAH_handle_is_ready (exchange))
+  {
+    char *arg;
+
+    GNUNET_asprintf (&arg,
+                    "/keys?last_issue_date=%llu",
+                    (unsigned long long) 
exchange->key_data.last_issue_date.abs_value_us);
+    kr->url = MAH_path_to_url (exchange,
+                              arg);
+    GNUNET_free (arg);
+  }
+  else
+  {
+    kr->url = MAH_path_to_url (exchange,
+                              "/keys");
+  }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Requesting keys with URL `%s'.\n",
               kr->url);
diff --git a/src/exchange/taler-exchange-httpd_keystate.c 
b/src/exchange/taler-exchange-httpd_keystate.c
index 7cfd13d..ec0a470 100644
--- a/src/exchange/taler-exchange-httpd_keystate.c
+++ b/src/exchange/taler-exchange-httpd_keystate.c
@@ -661,7 +661,6 @@ reload_auditor_iter (void *cls,
                      const struct TALER_DenominationKeyValidityPS *dki)
 {
   struct TEH_KS_StateHandle *ctx = cls;
-  unsigned int i;
   unsigned int keep;
   const struct TALER_AuditorSignatureP *kept_asigs[dki_len];
   const struct TALER_DenominationKeyValidityPS *kept_dkis[dki_len];
@@ -678,7 +677,7 @@ reload_auditor_iter (void *cls,
   /* Filter the auditor information for those for which the
      keys actually match the denomination keys that are active right now */
   keep = 0;
-  for (i=0;i<dki_len;i++)
+  for (unsigned int i=0;i<dki_len;i++)
   {
     if (GNUNET_YES ==
         GNUNET_CONTAINER_multihashmap_contains (ctx->denomkey_map,
@@ -1274,8 +1273,36 @@ TEH_KS_handler_keys (struct TEH_RequestHandler *rh,
   char *json;
   size_t json_len;
   int comp;
+  const char *have;
+  struct GNUNET_TIME_Absolute last_issue_date;
 
+  have = MHD_lookup_connection_value (connection,
+                                     MHD_GET_ARGUMENT_KIND,
+                                     "last_issue_date");
+  if (NULL != have)
+  {
+    unsigned long long haven;
+    
+    if (1 !=
+       sscanf (have,
+               "%llu",
+               &haven))
+    {
+      GNUNET_break_op (0);
+      return TEH_RESPONSE_reply_arg_invalid (connection,
+                                            TALER_EC_KEYS_HAVE_NOT_NUMERIC,
+                                            "have");
+    }
+    last_issue_date.abs_value_us = (uint64_t) haven;
+  }
+  else
+  {
+    last_issue_date.abs_value_us = 0LLU;
+  }
+  
   key_state = TEH_KS_acquire ();
+  /* FIXME: #4840: compute /keys delta from last_issue_date */
+  (void) last_issue_date;
   comp = MHD_NO;
   if (NULL != key_state->keys_jsonz)
     comp = TEH_RESPONSE_can_compress (connection);
diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h
index 5e9988e..907be84 100644
--- a/src/include/taler_error_codes.h
+++ b/src/include/taler_error_codes.h
@@ -895,7 +895,13 @@ enum TALER_ErrorCode
    */
   TALER_EC_PAYBACK_COIN_BALANCE_NEGATIVE = 1857,
 
-
+  /**
+   * The "have" parameter was not a natural number.
+   * This reponse is provied with an HTTP status code of
+   * MHD_HTTP_BAD_REQUEST.
+   */
+  TALER_EC_KEYS_HAVE_NOT_NUMERIC = 1900,
+  
 
   /* *********** Merchant backend error codes ********* */
 
diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 9a004a4..04fa51f 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -206,6 +206,13 @@ struct TALER_EXCHANGE_Keys
   char *version;
 
   /**
+   * Timestamp indicating the /keys generation.  Monotonically
+   * increasing. Used to fetch /keys incrementally.  Set from
+   * the "list_issue_date" timestamp of /keys.
+   */
+  struct GNUNET_TIME_Absolute last_issue_date;
+  
+  /**
    * Length of the @e sign_keys array.
    */
   unsigned int num_sign_keys;

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



reply via email to

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