Merge branch 'master' of taler.net:/var/git/mint

This commit is contained in:
Fournier Nicolas 2015-06-10 14:59:21 +02:00
commit ccc57fed01
2 changed files with 72 additions and 58 deletions

View File

@ -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);

View File

@ -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 */
@ -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),
@ -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,41 +2162,52 @@ 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!
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 (cnc_index); // #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))
@ -2291,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);
uint16_t oldcoin_index_nbo = htons (j);
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
};
@ -2345,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,
@ -2356,13 +2370,13 @@ 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);
uint16_t oldcoin_index_nbo = htons (num_links);
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),
@ -2471,7 +2485,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;
{