From b6c0f0a29f13abe7a0e58c3eb8f69f654849d399 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 10 Jun 2015 10:59:04 +0200 Subject: typo --- src/mintdb/plugin_mintdb_postgres.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 710241d7a..e611437e4 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -723,7 +723,7 @@ postgres_prepare (PGconn *db_conn) during /deposit processing. Used in #postgres_have_deposit(). */ PREPARE ("get_deposit", "SELECT" - ",denom_pub" /* Note: not actually used (yet), #3819 */ + " denom_pub" /* Note: not actually used (yet), #3819 */ ",amount_with_fee_val" /* Note: not actually used (yet), #3819 */ ",amount_with_fee_frac" /* Note: not actually used (yet), #3819 */ ",amount_with_fee_curr" /* Note: not actually used (yet), #3819 */ -- cgit v1.2.3 From 84c21460b61217ec89ecbdc913d2a083ed255cbe Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 10 Jun 2015 11:14:05 +0200 Subject: links to bug reports, use TALER_refresh_link_encrypted_encode where appropriate when generating data to insert --- src/mintdb/plugin_mintdb_postgres.c | 81 ++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 33 deletions(-) diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index e611437e4..31dc91a4f 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -2053,8 +2053,8 @@ postgres_insert_refresh_order (void *cls, uint16_t num_newcoins, const struct TALER_DenominationPublicKey *denom_pubs) { - // FIXME: check logic: was written for just one COIN! - uint16_t newcoin_index_nbo = htons (num_newcoins); + // FIXME: check logic: was written for just one COIN! (#3830) + uint16_t newcoin_index_nbo = htons (num_newcoins); // FIXME: #3827 PGresult *result; { @@ -2103,8 +2103,8 @@ postgres_get_refresh_order (void *cls, uint16_t num_newcoins, struct TALER_DenominationPublicKey *denom_pubs) { - // FIXME: check logic -- was written for just one coin! - uint16_t newcoin_index_nbo = htons (num_newcoins); + // FIXME: check logic -- was written for just one coin! (#3830) + uint16_t newcoin_index_nbo = htons (num_newcoins); // FIXME: #3827 struct TALER_PQ_QueryParam params[] = { TALER_PQ_query_param_auto_from_type (session_hash), @@ -2166,37 +2166,48 @@ postgres_insert_refresh_commit_coins (void *cls, unsigned int num_newcoins, const struct TALER_MINTDB_RefreshCommitCoin *commit_coins) { - // FIXME: check logic! -- was written for single commit_coin! - uint16_t cnc_index_nbo = htons (i); - uint16_t newcoin_index_nbo = htons (num_newcoins); - struct TALER_PQ_QueryParam params[] = { - TALER_PQ_query_param_auto_from_type(session_hash), - TALER_PQ_query_param_auto_from_type(&cnc_index_nbo), - TALER_PQ_query_param_auto_from_type(&newcoin_index_nbo), - TALER_PQ_query_param_fixed_size (commit_coins->refresh_link->coin_priv_enc, - commit_coins->refresh_link->blinding_key_enc_size + - sizeof (struct TALER_CoinSpendPrivateKeyP)), - TALER_PQ_query_param_fixed_size(commit_coins->coin_ev, commit_coins->coin_ev_size), - TALER_PQ_query_param_end - }; + // FIXME: check logic! -- was written for single commit_coin! // #3831 + uint16_t cnc_index_nbo = htons (i); // #3827 + uint16_t newcoin_index_nbo = htons (num_newcoins); // #3827 + char *rle; + size_t rle_size; + PGresult *result; - PGresult *result = TALER_PQ_exec_prepared (session->conn, - "insert_refresh_commit_coin", - params); + rle = TALER_refresh_link_encrypted_encode (commit_coins->refresh_link, + &rle_size); + if (NULL == rle) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + { + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_query_param_auto_from_type (session_hash), + TALER_PQ_query_param_auto_from_type (&cnc_index_nbo), + TALER_PQ_query_param_auto_from_type (&newcoin_index_nbo), + TALER_PQ_query_param_fixed_size (rle, rle_size), + TALER_PQ_query_param_fixed_size (commit_coins->coin_ev, + commit_coins->coin_ev_size), + TALER_PQ_query_param_end + }; + result = TALER_PQ_exec_prepared (session->conn, + "insert_refresh_commit_coin", + params); + } + GNUNET_free (rle); if (PGRES_COMMAND_OK != PQresultStatus (result)) { BREAK_DB_ERR (result); PQclear (result); return GNUNET_SYSERR; } - if (0 != strcmp ("1", PQcmdTuples (result))) { GNUNET_break (0); + PQclear (result); return GNUNET_SYSERR; } - PQclear (result); return GNUNET_OK; } @@ -2212,7 +2223,7 @@ postgres_insert_refresh_commit_coins (void *cls, * @param cnc_index set index (1st dimension) * @param newcoin_index coin index (2nd dimension), corresponds to refreshed (new) coins * @param[out] cc coin commitment to return - * FIXME: should we not take an array of 'cc's and return all at once? + * FIXME: should we not take an array of 'cc's and return all at once? // #3831 * @return #GNUNET_OK on success * #GNUNET_NO if not found * #GNUNET_SYSERR on error @@ -2225,9 +2236,9 @@ postgres_get_refresh_commit_coins (void *cls, unsigned int newcoin_index, struct TALER_MINTDB_RefreshCommitCoin *cc) { - // FIXME: check logic! - uint16_t cnc_index_nbo = htons (cnc_index); - uint16_t newcoin_index_nbo = htons (newcoin_index); + // FIXME: check logic! // #3831 + uint16_t cnc_index_nbo = htons (cnc_index); // #3827 + uint16_t newcoin_index_nbo = htons (newcoin_index); // #3827 struct TALER_PQ_QueryParam params[] = { TALER_PQ_query_param_auto_from_type(session_hash), TALER_PQ_query_param_auto_from_type(&cnc_index_nbo), @@ -2258,8 +2269,12 @@ postgres_get_refresh_commit_coins (void *cls, } struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_result_spec_variable_size("link_vector_enc", &rl_buf, &rl_buf_size), - TALER_PQ_result_spec_variable_size("coin_ev", &c_buf, &c_buf_size), + TALER_PQ_result_spec_variable_size ("link_vector_enc", + &rl_buf, + &rl_buf_size), + TALER_PQ_result_spec_variable_size ("coin_ev", + &c_buf, + &c_buf_size), TALER_PQ_result_spec_end }; if (GNUNET_YES != TALER_PQ_extract_result (result, rs, 0)) @@ -2306,8 +2321,8 @@ postgres_insert_refresh_commit_links (void *cls, const struct TALER_MINTDB_RefreshCommitLinkP *commit_link) { // FIXME: check logic! - uint16_t cnc_index_nbo = htons (i); - uint16_t oldcoin_index_nbo = htons (j); + uint16_t cnc_index_nbo = htons (i); // #3827 + uint16_t oldcoin_index_nbo = htons (j); // #3827 struct TALER_PQ_QueryParam params[] = { TALER_PQ_query_param_auto_from_type(session_hash), TALER_PQ_query_param_auto_from_type(&commit_link->transfer_pub), @@ -2361,8 +2376,8 @@ postgres_get_refresh_commit_links (void *cls, struct TALER_MINTDB_RefreshCommitLinkP *links) { // FIXME: check logic: was written for a single link! - uint16_t cnc_index_nbo = htons (i); - uint16_t oldcoin_index_nbo = htons (num_links); + uint16_t cnc_index_nbo = htons (i); // #3827 + uint16_t oldcoin_index_nbo = htons (num_links); // #3827 struct TALER_PQ_QueryParam params[] = { TALER_PQ_query_param_auto_from_type(session_hash), @@ -2471,7 +2486,7 @@ postgres_insert_refresh_collectable (void *cls, const struct TALER_DenominationSignature *ev_sig) { // FIXME: check logic! - uint16_t newcoin_index_nbo = htons (newcoin_index); + uint16_t newcoin_index_nbo = htons (newcoin_index); // #3827 PGresult *result; { -- cgit v1.2.3 From 29a8047d6fd7baa083a47bde4aa40c264c8fbb7f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 10 Jun 2015 11:34:21 +0200 Subject: use better names than i/j --- src/include/taler_mintdb_plugin.h | 16 +++++++-------- src/mintdb/plugin_mintdb_postgres.c | 39 ++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index f6fa27dbb..acdb0d2f5 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -985,7 +985,7 @@ struct TALER_MINTDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param sesssion database connection to use * @param session_hash hash to identify refresh session - * @param i set index (1st dimension), relating to #TALER_CNC_KAPPA + * @param cnc_index cut and choose index (1st dimension), relating to #TALER_CNC_KAPPA * @param num_newcoins coin index size of the @a commit_coins array * @param commit_coin array of coin commitments to store * @return #GNUNET_OK on success @@ -995,7 +995,7 @@ struct TALER_MINTDB_Plugin (*insert_refresh_commit_coins) (void *cls, struct TALER_MINTDB_Session *sesssion, const struct GNUNET_HashCode *session_hash, - unsigned int i, + unsigned int cnc_index, unsigned int num_newcoins, const struct TALER_MINTDB_RefreshCommitCoin *commit_coins); @@ -1007,7 +1007,7 @@ struct TALER_MINTDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param sesssion database connection to use * @param session_hash hash to identify refresh session - * @param i set index (1st dimension) + * @param cnc_index cut and choose set index (1st dimension) * @param num_coins size of the @a commit_coins array * @param[out] commit_coin array of coin commitments to return * @return #GNUNET_OK on success @@ -1018,7 +1018,7 @@ struct TALER_MINTDB_Plugin (*get_refresh_commit_coins) (void *cls, struct TALER_MINTDB_Session *sesssion, const struct GNUNET_HashCode *session_hash, - unsigned int i, + unsigned int cnc_index, unsigned int num_coins, struct TALER_MINTDB_RefreshCommitCoin *commit_coins); @@ -1030,7 +1030,7 @@ struct TALER_MINTDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param sesssion database connection to use * @param session_hash hash to identify refresh session - * @param i set index (1st dimension), relating to #TALER_CNC_KAPPA + * @param cnc_index cut and choose index (1st dimension), relating to #TALER_CNC_KAPPA * @param num_links size of the @a commit_link array * @param commit_links array of link information to store * @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success @@ -1039,7 +1039,7 @@ struct TALER_MINTDB_Plugin (*insert_refresh_commit_links) (void *cls, struct TALER_MINTDB_Session *sesssion, const struct GNUNET_HashCode *session_hash, - unsigned int i, + unsigned int cnc_index, unsigned int num_links, const struct TALER_MINTDB_RefreshCommitLinkP *commit_links); @@ -1050,7 +1050,7 @@ struct TALER_MINTDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param sesssion database connection to use * @param session_hash hash to identify refresh session - * @param i set index (1st dimension) + * @param cnc_index cut and choose index (1st dimension) * @param num_links size of the @a links array to return * @param[out] links array link information to return * @return #GNUNET_SYSERR on internal error, @@ -1061,7 +1061,7 @@ struct TALER_MINTDB_Plugin (*get_refresh_commit_links) (void *cls, struct TALER_MINTDB_Session *sesssion, const struct GNUNET_HashCode *session_hash, - unsigned int i, + unsigned int cnc_index, unsigned int num_links, struct TALER_MINTDB_RefreshCommitLinkP *links); diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 31dc91a4f..6472e1fbe 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -2152,7 +2152,7 @@ postgres_get_refresh_order (void *cls, * @param cls the `struct PostgresClosure` with the plugin-specific state * @param session database connection to use * @param session_hash hash to identify refresh session - * @param i set index (1st dimension) + * @param cnc_index cut and choose index (1st dimension) * @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 @@ -2162,12 +2162,12 @@ static int postgres_insert_refresh_commit_coins (void *cls, struct TALER_MINTDB_Session *session, const struct GNUNET_HashCode *session_hash, - unsigned int i, + unsigned int cnc_index, unsigned int num_newcoins, const struct TALER_MINTDB_RefreshCommitCoin *commit_coins) { // FIXME: check logic! -- was written for single commit_coin! // #3831 - uint16_t cnc_index_nbo = htons (i); // #3827 + uint16_t cnc_index_nbo = htons (cnc_index); // #3827 uint16_t newcoin_index_nbo = htons (num_newcoins); // #3827 char *rle; size_t rle_size; @@ -2306,29 +2306,28 @@ postgres_get_refresh_commit_coins (void *cls, * @param cls the `struct PostgresClosure` with the plugin-specific state * @param session database connection to use * @param session_hash hash to identify refresh session - * FIXME: i/j -- better names, please! - * @param i set index (1st dimension) - * @param j coin index (2nd dimension), corresponds to melted (old) coins - * @param commit_link link information to store + * @param cnc_index cut and choose index (1st dimension) + * @param num_links size of the @a links array to return + * @param[out] links array of link information to store return * @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success */ static int postgres_insert_refresh_commit_links (void *cls, struct TALER_MINTDB_Session *session, const struct GNUNET_HashCode *session_hash, - unsigned int i, - unsigned int j, - const struct TALER_MINTDB_RefreshCommitLinkP *commit_link) + unsigned int cnc_index, + unsigned int num_links, + const struct TALER_MINTDB_RefreshCommitLinkP *links) { // FIXME: check logic! - uint16_t cnc_index_nbo = htons (i); // #3827 - uint16_t oldcoin_index_nbo = htons (j); // #3827 + uint16_t cnc_index_nbo = htons (cnc_index); // #3827 + uint16_t oldcoin_index_nbo = htons (num_links); // #3827 struct TALER_PQ_QueryParam params[] = { - TALER_PQ_query_param_auto_from_type(session_hash), - TALER_PQ_query_param_auto_from_type(&commit_link->transfer_pub), - TALER_PQ_query_param_auto_from_type(&cnc_index_nbo), - TALER_PQ_query_param_auto_from_type(&oldcoin_index_nbo), - TALER_PQ_query_param_auto_from_type(&commit_link->shared_secret_enc), + TALER_PQ_query_param_auto_from_type (session_hash), + TALER_PQ_query_param_auto_from_type (&links->transfer_pub), + TALER_PQ_query_param_auto_from_type (&cnc_index_nbo), + TALER_PQ_query_param_auto_from_type (&oldcoin_index_nbo), + TALER_PQ_query_param_auto_from_type (&links->shared_secret_enc), TALER_PQ_query_param_end }; @@ -2360,7 +2359,7 @@ postgres_insert_refresh_commit_links (void *cls, * @param cls the `struct PostgresClosure` with the plugin-specific state * @param session database connection to use * @param session_hash hash to identify refresh session - * @param i set index (1st dimension) + * @param cnc_index cut and choose index (1st dimension) * @param num_links size of the @a commit_link array * @param[out] links array of link information to return * @return #GNUNET_SYSERR on internal error, @@ -2371,12 +2370,12 @@ static int postgres_get_refresh_commit_links (void *cls, struct TALER_MINTDB_Session *session, const struct GNUNET_HashCode *session_hash, - unsigned int i, + unsigned int cnc_index, unsigned int num_links, struct TALER_MINTDB_RefreshCommitLinkP *links) { // FIXME: check logic: was written for a single link! - uint16_t cnc_index_nbo = htons (i); // #3827 + uint16_t cnc_index_nbo = htons (cnc_index); // #3827 uint16_t oldcoin_index_nbo = htons (num_links); // #3827 struct TALER_PQ_QueryParam params[] = { -- cgit v1.2.3