gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: preparatory steps for #6136


From: gnunet
Subject: [taler-merchant] branch master updated: preparatory steps for #6136
Date: Fri, 10 Apr 2020 21:59:16 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 1b7e296  preparatory steps for #6136
1b7e296 is described below

commit 1b7e296a8a4229ad46c78eee8766a31293736e8b
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Apr 10 21:59:14 2020 +0200

    preparatory steps for #6136
---
 src/backend/taler-merchant-httpd_exchanges.c       | 33 ++++++++++++++++++++++
 src/backend/taler-merchant-httpd_exchanges.h       |  6 ++++
 src/backend/taler-merchant-httpd_pay.c             |  1 +
 src/backend/taler-merchant-httpd_refund_lookup.c   |  1 +
 src/backend/taler-merchant-httpd_tip-pickup.c      |  1 +
 .../taler-merchant-httpd_tip-reserve-helper.c      |  1 +
 .../taler-merchant-httpd_track-transaction.c       |  1 +
 src/backend/taler-merchant-httpd_track-transfer.c  |  1 +
 src/lib/testing_api_cmd_pay_abort_refund.c         | 21 +++++++-------
 9 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_exchanges.c 
b/src/backend/taler-merchant-httpd_exchanges.c
index a7b9cdd..bd8905c 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -191,6 +191,11 @@ struct Exchange
    */
   struct TALER_MasterPublicKeyP master_pub;
 
+  /**
+   * How soon can may we, at the earliest, re-download /keys?
+   */
+  struct GNUNET_TIME_Absolute first_retry;
+
   /**
    * How long should we wait between the next retry?
    */
@@ -782,6 +787,8 @@ keys_mgmt_cb (void *cls,
                 GNUNET_STRINGS_relative_time_to_string (exchange->retry_delay,
                                                         GNUNET_YES));
     GNUNET_assert (NULL == exchange->retry_task);
+    exchange->first_retry = GNUNET_TIME_relative_to_absolute (
+      exchange->retry_delay);
     exchange->retry_task = GNUNET_SCHEDULER_add_delayed (exchange->retry_delay,
                                                          &retry_exchange,
                                                          exchange);
