do not 500 on empty reserve history by not ignoring undecided purses that may have caused reserve to be created in the first place
This commit is contained in:
parent
8563dcc845
commit
faf3f57ce3
@ -704,6 +704,7 @@ TEH_RESPONSE_compile_reserve_history (
|
|||||||
json_t *json_history;
|
json_t *json_history;
|
||||||
|
|
||||||
json_history = json_array ();
|
json_history = json_array ();
|
||||||
|
GNUNET_assert (NULL != json_history);
|
||||||
for (const struct TALER_EXCHANGEDB_ReserveHistory *pos = rh;
|
for (const struct TALER_EXCHANGEDB_ReserveHistory *pos = rh;
|
||||||
NULL != pos;
|
NULL != pos;
|
||||||
pos = pos->next)
|
pos = pos->next)
|
||||||
@ -1012,10 +1013,14 @@ reply_reserve_insufficient_funds (
|
|||||||
|
|
||||||
json_history = TEH_RESPONSE_compile_reserve_history (rh);
|
json_history = TEH_RESPONSE_compile_reserve_history (rh);
|
||||||
if (NULL == json_history)
|
if (NULL == json_history)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Failed to compile reserve history\n");
|
||||||
return TALER_MHD_reply_with_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
TALER_EC_EXCHANGE_RESERVE_HISTORY_ERROR_INSUFFICIENT_FUNDS,
|
TALER_EC_EXCHANGE_RESERVE_HISTORY_ERROR_INSUFFICIENT_FUNDS,
|
||||||
NULL);
|
NULL);
|
||||||
|
}
|
||||||
return TALER_MHD_REPLY_JSON_PACK (
|
return TALER_MHD_REPLY_JSON_PACK (
|
||||||
connection,
|
connection,
|
||||||
MHD_HTTP_CONFLICT,
|
MHD_HTTP_CONFLICT,
|
||||||
@ -1061,6 +1066,7 @@ TEH_RESPONSE_reply_reserve_insufficient_balance (
|
|||||||
if ( (qs < 0) ||
|
if ( (qs < 0) ||
|
||||||
(NULL == rh) )
|
(NULL == rh) )
|
||||||
{
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
return TALER_MHD_reply_with_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
TALER_EC_GENERIC_DB_FETCH_FAILED,
|
TALER_EC_GENERIC_DB_FETCH_FAILED,
|
||||||
|
@ -215,6 +215,8 @@ withdraw_transaction (void *cls,
|
|||||||
if (! balance_ok)
|
if (! balance_ok)
|
||||||
{
|
{
|
||||||
TEH_plugin->rollback (TEH_plugin->cls);
|
TEH_plugin->rollback (TEH_plugin->cls);
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
|
"Balance insufficient for /withdraw\n");
|
||||||
*mhd_ret = TEH_RESPONSE_reply_reserve_insufficient_balance (
|
*mhd_ret = TEH_RESPONSE_reply_reserve_insufficient_balance (
|
||||||
connection,
|
connection,
|
||||||
TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS,
|
TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS,
|
||||||
|
@ -161,7 +161,3 @@ END $$;
|
|||||||
|
|
||||||
COMMENT ON FUNCTION exchange_do_reserve_purse(BYTEA, BYTEA, INT8, INT8, INT8, BYTEA, BOOLEAN, INT8, INT4, BYTEA, BYTEA)
|
COMMENT ON FUNCTION exchange_do_reserve_purse(BYTEA, BYTEA, INT8, INT8, INT8, BYTEA, BOOLEAN, INT8, INT4, BYTEA, BYTEA)
|
||||||
IS 'Create a purse for a reserve.';
|
IS 'Create a purse for a reserve.';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -797,14 +797,14 @@ TEH_PG_get_reserve_history (void *cls,
|
|||||||
" FROM purse_merges pm"
|
" FROM purse_merges pm"
|
||||||
" JOIN purse_requests pr"
|
" JOIN purse_requests pr"
|
||||||
" USING (purse_pub)"
|
" USING (purse_pub)"
|
||||||
" JOIN purse_decision pdes"
|
" LEFT JOIN purse_decision pdes"
|
||||||
" USING (purse_pub)"
|
" USING (purse_pub)"
|
||||||
" JOIN account_merges am"
|
" JOIN account_merges am"
|
||||||
" ON (am.purse_pub = pm.purse_pub AND"
|
" ON (am.purse_pub = pm.purse_pub AND"
|
||||||
" am.reserve_pub = pm.reserve_pub)"
|
" am.reserve_pub = pm.reserve_pub)"
|
||||||
" WHERE pm.reserve_pub=$1"
|
" WHERE pm.reserve_pub=$1"
|
||||||
" AND COALESCE(pm.partner_serial_id,0)=0" /* must be local! */
|
" AND COALESCE(pm.partner_serial_id,0)=0" /* must be local! */
|
||||||
" AND NOT pdes.refunded;");
|
" AND NOT COALESCE (pdes.refunded, FALSE);");
|
||||||
PREPARE (pg,
|
PREPARE (pg,
|
||||||
"history_by_reserve",
|
"history_by_reserve",
|
||||||
"SELECT"
|
"SELECT"
|
||||||
@ -855,7 +855,12 @@ TEH_PG_get_reserve_history (void *cls,
|
|||||||
&rhc);
|
&rhc);
|
||||||
if ( (0 > qs) ||
|
if ( (0 > qs) ||
|
||||||
(GNUNET_OK != rhc.status) )
|
(GNUNET_OK != rhc.status) )
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
|
"Failed to compile reserve history at `%s'\n",
|
||||||
|
work[i].statement);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( (qs < 0) ||
|
if ( (qs < 0) ||
|
||||||
(rhc.status != GNUNET_OK) )
|
(rhc.status != GNUNET_OK) )
|
||||||
|
Loading…
Reference in New Issue
Block a user