aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-exchange.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-exchange.c')
-rw-r--r--src/backend/taler-merchant-exchange.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/backend/taler-merchant-exchange.c b/src/backend/taler-merchant-exchange.c
index d8755ee7..5ce419d6 100644
--- a/src/backend/taler-merchant-exchange.c
+++ b/src/backend/taler-merchant-exchange.c
@@ -85,7 +85,12 @@ struct Exchange
/**
* A connection to this exchange
*/
- struct TALER_EXCHANGE_Handle *conn;
+ struct TALER_EXCHANGE_GetKeysHandle *conn;
+
+ /**
+ * The keys of this exchange
+ */
+ struct TALER_EXCHANGE_Keys *keys;
/**
* Task where we retry fetching /keys from the exchange.
@@ -305,30 +310,27 @@ download_keys (void *cls);
static void
cert_cb (
void *cls,
- const struct TALER_EXCHANGE_KeysResponse *kr)
+ const struct TALER_EXCHANGE_KeysResponse *kr,
+ struct TALER_EXCHANGE_Keys *keys)
{
struct Exchange *e = cls;
- struct GNUNET_TIME_Timestamp t;
struct GNUNET_TIME_Absolute n;
+ e->conn = NULL;
switch (kr->hr.http_status)
{
case MHD_HTTP_OK:
e->ready = true;
+ TALER_EXCHANGE_keys_decref (e->keys);
+ e->keys = keys;
launch_inquiries_at_exchange (e);
/* Reset back-off */
e->retry_delay = GNUNET_TIME_UNIT_ZERO;
/* Success: rate limit at once per minute */
e->first_retry = GNUNET_TIME_relative_to_absolute (
GNUNET_TIME_UNIT_MINUTES);
- /* Moreover usually only go after the current
- response actually expired */
- t = TALER_EXCHANGE_check_keys_current (e->conn,
- TALER_EXCHANGE_CKF_NONE,
- NULL,
- NULL);
- n = GNUNET_TIME_absolute_max (t.abs_time,
- e->first_retry);
+ n = GNUNET_TIME_absolute_max (e->first_retry,
+ keys->key_data_expiration.abs_time);
if (NULL != e->retry_task)
GNUNET_SCHEDULER_cancel (e->retry_task);
e->retry_task = GNUNET_SCHEDULER_add_at (n,
@@ -340,7 +342,6 @@ cert_cb (
= GNUNET_TIME_STD_BACKOFF (e->retry_delay);
e->first_retry
= GNUNET_TIME_relative_to_absolute (e->retry_delay);
-
if (NULL != e->retry_task)
GNUNET_SCHEDULER_cancel (e->retry_task);
e->retry_task = GNUNET_SCHEDULER_add_delayed (e->retry_delay,
@@ -364,17 +365,13 @@ download_keys (void *cls)
e->retry_task = GNUNET_SCHEDULER_add_delayed (n,
&download_keys,
e);
- if (NULL == e->conn)
- e->conn = TALER_EXCHANGE_connect (ctx,
- e->exchange_url,
- &cert_cb,
- e,
- TALER_EXCHANGE_OPTION_END);
- else
- (void) TALER_EXCHANGE_check_keys_current (e->conn,
- TALER_EXCHANGE_CKF_NONE,
- NULL,
- NULL);
+ if ( (NULL == e->keys) ||
+ (GNUNET_TIME_absolute_is_past (e->keys->key_data_expiration.abs_time)) )
+ e->conn = TALER_EXCHANGE_get_keys (ctx,
+ e->exchange_url,
+ e->keys,
+ &cert_cb,
+ e);
}
@@ -516,7 +513,11 @@ shutdown_task (void *cls)
end_inquiry (w);
}
GNUNET_free (e->exchange_url);
- TALER_EXCHANGE_disconnect (e->conn);
+ if (NULL != e->conn)
+ {
+ TALER_EXCHANGE_get_keys_cancel (e->conn);
+ e->conn = NULL;
+ }
if (NULL != e->retry_task)
{
GNUNET_SCHEDULER_cancel (e->retry_task);
@@ -568,7 +569,7 @@ check_wire_fee (struct Inquiry *w,
const struct TALER_Amount *wire_fee)
{
struct Exchange *e = w->exchange;
- const struct TALER_EXCHANGE_Keys *keys;
+ const struct TALER_EXCHANGE_Keys *keys = e->keys;
struct TALER_WireFeeSet fees;
struct TALER_MasterSignatureP master_sig;
struct GNUNET_TIME_Timestamp start_date;
@@ -576,7 +577,6 @@ check_wire_fee (struct Inquiry *w,
enum GNUNET_DB_QueryStatus qs;
char *wire_method;
- keys = TALER_EXCHANGE_get_keys (e->conn);
if (NULL == keys)
{
GNUNET_break (0);
@@ -943,7 +943,7 @@ exchange_request (void *cls)
w->wdh = TALER_EXCHANGE_transfers_get (
ctx,
e->exchange_url,
- TALER_EXCHANGE_get_keys (e->conn),
+ e->keys,
&w->wtid,
&wire_transfer_cb,
w);