diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-04-10 21:59:14 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-04-10 21:59:14 +0200 |
commit | 1b7e296a8a4229ad46c78eee8766a31293736e8b (patch) | |
tree | e9f912dc0c6baa49b4c09e310e1990441ee6b101 | |
parent | 64a7d25e935107383d468a35ed37bb6f0f8776a6 (diff) | |
download | merchant-1b7e296a8a4229ad46c78eee8766a31293736e8b.tar.gz merchant-1b7e296a8a4229ad46c78eee8766a31293736e8b.tar.bz2 merchant-1b7e296a8a4229ad46c78eee8766a31293736e8b.zip |
preparatory steps for #6136
-rw-r--r-- | src/backend/taler-merchant-httpd_exchanges.c | 33 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_exchanges.h | 6 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 1 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_refund_lookup.c | 1 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_tip-pickup.c | 1 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_tip-reserve-helper.c | 1 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transaction.c | 1 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transfer.c | 1 | ||||
-rw-r--r-- | 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 a7b9cdd6..bd8905c6 100644 --- a/src/backend/taler-merchant-httpd_exchanges.c +++ b/src/backend/taler-merchant-httpd_exchanges.c @@ -192,6 +192,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? */ struct GNUNET_TIME_Relative retry_delay; @@ -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 eca69af2..523ed531 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 2d3bfcd3..d10d960c 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 0fd83ad3..946f90da 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 6c08cce2..096af605 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 fc5a1aa6..33ec5340 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 b64bf2e1..95626fe6 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 000738b2..5c6b3839 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 7ecf8b78..918ad758 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); } |