address DB failure error handling in KYC check
This commit is contained in:
parent
c239ba6f18
commit
42bd2dadcf
@ -1 +1 @@
|
||||
Subproject commit 3e659ed54023230dd45dbec5664f176e1763d260
|
||||
Subproject commit 7884adf99ec4d5ccf52b1a5a251b99fb6ab9c2f6
|
@ -297,6 +297,7 @@ kyc_check (void *cls,
|
||||
enum GNUNET_GenericReturnValue ret;
|
||||
struct TALER_PaytoHashP h_payto;
|
||||
char *requirements;
|
||||
bool satisfied;
|
||||
|
||||
qs = TEH_plugin->lookup_kyc_requirement_by_row (
|
||||
TEH_plugin->cls,
|
||||
@ -330,12 +331,26 @@ kyc_check (void *cls,
|
||||
GNUNET_free (requirements);
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
}
|
||||
if (TALER_KYCLOGIC_check_satisfied (
|
||||
requirements,
|
||||
&h_payto,
|
||||
&kyp->kyc_details,
|
||||
TEH_plugin->select_satisfied_kyc_processes,
|
||||
TEH_plugin->cls))
|
||||
qs = TALER_KYCLOGIC_check_satisfied (
|
||||
requirements,
|
||||
&h_payto,
|
||||
&kyp->kyc_details,
|
||||
TEH_plugin->select_satisfied_kyc_processes,
|
||||
TEH_plugin->cls,
|
||||
&satisfied);
|
||||
if (qs < 0)
|
||||
{
|
||||
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
|
||||
return qs;
|
||||
GNUNET_break (0);
|
||||
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||
TALER_EC_GENERIC_DB_FETCH_FAILED,
|
||||
"kyc_test_required");
|
||||
GNUNET_free (requirements);
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
}
|
||||
if (satisfied)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"KYC requirements `%s' already satisfied\n",
|
||||
|
@ -214,7 +214,7 @@ typedef enum GNUNET_DB_QueryStatus
|
||||
* amounts involved in this type of operation
|
||||
* at the given account
|
||||
* @param ai_cls closure for @a ai
|
||||
* @param[out] set to NULL if no check is needed,
|
||||
* @param[out] required set to NULL if no check is needed,
|
||||
* otherwise space-separated list of required checks
|
||||
* @return transaction status
|
||||
*/
|
||||
@ -238,14 +238,16 @@ TALER_KYCLOGIC_kyc_test_required (enum TALER_KYCLOGIC_KycTriggerEvent event,
|
||||
* KYC information was collected
|
||||
* @param ki iterator over satisfied providers
|
||||
* @param ki_cls closure for @a ki
|
||||
* @return true if the KYC check was satisfied
|
||||
* @param[out] satisfied set to true if the KYC check was satisfied
|
||||
* @return transaction status (from @a ki)
|
||||
*/
|
||||
bool
|
||||
enum GNUNET_DB_QueryStatus
|
||||
TALER_KYCLOGIC_check_satisfied (const char *requirements,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
json_t **kyc_details,
|
||||
TALER_KYCLOGIC_KycSatisfiedIterator ki,
|
||||
void *ki_cls);
|
||||
void *ki_cls,
|
||||
bool *satisfied);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1166,18 +1166,22 @@ TALER_KYCLOGIC_kyc_get_details (
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
enum GNUNET_DB_QueryStatus
|
||||
TALER_KYCLOGIC_check_satisfied (const char *requirements,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
json_t **kyc_details,
|
||||
TALER_KYCLOGIC_KycSatisfiedIterator ki,
|
||||
void *ki_cls)
|
||||
void *ki_cls,
|
||||
bool *satisfied)
|
||||
{
|
||||
struct TALER_KYCLOGIC_KycCheck *needed[num_kyc_checks];
|
||||
unsigned int needed_cnt = 0;
|
||||
|
||||
if (NULL == requirements)
|
||||
return true;
|
||||
{
|
||||
*satisfied = true;
|
||||
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
|
||||
}
|
||||
{
|
||||
char *req = GNUNET_strdup (requirements);
|
||||
|
||||
@ -1204,7 +1208,12 @@ TALER_KYCLOGIC_check_satisfied (const char *requirements,
|
||||
h_payto,
|
||||
&remove_satisfied,
|
||||
&rc);
|
||||
GNUNET_break (qs >= 0); // FIXME: handle DB failure more nicely?
|
||||
if (qs < 0)
|
||||
{
|
||||
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
|
||||
*satisfied = false;
|
||||
return qs;
|
||||
}
|
||||
if (0 != needed_cnt)
|
||||
{
|
||||
json_decref (rc.kyc_details);
|
||||
@ -1215,7 +1224,8 @@ TALER_KYCLOGIC_check_satisfied (const char *requirements,
|
||||
*kyc_details = rc.kyc_details;
|
||||
}
|
||||
}
|
||||
return (0 == needed_cnt);
|
||||
*satisfied = (0 == needed_cnt);
|
||||
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user