convert another function for #5010
This commit is contained in:
parent
d66a29e383
commit
d2c7ef54a7
@ -228,6 +228,8 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection,
|
||||
struct TEH_KS_StateHandle *mks;
|
||||
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
|
||||
int ret;
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
unsigned int retries = 0;
|
||||
|
||||
if (NULL == (session = TEH_plugin->get_session (TEH_plugin->cls)))
|
||||
{
|
||||
@ -235,6 +237,7 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection,
|
||||
return TEH_RESPONSE_reply_internal_db_error (connection,
|
||||
TALER_EC_DB_SETUP_FAILED);
|
||||
}
|
||||
again:
|
||||
if (GNUNET_YES ==
|
||||
TEH_plugin->have_deposit (TEH_plugin->cls,
|
||||
session,
|
||||
@ -305,10 +308,10 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection,
|
||||
}
|
||||
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
||||
tl);
|
||||
if (GNUNET_OK !=
|
||||
TEH_plugin->insert_deposit (TEH_plugin->cls,
|
||||
session,
|
||||
deposit))
|
||||
qs = TEH_plugin->insert_deposit (TEH_plugin->cls,
|
||||
session,
|
||||
deposit);
|
||||
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
||||
{
|
||||
TALER_LOG_WARNING ("Failed to store /deposit information in database\n");
|
||||
TEH_plugin->rollback (TEH_plugin->cls,
|
||||
@ -316,6 +319,16 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection,
|
||||
return TEH_RESPONSE_reply_internal_db_error (connection,
|
||||
TALER_EC_DEPOSIT_STORE_DB_ERROR);
|
||||
}
|
||||
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
|
||||
{
|
||||
retries++;
|
||||
TEH_plugin->rollback (TEH_plugin->cls,
|
||||
session);
|
||||
if (retries > 5)
|
||||
return TEH_RESPONSE_reply_internal_db_error (connection,
|
||||
TALER_EC_DEPOSIT_STORE_DB_ERROR);
|
||||
goto again;
|
||||
}
|
||||
|
||||
COMMIT_TRANSACTION(session, connection);
|
||||
GNUNET_assert (GNUNET_SYSERR !=
|
||||
|
@ -1334,15 +1334,15 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
|
||||
case PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT:
|
||||
{
|
||||
int deposit_index;
|
||||
int ret;
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
struct TALER_EXCHANGEDB_Deposit *deposit;
|
||||
|
||||
deposit_index = state->cmd[state->i].details.insert_deposit.index_deposit;
|
||||
deposit = state->cmd[deposit_index].exposed.data.deposit;
|
||||
ret = state->plugin->insert_deposit (state->plugin->cls,
|
||||
qs = state->plugin->insert_deposit (state->plugin->cls,
|
||||
state->session,
|
||||
deposit);
|
||||
GNUNET_assert (GNUNET_SYSERR != ret);
|
||||
GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
|
||||
state->cmd[state->i].exposed.data.deposit = deposit;
|
||||
}
|
||||
break;
|
||||
|
@ -3181,11 +3181,9 @@ get_known_coin (void *cls,
|
||||
* @param cls plugin closure
|
||||
* @param session the shared database session
|
||||
* @param coin_info the public coin info
|
||||
* @return #GNUNET_SYSERR upon error;
|
||||
* #GNUNET_NO on transient error
|
||||
* #GNUNET_OK upon success
|
||||
* @return query result status
|
||||
*/
|
||||
static int
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
insert_known_coin (void *cls,
|
||||
struct TALER_EXCHANGEDB_Session *session,
|
||||
const struct TALER_CoinPublicInfo *coin_info)
|
||||
@ -3200,9 +3198,9 @@ insert_known_coin (void *cls,
|
||||
|
||||
GNUNET_CRYPTO_rsa_public_key_hash (coin_info->denom_pub.rsa_public_key,
|
||||
&denom_pub_hash);
|
||||
return execute_prepared_non_select (session,
|
||||
"insert_known_coin",
|
||||
params);
|
||||
return GNUNET_PQ_eval_prepared_non_select (session->conn,
|
||||
"insert_known_coin",
|
||||
params);
|
||||
}
|
||||
|
||||
|
||||
@ -3212,16 +3210,15 @@ insert_known_coin (void *cls,
|
||||
* @param cls the `struct PostgresClosure` with the plugin-specific state
|
||||
* @param session connection to the database
|
||||
* @param deposit deposit information to store
|
||||
* @return #GNUNET_OK on success,
|
||||
* #GNUNET_NO on transient error
|
||||
* #GNUNET_SYSERR on error
|
||||
* @return query result status
|
||||
*/
|
||||
static int
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
postgres_insert_deposit (void *cls,
|
||||
struct TALER_EXCHANGEDB_Session *session,
|
||||
const struct TALER_EXCHANGEDB_Deposit *deposit)
|
||||
{
|
||||
int ret;
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (&deposit->coin.coin_pub),
|
||||
TALER_PQ_query_param_amount (&deposit->amount_with_fee),
|
||||
@ -3248,19 +3245,19 @@ postgres_insert_deposit (void *cls,
|
||||
}
|
||||
if (GNUNET_NO == ret) /* if not, insert it */
|
||||
{
|
||||
if (GNUNET_OK !=
|
||||
(ret = insert_known_coin (cls,
|
||||
session,
|
||||
&deposit->coin)))
|
||||
qs = insert_known_coin (cls,
|
||||
session,
|
||||
&deposit->coin);
|
||||
if (0 > qs)
|
||||
{
|
||||
GNUNET_break (GNUNET_NO == ret);
|
||||
return ret;
|
||||
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
|
||||
return qs;
|
||||
}
|
||||
}
|
||||
|
||||
return execute_prepared_non_select (session,
|
||||
"insert_deposit",
|
||||
params);
|
||||
return GNUNET_PQ_eval_prepared_non_select (session->conn,
|
||||
"insert_deposit",
|
||||
params);
|
||||
}
|
||||
|
||||
|
||||
@ -3416,6 +3413,7 @@ postgres_create_refresh_session (void *cls,
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
int ret;
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
|
||||
/* check if the coin is already known */
|
||||
ret = get_known_coin (cls,
|
||||
@ -3429,12 +3427,12 @@ postgres_create_refresh_session (void *cls,
|
||||
}
|
||||
if (GNUNET_NO == ret) /* if not, insert it */
|
||||
{
|
||||
if (GNUNET_OK !=
|
||||
(ret = insert_known_coin (cls,
|
||||
session,
|
||||
&refresh_session->melt.coin)))
|
||||
qs = insert_known_coin (cls,
|
||||
session,
|
||||
&refresh_session->melt.coin);
|
||||
if (0 > qs)
|
||||
{
|
||||
GNUNET_break (GNUNET_NO == ret);
|
||||
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
}
|
||||
@ -6155,12 +6153,12 @@ postgres_insert_payback_request (void *cls,
|
||||
}
|
||||
if (GNUNET_NO == ret) /* if not, insert it */
|
||||
{
|
||||
if (GNUNET_OK !=
|
||||
(ret = insert_known_coin (cls,
|
||||
session,
|
||||
coin)))
|
||||
qs = insert_known_coin (cls,
|
||||
session,
|
||||
coin);
|
||||
if (0 > qs)
|
||||
{
|
||||
GNUNET_break (GNUNET_NO == ret);
|
||||
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -1768,7 +1768,7 @@ run (void *cls)
|
||||
deposit.amount_with_fee = value;
|
||||
deposit.deposit_fee = fee_deposit;
|
||||
result = 8;
|
||||
FAILIF (GNUNET_OK !=
|
||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||
plugin->insert_deposit (plugin->cls,
|
||||
session,
|
||||
&deposit));
|
||||
|
@ -1309,11 +1309,9 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to the database
|
||||
* @param deposit deposit information to store
|
||||
* @return #GNUNET_OK on success,
|
||||
* #GNUNET_NO on transient error
|
||||
* #GNUNET_SYSERR on error
|
||||
* @return query result status
|
||||
*/
|
||||
int
|
||||
enum GNUNET_DB_QueryStatus
|
||||
(*insert_deposit) (void *cls,
|
||||
struct TALER_EXCHANGEDB_Session *session,
|
||||
const struct TALER_EXCHANGEDB_Deposit *deposit);
|
||||
@ -1375,11 +1373,9 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to the database
|
||||
* @param deposit_rowid identifies the deposit row to modify
|
||||
* @return #GNUNET_OK on success,
|
||||
* #GNUNET_NO on transient error
|
||||
* #GNUNET_SYSERR on error
|
||||
* @return query result status
|
||||
*/
|
||||
int
|
||||
enum GNUNET_DB_QueryStatus
|
||||
(*mark_deposit_done) (void *cls,
|
||||
struct TALER_EXCHANGEDB_Session *session,
|
||||
uint64_t rowid);
|
||||
|
Loading…
Reference in New Issue
Block a user