@@ -816,6 +823,7 @@ keys_mgmt_cb (void *cls,
   expire = TALER_EXCHANGE_check_keys_current (exchange->conn,
                                               GNUNET_NO,
                                               GNUNET_NO);
+  exchange->first_retry = GNUNET_TIME_relative_to_absolute (RELOAD_DELAY);
   if (0 == expire.abs_value_us)
     delay = RELOAD_DELAY;
   else
@@ -877,6 +885,11 @@ return_result (void *cls)
  *
  * @param chosen_exchange URL of the exchange we would like to talk to
  * @param wire_method the wire method we will use with @a chosen_exchange, 
NULL for none
+ * @param force_reload try to force reloading /keys from the exchange ASAP; 
note
+ *        that IF the forced reload fails, it is possible @a fc won't be 
called at all
+ *        until a /keys download succeeds; only use #GNUNET_YES if a new /keys 
request
+ *        is mandatory. If the force reload request is not allowed due to our 
rate limiting,
+ *        then @a fc will be called immediately with the existing /keys data
  * @param fc function to call with the handles for the exchange
  * @param fc_cls closure for @a fc
  * @return NULL on error
@@ -884,6 +897,7 @@ return_result (void *cls)
 struct TMH_EXCHANGES_FindOperation *
 TMH_EXCHANGES_find_exchange (const char *chosen_exchange,
                              const char *wire_method,
+                             int force_reload,
                              TMH_EXCHANGES_FindContinuation fc,
                              void *fc_cls)
 {
@@ -941,6 +955,25 @@ TMH_EXCHANGES_find_exchange (const char *chosen_exchange,
                                fo);
   now = GNUNET_TIME_absolute_get ();
   (void) GNUNET_TIME_round_abs (&now);
+  if ( (force_reload) &&
+       (0 == GNUNET_TIME_absolute_get_remaining (
+          exchange->first_retry).rel_value_us) )
+  {
+    /* increment exponential-backoff */
+    exchange->retry_delay = RETRY_BACKOFF (exchange->retry_delay);
+    /* do not allow forced check until both backoff and #RELOAD_DELAY
+       are satisified again */
+    exchange->first_retry
+      = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_max (
+                                            exchange->retry_delay,
+                                            RELOAD_DELAY));
+    TALER_EXCHANGE_check_keys_current (exchange->conn,
+                                       GNUNET_YES,
+                                       GNUNET_NO);
+    return fo;
+  }
+
+
   if ( (GNUNET_YES != exchange->pending) &&
        ( (NULL == fo->wire_method) ||
          (NULL != get_wire_fees (exchange,
diff --git a/src/backend/taler-merchant-httpd_exchanges.h 
b/src/backend/taler-merchant-httpd_exchanges.h
index eca69af..523ed53 100644
--- a/src/backend/taler-merchant-httpd_exchanges.h
+++ b/src/backend/taler-merchant-httpd_exchanges.h
@@ -90,12 +90,18 @@ struct TMH_EXCHANGES_FindOperation;
  *
  * @param chosen_exchange URL of the exchange we would like to talk to
  * @param wire_method the wire method we will use with @a chosen_exchange, 
NULL for none
+ * @param force_reload try to force reloading /keys from the exchange ASAP; 
note
+ *        that IF the forced reload fails, it is possible @a fc won't be 
called at all
+ *        until a /keys download succeeds; only use #GNUNET_YES if a new /keys 
request
+ *        is mandatory. If the force reload request is not allowed due to our 
rate limiting,
+ *        then @a fc will be called immediately with the existing /keys data
  * @param fc function to call with the handles for the exchange
  * @param fc_cls closure for @a fc
  */
 struct TMH_EXCHANGES_FindOperation *
 TMH_EXCHANGES_find_exchange (const char *chosen_exchange,
                              const char *wire_method,
+                             int force_reload,
                              TMH_EXCHANGES_FindContinuation fc,
                              void *fc_cls);
 
diff --git a/src/backend/taler-merchant-httpd_pay.c 
b/src/backend/taler-merchant-httpd_pay.c
index 2d3bfcd..d10d960 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -1318,6 +1318,7 @@ find_next_exchange (struct PayContext *pc)
       pc->current_exchange = dc->exchange_url;
       pc->fo = TMH_EXCHANGES_find_exchange (pc->current_exchange,
                                             pc->wm->wire_method,
+                                            GNUNET_NO,
                                             &process_pay_with_exchange,
                                             pc);
       if (NULL == pc->fo)
diff --git a/src/backend/taler-merchant-httpd_refund_lookup.c 
b/src/backend/taler-merchant-httpd_refund_lookup.c
index 0fd83ad..946f90d 100644
--- a/src/backend/taler-merchant-httpd_refund_lookup.c
+++ b/src/backend/taler-merchant-httpd_refund_lookup.c
@@ -563,6 +563,7 @@ MH_handler_refund_lookup (struct TMH_RequestHandler *rh,
         /* We need to talk to the exchange */
         cr->fo = TMH_EXCHANGES_find_exchange (cr->exchange_url,
                                               NULL,
+                                              GNUNET_NO,
                                               &exchange_found_cb,
                                               cr);
       }
diff --git a/src/backend/taler-merchant-httpd_tip-pickup.c 
b/src/backend/taler-merchant-httpd_tip-pickup.c
index 6c08cce..096af60 100644
--- a/src/backend/taler-merchant-httpd_tip-pickup.c
+++ b/src/backend/taler-merchant-httpd_tip-pickup.c
@@ -443,6 +443,7 @@ prepare_pickup (struct PickupContext *pc)
   }
   pc->fo = TMH_EXCHANGES_find_exchange (pc->exchange_url,
                                         NULL,
+                                        GNUNET_NO,
                                         &exchange_found_cb,
                                         pc);
   if (NULL == pc->fo)
diff --git a/src/backend/taler-merchant-httpd_tip-reserve-helper.c 
b/src/backend/taler-merchant-httpd_tip-reserve-helper.c
index fc5a1aa..33ec534 100644
--- a/src/backend/taler-merchant-httpd_tip-reserve-helper.c
+++ b/src/backend/taler-merchant-httpd_tip-reserve-helper.c
@@ -398,6 +398,7 @@ TMH_check_tip_reserve (struct TMH_CheckTipReserve *ctr,
   db->preflight (db->cls);
   ctr->fo = TMH_EXCHANGES_find_exchange (tip_exchange,
                                          NULL,
+                                         GNUNET_NO,
                                          &exchange_cont,
                                          ctr);
   if (NULL == ctr->fo)
diff --git a/src/backend/taler-merchant-httpd_track-transaction.c 
b/src/backend/taler-merchant-httpd_track-transaction.c
index b64bf2e..95626fe 100644
--- a/src/backend/taler-merchant-httpd_track-transaction.c
+++ b/src/backend/taler-merchant-httpd_track-transaction.c
@@ -1052,6 +1052,7 @@ find_exchange (struct TrackTransactionContext *tctx)
     tctx->fo = TMH_EXCHANGES_find_exchange (
       tctx->current_exchange,
       NULL,
+      GNUNET_NO,
       &process_track_transaction_with_exchange,
       tctx);
 
diff --git a/src/backend/taler-merchant-httpd_track-transfer.c 
b/src/backend/taler-merchant-httpd_track-transfer.c
index 000738b..5c6b383 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.c
+++ b/src/backend/taler-merchant-httpd_track-transfer.c
@@ -1079,6 +1079,7 @@ MH_handler_track_transfer (struct TMH_RequestHandler *rh,
   MHD_suspend_connection (connection);
   rctx->fo = TMH_EXCHANGES_find_exchange (url,
                                           NULL,
+                                          GNUNET_NO,
                                           
&process_track_transfer_with_exchange,
                                           rctx);
   rctx->timeout_task
diff --git a/src/lib/testing_api_cmd_pay_abort_refund.c 
b/src/lib/testing_api_cmd_pay_abort_refund.c
index 7ecf8b7..918ad75 100644
--- a/src/lib/testing_api_cmd_pay_abort_refund.c
+++ b/src/lib/testing_api_cmd_pay_abort_refund.c
@@ -190,17 +190,16 @@ pay_abort_refund_run (void *cls,
   GNUNET_assert (GNUNET_OK ==
                  TALER_string_to_amount (pars->refund_fee,
                                          &refund_fee));
-  pars->rh = TALER_EXCHANGE_refund2
-               (is->exchange,
-               &refund_amount,
-               &refund_fee,
-               h_contract_terms,
-               &refund_entry->coin_pub,
-               refund_entry->rtransaction_id,
-               merchant_pub,
-               &refund_entry->merchant_sig,
-               &abort_refund_cb,
-               pars);
+  pars->rh = TALER_EXCHANGE_refund2 (is->exchange,
+                                     &refund_amount,
+                                     &refund_fee,
+                                     h_contract_terms,
+                                     &refund_entry->coin_pub,
+                                     refund_entry->rtransaction_id,
+                                     merchant_pub,
+                                     &refund_entry->merchant_sig,
+                                     &abort_refund_cb,
+                                     pars);
   GNUNET_assert (NULL != pars->rh);
 }
 

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



reply via email to

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