aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-05-04 17:13:54 +0200
committerChristian Grothoff <christian@grothoff.org>2023-05-04 17:13:54 +0200
commit0bf27e7e97ed2b8b29ca610f8fb15d3194c84f07 (patch)
tree19574cd8c8baa6f33288706e35df4c01f20fcd84 /src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
parent9316c050740bf275468ca5429d402718d7e69a07 (diff)
-minor code cleanup
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c')
-rw-r--r--src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c74
1 files changed, 13 insertions, 61 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
index 3d807569..5e229b48 100644
--- a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
+++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
@@ -192,7 +192,7 @@ struct KycContext
/**
* How long are we willing to wait for the exchange(s)?
*/
- struct GNUNET_TIME_Relative timeout;
+ struct GNUNET_TIME_Absolute timeout;
/**
* HTTP status code to use for the reply, i.e 200 for "OK".
@@ -693,7 +693,7 @@ kyc_with_exchange (void *cls,
ekr->exchange_kyc_serial,
&h_payto,
ekr->kc->mi->settings.ut,
- kc->timeout,
+ GNUNET_TIME_absolute_get_remaining (kc->timeout),
&exchange_check_cb,
ekr);
}
@@ -786,39 +786,13 @@ get_instances_ID_kyc (struct TMH_MerchantInstance *mi,
kc->timeout_kycs = json_array ();
GNUNET_assert (NULL != kc->timeout_kycs);
- /* process 'timeout_ms' argument */
- {
- const char *long_poll_timeout_s;
-
- long_poll_timeout_s
- = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "timeout_ms");
- if (NULL != long_poll_timeout_s)
- {
- unsigned int timeout_ms;
- char dummy;
-
- if (1 != sscanf (long_poll_timeout_s,
- "%u%c",
- &timeout_ms,
- &dummy))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "timeout_ms must be non-negative number");
- }
- kc->timeout = GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_MILLISECONDS,
- timeout_ms);
- kc->timeout_task
- = GNUNET_SCHEDULER_add_delayed (kc->timeout,
- &handle_kyc_timeout,
- kc);
- }
- } /* end timeout processing */
+ TALER_MHD_parse_request_timeout (connection,
+ &kc->timeout);
+ if (! GNUNET_TIME_absolute_is_past (kc->timeout))
+ kc->timeout_task
+ = GNUNET_SCHEDULER_add_at (kc->timeout,
+ &handle_kyc_timeout,
+ kc);
/* process 'exchange_url' argument */
kc->exchange_url = MHD_lookup_connection_value (connection,
@@ -840,32 +814,10 @@ get_instances_ID_kyc (struct TMH_MerchantInstance *mi,
"exchange_url must be a valid HTTP(s) URL");
}
- /* process 'h_wire' argument */
- {
- const char *h_wire_s;
-
- h_wire_s
- = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "h_wire");
- if (NULL != h_wire_s)
- {
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (h_wire_s,
- strlen (h_wire_s),
- &kc->h_wire,
- sizeof (kc->h_wire)))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "h_wire must be Crockford base32 encoded hash");
- }
- kc->have_h_wire = true;
- }
- } /* end of h_wire processing */
-
+ TALER_MHD_parse_request_arg_auto (connection,
+ "h_wire",
+ &kc->h_wire,
+ kc->have_h_wire);
/* Check our database */
{
enum GNUNET_DB_QueryStatus qs;