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