better naming, comments and more logging for incoming history

This commit is contained in:
Florian Dold 2020-01-22 13:53:11 +01:00
parent 975d9c9d15
commit 0fe82acc1b
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -132,16 +132,16 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh,
/** /**
* Function called when we're done processing the * Function called when we're done processing the
* HTTP /history request. * HTTP /history/incoming request.
* *
* @param cls the `struct TALER_BANK_CreditHistoryHandle` * @param cls the `struct TALER_BANK_CreditHistoryHandle`
* @param response_code HTTP response code, 0 on error * @param response_code HTTP response code, 0 on error
* @param response parsed JSON result, NULL on error * @param response parsed JSON result, NULL on error
*/ */
static void static void
handle_history_finished (void *cls, handle_credit_history_finished (void *cls,
long response_code, long response_code,
const void *response) const void *response)
{ {
struct TALER_BANK_CreditHistoryHandle *hh = cls; struct TALER_BANK_CreditHistoryHandle *hh = cls;
enum TALER_ErrorCode ec; enum TALER_ErrorCode ec;
@ -167,32 +167,36 @@ handle_history_finished (void *cls,
response_code = MHD_HTTP_NO_CONTENT; /* signal end of list */ response_code = MHD_HTTP_NO_CONTENT; /* signal end of list */
ec = TALER_EC_NONE; ec = TALER_EC_NONE;
break; break;
case MHD_HTTP_NO_CONTENT:
ec = TALER_EC_NONE;
break;
case MHD_HTTP_BAD_REQUEST: case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the bank is buggy /* This should never happen, either us or the bank is buggy
(or API version conflict); just pass JSON reply to the application */ (or API version conflict); just pass JSON reply to the application */
GNUNET_break_op (0);
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
case MHD_HTTP_FORBIDDEN: case MHD_HTTP_FORBIDDEN:
/* Access denied */ /* Access denied */
GNUNET_break_op (0);
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
case MHD_HTTP_UNAUTHORIZED: case MHD_HTTP_UNAUTHORIZED:
/* FIXME(dold): I don't get this comment below. What signatures would the
bank even verify?! */
/* Nothing really to verify, bank says one of the signatures is /* Nothing really to verify, bank says one of the signatures is
invalid; as we checked them, this should never happen, we invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */ should pass the JSON reply to the application */
GNUNET_break_op (0);
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
case MHD_HTTP_NOT_FOUND: case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never /* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */ happen, we should pass the JSON reply to the application */
GNUNET_break_op (0);
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
case MHD_HTTP_INTERNAL_SERVER_ERROR: case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API /* Server had an internal issue; we should retry, but this API
leaves this to the application */ leaves this to the application */
GNUNET_break_op (0);
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
default: default:
@ -200,7 +204,7 @@ handle_history_finished (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u\n", "Unexpected response code %u\n",
(unsigned int) response_code); (unsigned int) response_code);
GNUNET_break (0); GNUNET_break_op (0);
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
response_code = 0; response_code = 0;
break; break;
@ -297,7 +301,7 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
hh->job = GNUNET_CURL_job_add2 (ctx, hh->job = GNUNET_CURL_job_add2 (ctx,
eh, eh,
NULL, NULL,
&handle_history_finished, &handle_credit_history_finished,
hh); hh);
return hh; return hh;
} }