-fix build issues

This commit is contained in:
Christian Grothoff 2022-11-17 17:38:33 +01:00
parent 20afebe72a
commit a2371912ee
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -1469,65 +1469,43 @@ check_exchange_wire_out (struct WireAccount *wa)
* transactions). * transactions).
* *
* @param cls `struct WireAccount` with current wire account to process * @param cls `struct WireAccount` with current wire account to process
* @param http_status_code http status of the request * @param dhr HTTP response details
* @param ec error code in case something went wrong
* @param row_off identification of the position at which we are querying
* @param details details about the wire transfer
* @param json original response in JSON format
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
*/ */
static enum GNUNET_GenericReturnValue static void
history_debit_cb (void *cls, history_debit_cb (void *cls,
unsigned int http_status_code, const struct TALER_BANK_DebitHistoryResponse *dhr)
enum TALER_ErrorCode ec,
uint64_t row_off,
const struct TALER_BANK_DebitDetails *details,
const json_t *json)
{ {
struct WireAccount *wa = cls; struct WireAccount *wa = cls;
struct ReserveOutInfo *roi; struct ReserveOutInfo *roi;
size_t slen; size_t slen;
(void) json;
if (NULL == details)
{
wa->dhh = NULL; wa->dhh = NULL;
if ( (TALER_EC_NONE != ec) && switch (dhr->http_status)
( (! ignore_account_404) ||
(MHD_HTTP_NOT_FOUND != http_status_code) ) )
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, case MHD_HTTP_OK:
"Error fetching debit history of account %s: %u/%u!\n", for (unsigned int i = 0; i<dhr->details.success.details_length; i++)
wa->ai->section_name, {
http_status_code, const struct TALER_BANK_DebitDetails *dd
(unsigned int) ec); = &dhr->details.success.details[i];
commit (GNUNET_DB_STATUS_HARD_ERROR);
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
check_exchange_wire_out (wa);
return GNUNET_OK;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Analyzing bank DEBIT at %s of %s with WTID %s\n", "Analyzing bank DEBIT at %s of %s with WTID %s\n",
GNUNET_TIME_timestamp2s (details->execution_date), GNUNET_TIME_timestamp2s (dd->execution_date),
TALER_amount2s (&details->amount), TALER_amount2s (&dd->amount),
TALER_B2S (&details->wtid)); TALER_B2S (&dd->wtid));
/* Update offset */ /* Update offset */
wa->wire_off.out_wire_off = row_off; wa->wire_off.out_wire_off = dd->serial_id;
slen = strlen (details->credit_account_uri) + 1; slen = strlen (dd->credit_account_uri) + 1;
roi = GNUNET_malloc (sizeof (struct ReserveOutInfo) roi = GNUNET_malloc (sizeof (struct ReserveOutInfo)
+ slen); + slen);
GNUNET_CRYPTO_hash (&details->wtid, GNUNET_CRYPTO_hash (&dd->wtid,
sizeof (details->wtid), sizeof (dd->wtid),
&roi->subject_hash); &roi->subject_hash);
roi->details.amount = details->amount; roi->details.amount = dd->amount;
roi->details.execution_date = details->execution_date; roi->details.execution_date = dd->execution_date;
roi->details.wtid = details->wtid; roi->details.wtid = dd->wtid;
roi->details.credit_account_uri = (const char *) &roi[1]; roi->details.credit_account_uri = (const char *) &roi[1];
memcpy (&roi[1], memcpy (&roi[1],
details->credit_account_uri, dd->credit_account_uri,
slen); slen);
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONTAINER_multihashmap_put (out_map, GNUNET_CONTAINER_multihashmap_put (out_map,
@ -1542,19 +1520,41 @@ history_debit_cb (void *cls,
TALER_B2S (&roi->subject_hash)); TALER_B2S (&roi->subject_hash));
TALER_ARL_amount_add (&total_wire_format_amount, TALER_ARL_amount_add (&total_wire_format_amount,
&total_wire_format_amount, &total_wire_format_amount,
&details->amount); &dd->amount);
TALER_ARL_report (report_wire_format_inconsistencies, TALER_ARL_report (report_wire_format_inconsistencies,
GNUNET_JSON_PACK ( GNUNET_JSON_PACK (
TALER_JSON_pack_amount ("amount", TALER_JSON_pack_amount ("amount",
&details->amount), &dd->amount),
GNUNET_JSON_pack_uint64 ("wire_offset", GNUNET_JSON_pack_uint64 ("wire_offset",
row_off), dd->serial_id),
GNUNET_JSON_pack_string ("diagnostic", GNUNET_JSON_pack_string ("diagnostic",
diagnostic))); diagnostic)));
GNUNET_free (diagnostic); GNUNET_free (diagnostic);
return GNUNET_OK;
} }
return GNUNET_OK; }
check_exchange_wire_out (wa);
return;
case MHD_HTTP_NO_CONTENT:
check_exchange_wire_out (wa);
return;
case MHD_HTTP_NOT_FOUND:
if (ignore_account_404)
{
check_exchange_wire_out (wa);
return;
}
break;
default:
break;
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error fetching debit history of account %s: %u/%u!\n",
wa->ai->section_name,
dhr->http_status,
(unsigned int) dhr->ec);
commit (GNUNET_DB_STATUS_HARD_ERROR);
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
} }
@ -1764,49 +1764,14 @@ process_credits (void *cls);
/** /**
* This function is called for all transactions that * We got all of the incoming transactions for @a wa,
* are credited to the exchange's account (incoming * finish processing the account.
* transactions).
* *
* @param cls `struct WireAccount` we are processing * @param[in,out] wa wire account to process
* @param http_status HTTP status returned by the bank
* @param ec error code in case something went wrong
* @param row_off identification of the position at which we are querying
* @param details details about the wire transfer
* @param json raw response
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
*/ */
static enum GNUNET_GenericReturnValue static void
history_credit_cb (void *cls, conclude_account (struct WireAccount *wa)
unsigned int http_status,
enum TALER_ErrorCode ec,
uint64_t row_off,
const struct TALER_BANK_CreditDetails *details,
const json_t *json)
{ {
struct WireAccount *wa = cls;
struct ReserveInInfo *rii;
struct GNUNET_HashCode key;
(void) json;
if (NULL == details)
{
wa->chh = NULL;
if ( (TALER_EC_NONE != ec) &&
( (! ignore_account_404) ||
(MHD_HTTP_NOT_FOUND != http_status) ) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error fetching credit history of account %s: %u/%s!\n",
wa->ai->section_name,
http_status,
TALER_ErrorCode_get_hint (ec));
commit (GNUNET_DB_STATUS_HARD_ERROR);
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
/* end of operation */
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Reconciling CREDIT processing of account `%s'\n", "Reconciling CREDIT processing of account `%s'\n",
wa->ai->section_name); wa->ai->section_name);
@ -1818,15 +1783,30 @@ history_credit_cb (void *cls,
&free_rii, &free_rii,
NULL); NULL);
process_credits (wa->next); process_credits (wa->next);
return GNUNET_OK; }
}
/**
* Analyze credit transation @a details into @a wa.
*
* @param[in,out] wa account that received the transfer
* @param details transfer details
* @return true on success, false to stop loop at this point
*/
static bool
analyze_credit (struct WireAccount *wa,
const struct TALER_BANK_CreditDetails *details)
{
struct ReserveInInfo *rii;
struct GNUNET_HashCode key;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Analyzing bank CREDIT at %s of %s with Reserve-pub %s\n", "Analyzing bank CREDIT at %s of %s with Reserve-pub %s\n",
GNUNET_TIME_timestamp2s (details->execution_date), GNUNET_TIME_timestamp2s (details->execution_date),
TALER_amount2s (&details->amount), TALER_amount2s (&details->amount),
TALER_B2S (&details->reserve_pub)); TALER_B2S (&details->reserve_pub));
GNUNET_CRYPTO_hash (&row_off, GNUNET_CRYPTO_hash (&details->serial_id,
sizeof (row_off), sizeof (details->serial_id),
&key); &key);
rii = GNUNET_CONTAINER_multihashmap_get (in_map, rii = GNUNET_CONTAINER_multihashmap_get (in_map,
&key); &key);
@ -1835,13 +1815,12 @@ history_credit_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Failed to find wire transfer at `%s' in exchange database. Audit ends at this point in time.\n", "Failed to find wire transfer at `%s' in exchange database. Audit ends at this point in time.\n",
GNUNET_TIME_timestamp2s (details->execution_date)); GNUNET_TIME_timestamp2s (details->execution_date));
wa->chh = NULL;
process_credits (wa->next); process_credits (wa->next);
return GNUNET_SYSERR; /* not an error, just end of processing */ return false; /* not an error, just end of processing */
} }
/* Update offset */ /* Update offset */
wa->wire_off.in_wire_off = row_off; wa->wire_off.in_wire_off = details->serial_id;
/* compare records with expected data */ /* compare records with expected data */
if (0 != GNUNET_memcmp (&details->reserve_pub, if (0 != GNUNET_memcmp (&details->reserve_pub,
&rii->details.reserve_pub)) &rii->details.reserve_pub))
@ -1852,7 +1831,7 @@ history_credit_cb (void *cls,
GNUNET_JSON_pack_uint64 ("row", GNUNET_JSON_pack_uint64 ("row",
rii->rowid), rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row", GNUNET_JSON_pack_uint64 ("bank_row",
row_off), details->serial_id),
TALER_JSON_pack_amount ("amount_exchange_expected", TALER_JSON_pack_amount ("amount_exchange_expected",
&rii->details.amount), &rii->details.amount),
TALER_JSON_pack_amount ("amount_wired", TALER_JSON_pack_amount ("amount_wired",
@ -1872,7 +1851,7 @@ history_credit_cb (void *cls,
GNUNET_JSON_pack_uint64 ("row", GNUNET_JSON_pack_uint64 ("row",
rii->rowid), rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row", GNUNET_JSON_pack_uint64 ("bank_row",
row_off), details->serial_id),
TALER_JSON_pack_amount ("amount_exchange_expected", TALER_JSON_pack_amount ("amount_exchange_expected",
&zero), &zero),
TALER_JSON_pack_amount ("amount_wired", TALER_JSON_pack_amount ("amount_wired",
@ -1898,7 +1877,7 @@ history_credit_cb (void *cls,
GNUNET_JSON_pack_uint64 ("row", GNUNET_JSON_pack_uint64 ("row",
rii->rowid), rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row", GNUNET_JSON_pack_uint64 ("bank_row",
row_off), details->serial_id),
TALER_JSON_pack_amount ("amount_exchange_expected", TALER_JSON_pack_amount ("amount_exchange_expected",
&rii->details.amount), &rii->details.amount),
TALER_JSON_pack_amount ("amount_wired", TALER_JSON_pack_amount ("amount_wired",
@ -1946,7 +1925,7 @@ history_credit_cb (void *cls,
GNUNET_JSON_pack_uint64 ("row", GNUNET_JSON_pack_uint64 ("row",
rii->rowid), rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row", GNUNET_JSON_pack_uint64 ("bank_row",
row_off), details->serial_id),
GNUNET_JSON_pack_data_auto ( GNUNET_JSON_pack_data_auto (
"reserve_pub", "reserve_pub",
&rii->details.reserve_pub))); &rii->details.reserve_pub)));
@ -1965,7 +1944,7 @@ history_credit_cb (void *cls,
GNUNET_JSON_pack_uint64 ("row", GNUNET_JSON_pack_uint64 ("row",
rii->rowid), rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row", GNUNET_JSON_pack_uint64 ("bank_row",
row_off), details->serial_id),
GNUNET_JSON_pack_string ("diagnostic", GNUNET_JSON_pack_string ("diagnostic",
"execution date mismatch"))); "execution date mismatch")));
} }
@ -1974,7 +1953,60 @@ cleanup:
free_rii (NULL, free_rii (NULL,
&key, &key,
rii)); rii));
return GNUNET_OK; return true;
}
/**
* This function is called for all transactions that
* are credited to the exchange's account (incoming
* transactions).
*
* @param cls `struct WireAccount` we are processing
* @param chr HTTP response returned by the bank
*/
static void
history_credit_cb (void *cls,
const struct TALER_BANK_CreditHistoryResponse *chr)
{
struct WireAccount *wa = cls;
wa->chh = NULL;
switch (chr->http_status)
{
case MHD_HTTP_OK:
for (unsigned int i = 0; i<chr->details.success.details_length; i++)
{
const struct TALER_BANK_CreditDetails *cd
= &chr->details.success.details[i];
if (! analyze_credit (wa,
cd))
break;
}
conclude_account (wa);
return;
case MHD_HTTP_NO_CONTENT:
conclude_account (wa);
return;
case MHD_HTTP_NOT_FOUND:
if (ignore_account_404)
{
conclude_account (wa);
return;
}
break;
default:
break;
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error fetching credit history of account %s: %u/%s!\n",
wa->ai->section_name,
chr->http_status,
TALER_ErrorCode_get_hint (chr->ec));
commit (GNUNET_DB_STATUS_HARD_ERROR);
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
} }