aboutsummaryrefslogtreecommitdiff
path: root/src/lib/auditor_api_handle.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-06-21 07:53:17 +0200
committerChristian Grothoff <christian@grothoff.org>2023-06-21 07:53:17 +0200
commit17789253e9194c66bb9ddb081425a35212ac7bf3 (patch)
treed8acb45cf9a87aecb421707017e7b5be47df1c1a /src/lib/auditor_api_handle.c
parentd6838ed841185c7850c3f52d91d1baa9a1f90a7e (diff)
downloadexchange-17789253e9194c66bb9ddb081425a35212ac7bf3.tar.xz
ensure forward-compatibility for auditor C API
Diffstat (limited to 'src/lib/auditor_api_handle.c')
-rw-r--r--src/lib/auditor_api_handle.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/src/lib/auditor_api_handle.c b/src/lib/auditor_api_handle.c
index 14869de43..318b63f94 100644
--- a/src/lib/auditor_api_handle.c
+++ b/src/lib/auditor_api_handle.c
@@ -239,10 +239,9 @@ version_completed_cb (void *cls,
{
struct TALER_AUDITOR_Handle *auditor = cls;
const json_t *resp_obj = gresp_obj;
- enum TALER_AUDITOR_VersionCompatibility vc;
- struct TALER_AUDITOR_HttpResponse hr = {
- .reply = resp_obj,
- .http_status = (unsigned int) response_code
+ struct TALER_AUDITOR_VersionResponse vr = {
+ .hr.reply = resp_obj,
+ .hr.http_status = (unsigned int) response_code
};
auditor->vr = NULL;
@@ -250,7 +249,6 @@ version_completed_cb (void *cls,
"Received version from URL `%s' with status %ld.\n",
auditor->url,
response_code);
- vc = TALER_AUDITOR_VC_PROTOCOL_ERROR;
switch (response_code)
{
case 0:
@@ -268,28 +266,33 @@ version_completed_cb (void *cls,
{
GNUNET_break_op (0);
TALER_LOG_WARNING ("NULL body for a 200-OK /config\n");
- hr.http_status = 0;
- hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ vr.hr.http_status = 0;
+ vr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
}
- hr.ec = decode_version_json (resp_obj,
- auditor,
- &vc);
- if (TALER_EC_NONE != hr.ec)
+ vr.hr.ec = decode_version_json (resp_obj,
+ auditor,
+ &vr.details.ok.compat);
+ if (TALER_EC_NONE != vr.hr.ec)
{
GNUNET_break_op (0);
- hr.http_status = 0;
+ vr.hr.http_status = 0;
break;
}
+ auditor->state = MHS_VERSION;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Auditor %s is ready!\n",
+ auditor->url);
+ vr.details.ok.vi = auditor->vi;
auditor->retry_delay = GNUNET_TIME_UNIT_ZERO; /* restart quickly */
break;
default:
- hr.ec = TALER_JSON_get_error_code (resp_obj);
- hr.hint = TALER_JSON_get_error_hint (resp_obj);
+ vr.hr.ec = TALER_JSON_get_error_code (resp_obj);
+ vr.hr.hint = TALER_JSON_get_error_hint (resp_obj);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- (int) hr.ec);
+ (int) vr.hr.ec);
break;
}
if (MHD_HTTP_OK != response_code)
@@ -299,23 +302,9 @@ version_completed_cb (void *cls,
auditor->url,
(unsigned int) response_code);
auditor->state = MHS_FAILED;
- /* notify application that we failed */
- auditor->version_cb (auditor->version_cb_cls,
- &hr,
- NULL,
- vc);
- return;
}
- TALER_LOG_DEBUG ("Switching auditor state to 'version'\n");
- auditor->state = MHS_VERSION;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Auditor %s is ready!\n",
- auditor->url);
- /* notify application about the key information */
auditor->version_cb (auditor->version_cb_cls,
- &hr,
- &auditor->vi,
- vc);
+ &vr);
}