From fbff951e7d0a8965c44e37716067d5ddc13c975a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 22 Jun 2017 11:49:40 +0200 Subject: address #5010 for /refresh/melt --- src/exchangedb/perf_taler_exchangedb_interpreter.c | 34 ++++++----- src/exchangedb/plugin_exchangedb_postgres.c | 70 ++++++++++------------ src/exchangedb/test_exchangedb.c | 6 +- 3 files changed, 52 insertions(+), 58 deletions(-) (limited to 'src/exchangedb') diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c index 3f52e90e2..7a5915807 100644 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.c +++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c @@ -1553,10 +1553,11 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) refresh_session = PERF_TALER_EXCHANGEDB_refresh_session_init (); GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, hash); - state->plugin->create_refresh_session (state->session, - state->session, - hash, - refresh_session); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + state->plugin->create_refresh_session (state->session, + state->session, + hash, + refresh_session)); state->cmd[state->i].exposed.data.session_hash = hash; PERF_TALER_EXCHANGEDB_refresh_session_free (refresh_session); GNUNET_free (refresh_session); @@ -1589,11 +1590,12 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) denom_index = state->cmd[state->i].details.insert_refresh_order.index_denom; session_hash = state->cmd[hash_index].exposed.data.session_hash; denom = state->cmd[denom_index].exposed.data.dki; - state->plugin->insert_refresh_order (state->plugin->cls, - state->session, - session_hash, - 1, - &denom->denom_pub); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + state->plugin->insert_refresh_order (state->plugin->cls, + state->session, + session_hash, + 1, + &denom->denom_pub)); } break; @@ -1616,18 +1618,18 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) case PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_COMMIT_COIN: { - int ret; + enum GNUNET_DB_QueryStatus qs; unsigned int hash_index; struct TALER_EXCHANGEDB_RefreshCommitCoin *refresh_commit; hash_index = state->cmd[state->i].details.insert_refresh_commit_coin.index_hash; refresh_commit = PERF_TALER_EXCHANGEDB_refresh_commit_coin_init (); - ret = state->plugin->insert_refresh_commit_coins (state->plugin->cls, - state->session, - state->cmd[hash_index].exposed.data.session_hash, - 1, - refresh_commit); - GNUNET_assert (GNUNET_OK == ret); + qs = state->plugin->insert_refresh_commit_coins (state->plugin->cls, + state->session, + state->cmd[hash_index].exposed.data.session_hash, + 1, + refresh_commit); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); } break; diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 592751f66..9df7fc4f3 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -3344,11 +3344,9 @@ postgres_get_refresh_session (void *cls, * @param session database handle to use * @param session_hash hash over the melt to use to locate the session * @param refresh_session session data to store - * @return #GNUNET_YES on success, - * #GNUNET_NO on transient error - * #GNUNET_SYSERR on DB failure + * @return query status for the transaction */ -static int +static enum GNUNET_DB_QueryStatus postgres_create_refresh_session (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, @@ -3366,7 +3364,7 @@ postgres_create_refresh_session (void *cls, int ret; enum GNUNET_DB_QueryStatus qs; - /* check if the coin is already known */ + /* check if the coin is already known (FIXME: #5010) */ ret = get_known_coin (cls, session, &refresh_session->melt.coin.coin_pub, @@ -3384,13 +3382,13 @@ postgres_create_refresh_session (void *cls, if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - return GNUNET_SYSERR; + return qs; } } - - return execute_prepared_non_select (session, - "insert_refresh_session", - params); + + return GNUNET_PQ_eval_prepared_non_select (session->conn, + "insert_refresh_session", + params); } @@ -3403,11 +3401,9 @@ postgres_create_refresh_session (void *cls, * @param session_hash hash to identify refresh session * @param num_newcoins number of coins to generate, size of the @a denom_pubs array * @param denom_pubs array denominations of the coins to create - * @return #GNUNET_OK on success - * #GNUNET_NO on transient error - * #GNUNET_SYSERR on internal error + * @return query status for the transaction */ -static int +static enum GNUNET_DB_QueryStatus postgres_insert_refresh_order (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, @@ -3426,18 +3422,18 @@ postgres_insert_refresh_order (void *cls, GNUNET_PQ_query_param_auto_from_type (&denom_pub_hash), GNUNET_PQ_query_param_end }; - int ret; + enum GNUNET_DB_QueryStatus qs; GNUNET_CRYPTO_rsa_public_key_hash (denom_pubs[i].rsa_public_key, &denom_pub_hash); - ret = execute_prepared_non_select (session, - "insert_refresh_order", - params); - if (GNUNET_OK != ret) - return ret; + qs = GNUNET_PQ_eval_prepared_non_select (session->conn, + "insert_refresh_order", + params); + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) + return qs; } } - return GNUNET_OK; + return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } @@ -3524,11 +3520,9 @@ postgres_get_refresh_order (void *cls, * @param session_hash hash to identify refresh session * @param num_newcoins coin index size of the @a commit_coins array * @param commit_coins array of coin commitments to store - * @return #GNUNET_OK on success - * #GNUNET_NO on transient error - * #GNUNET_SYSERR on error + * @return query transaction status */ -static int +static enum GNUNET_DB_QueryStatus postgres_insert_refresh_commit_coins (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, @@ -3544,15 +3538,15 @@ postgres_insert_refresh_commit_coins (void *cls, commit_coins[coin_off].coin_ev_size), GNUNET_PQ_query_param_end }; - int ret; + enum GNUNET_DB_QueryStatus qs; - ret = execute_prepared_non_select (session, - "insert_refresh_commit_coin", - params); - if (GNUNET_OK != ret) - return ret; + qs = GNUNET_PQ_eval_prepared_non_select (session->conn, + "insert_refresh_commit_coin", + params); + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) + return qs; } - return GNUNET_OK; + return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } @@ -3640,11 +3634,9 @@ postgres_get_refresh_commit_coins (void *cls, * @param session database connection to use * @param session_hash hash to identify refresh session * @param tp transfer public key to store - * @return #GNUNET_SYSERR on internal error, - * #GNUNET_NO on transient errors - * #GNUNET_OK on success + * @return transaction status */ -static int +static enum GNUNET_DB_QueryStatus postgres_insert_refresh_transfer_public_key (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, @@ -3656,9 +3648,9 @@ postgres_insert_refresh_transfer_public_key (void *cls, GNUNET_PQ_query_param_end }; - return execute_prepared_non_select (session, - "insert_transfer_public_key", - params); + return GNUNET_PQ_eval_prepared_non_select (session->conn, + "insert_transfer_public_key", + params); } diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 673d51446..1b3797dd3 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -349,7 +349,7 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session, ccoin->coin_ev, ccoin->coin_ev_size); } - FAILIF (GNUNET_OK != + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_refresh_commit_coins (plugin->cls, session, session_hash, @@ -417,7 +417,7 @@ test_refresh_commit_links (struct TALER_EXCHANGEDB_Session *session, &tp)); for (i=0;iinsert_refresh_transfer_public_key (plugin->cls, session, session_hash, @@ -572,7 +572,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) meltp->melt_fee = fee_refresh; } - FAILIF (GNUNET_OK != + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->create_refresh_session (plugin->cls, session, &session_hash, -- cgit v1.2.3