merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit c22eb34d925c55e1a07710c6f0e8df5b954dece7
parent 1b7e296a8a4229ad46c78eee8766a31293736e8b
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 10 Apr 2020 22:07:11 +0200

implement #6136

Diffstat:
Msrc/backend/taler-merchant-httpd_exchanges.c | 11+++++++++--
Msrc/backend/taler-merchant-httpd_pay.c | 23++++++++++++++++++++++-
2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c @@ -30,6 +30,13 @@ #define RELOAD_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) /** + * Delay after which we'll allow clients to force us to re-fetch key + * information from the exchange if we don't know the denomination key. + */ +#define FORCED_RELOAD_DELAY GNUNET_TIME_relative_multiply ( \ + GNUNET_TIME_UNIT_MINUTES, 15) + +/** * Threshold after which exponential backoff should not increase. */ #define RETRY_BACKOFF_THRESHOLD GNUNET_TIME_relative_multiply ( \ @@ -961,12 +968,12 @@ TMH_EXCHANGES_find_exchange (const char *chosen_exchange, { /* increment exponential-backoff */ exchange->retry_delay = RETRY_BACKOFF (exchange->retry_delay); - /* do not allow forced check until both backoff and #RELOAD_DELAY + /* do not allow forced check until both backoff and #FORCED_RELOAD_DELAY are satisified again */ exchange->first_retry = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_max ( exchange->retry_delay, - RELOAD_DELAY)); + FORCED_RELOAD_DELAY)); TALER_EXCHANGE_check_keys_current (exchange->conn, GNUNET_YES, GNUNET_NO); diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c @@ -371,6 +371,11 @@ struct PayContext int suspended; /** + * #GNUNET_YES if we already tried a forced /keys download. + */ + int tried_force_keys; + + /** * Which operational mode is the /pay request made in? */ enum { PC_MODE_PAY, PC_MODE_ABORT_REFUND } mode; @@ -1208,6 +1213,9 @@ process_pay_with_exchange (void *cls, enum TALER_ErrorCode ec; unsigned int hc; + if (NULL != dc->dh) + continue; /* we were here before (can happen due to + tried_force_keys logic), don't go again */ if (GNUNET_YES == dc->found_in_db) continue; if (0 != strcmp (dc->exchange_url, @@ -1217,9 +1225,22 @@ process_pay_with_exchange (void *cls, &dc->denom); if (NULL == denom_details) { - /* FIXME: #6136 applies HERE */ struct GNUNET_HashCode h_denom; + if (! pc->tried_force_keys) + { + /* let's try *forcing* a re-download of /keys from the exchange. + Maybe the wallet has seen /keys that we missed. */ + pc->tried_force_keys = GNUNET_YES; + pc->fo = TMH_EXCHANGES_find_exchange (pc->current_exchange, + pc->wm->wire_method, + GNUNET_YES, + &process_pay_with_exchange, + pc); + if (NULL != pc->fo) + return; + } + /* Forcing failed or we already did it, give up */ GNUNET_CRYPTO_rsa_public_key_hash (dc->denom.rsa_public_key, &h_denom); resume_pay_with_response (