store and retrieve arrays from database where arrays are the unit of transaction, to reduce number of DB interactions

This commit is contained in:
Christian Grothoff 2015-03-22 14:21:16 +01:00
parent 3a94a76aac
commit 81e234e723
4 changed files with 233 additions and 221 deletions

View File

@ -1637,8 +1637,8 @@ postgres_get_refresh_melt (void *cls,
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection
* @param session_pub refresh session key
* @param newcoin_index index of the coin to generate
* @param denom_pub denomination of the coin to create
* @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_SYSERR on internal error
*/
@ -1646,16 +1646,16 @@ static int
postgres_insert_refresh_order (void *cls,
struct TALER_MINTDB_Session *session,
const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub,
uint16_t newcoin_index,
const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub)
uint16_t num_newcoins,
struct GNUNET_CRYPTO_rsa_PublicKey *const*denom_pubs)
{
// FIXME: check logic
uint16_t newcoin_index_nbo = htons (newcoin_index);
// FIXME: check logic: was written for just one COIN!
uint16_t newcoin_index_nbo = htons (num_newcoins);
char *buf;
size_t buf_size;
PGresult *result;
buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pub,
buf_size = GNUNET_CRYPTO_rsa_public_key_encode (*denom_pubs,
&buf);
{
@ -1687,27 +1687,28 @@ postgres_insert_refresh_order (void *cls,
/**
* Lookup in the database the @a newcoin_index coin that we want to
* Lookup in the database the coins that we want to
* create in the given refresh operation.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database connection
* @param session_pub refresh session key
* @param newcoin_index index of the coin to generate
* @param denom_pub denomination of the coin to create
* @return NULL on error (not found or internal error)
* @param newcoin_index array of the @a denom_pubs array
* @param denom_pubs where to store the deomination keys
* @return #GNUNET_OK on success
* #GNUNET_SYSERR on internal error
*/
static struct GNUNET_CRYPTO_rsa_PublicKey *
static int
postgres_get_refresh_order (void *cls,
struct TALER_MINTDB_Session *session,
const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub,
uint16_t newcoin_index)
uint16_t num_newcoins,
struct GNUNET_CRYPTO_rsa_PublicKey **denom_pubs)
{
// FIXME: check logic
// FIXME: check logic -- was written for just one coin!
char *buf;
size_t buf_size;
struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub;
uint16_t newcoin_index_nbo = htons (newcoin_index);
uint16_t newcoin_index_nbo = htons (num_newcoins);
struct TALER_DB_QueryParam params[] = {
TALER_DB_QUERY_PARAM_PTR(session_pub),
@ -1715,20 +1716,21 @@ postgres_get_refresh_order (void *cls,
TALER_DB_QUERY_PARAM_END
};
PGresult *result = TALER_DB_exec_prepared (session->conn, "get_refresh_order", params);
PGresult *result = TALER_DB_exec_prepared (session->conn,
"get_refresh_order", params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
BREAK_DB_ERR (result);
PQclear (result);
return NULL;
return GNUNET_SYSERR;
}
if (0 == PQntuples (result))
{
PQclear (result);
/* FIXME: may want to distinguish between different error cases! */
return NULL;
return GNUNET_SYSERR;
}
GNUNET_assert (1 == PQntuples (result));
struct TALER_DB_ResultSpec rs[] = {
@ -1739,12 +1741,12 @@ postgres_get_refresh_order (void *cls,
{
PQclear (result);
GNUNET_break (0);
return NULL;
return GNUNET_SYSERR;
}
PQclear (result);
denom_pub = GNUNET_CRYPTO_rsa_public_key_decode (buf, buf_size);
denom_pubs[0] = GNUNET_CRYPTO_rsa_public_key_decode (buf, buf_size);
GNUNET_free (buf);
return denom_pub;
return GNUNET_OK;
}
@ -1757,34 +1759,36 @@ postgres_get_refresh_order (void *cls,
* @param session database connection to use
* @param refresh_session_pub refresh session this commitment belongs to
* @param i set index (1st dimension)
* @param j coin index (2nd dimension), corresponds to refreshed (new) coins
* @param commit_coin coin commitment to store
* @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_SYSERR on error
*/
static int
postgres_insert_refresh_commit_coin (void *cls,
postgres_insert_refresh_commit_coins (void *cls,
struct TALER_MINTDB_Session *session,
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
unsigned int i,
unsigned int j,
const struct RefreshCommitCoin *commit_coin)
unsigned int num_newcoins,
const struct RefreshCommitCoin *commit_coins)
{
// FIXME: check logic!
// FIXME: check logic! -- was written for single commit_coin!
uint16_t cnc_index_nbo = htons (i);
uint16_t newcoin_index_nbo = htons (j);
uint16_t newcoin_index_nbo = htons (num_newcoins);
struct TALER_DB_QueryParam params[] = {
TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coin->coin_ev, commit_coin->coin_ev_size),
TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coins->coin_ev, commit_coins->coin_ev_size),
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coin->refresh_link->coin_priv_enc,
commit_coin->refresh_link->blinding_key_enc_size +
TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coins->refresh_link->coin_priv_enc,
commit_coins->refresh_link->blinding_key_enc_size +
sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)),
TALER_DB_QUERY_PARAM_END
};
PGresult *result = TALER_DB_exec_prepared (session->conn, "insert_refresh_commit_coin", params);
PGresult *result = TALER_DB_exec_prepared (session->conn,
"insert_refresh_commit_coin",
params);
if (PGRES_COMMAND_OK != PQresultStatus (result))
{
@ -1819,7 +1823,7 @@ postgres_insert_refresh_commit_coin (void *cls,
* #GNUNET_SYSERR on error
*/
static int
postgres_get_refresh_commit_coin (void *cls,
postgres_get_refresh_commit_coins (void *cls,
struct TALER_MINTDB_Session *session,
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
unsigned int cnc_index,
@ -1841,7 +1845,9 @@ postgres_get_refresh_commit_coin (void *cls,
size_t rl_buf_size;
struct TALER_RefreshLinkEncrypted *rl;
PGresult *result = TALER_DB_exec_prepared (session->conn, "get_refresh_commit_coin", params);
PGresult *result = TALER_DB_exec_prepared (session->conn,
"get_refresh_commit_coin",
params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
@ -1897,7 +1903,7 @@ postgres_get_refresh_commit_coin (void *cls,
* @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success
*/
static int
postgres_insert_refresh_commit_link (void *cls,
postgres_insert_refresh_commit_links (void *cls,
struct TALER_MINTDB_Session *session,
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
unsigned int i,
@ -1946,23 +1952,23 @@ postgres_insert_refresh_commit_link (void *cls,
* @param refresh_session_pub public key of the refresh session this
* commitment belongs with
* @param i set index (1st dimension)
* @param j coin index (2nd dimension), corresponds to melted (old) coins
* @param cc[OUT] link information to return
* @param num_links size of the @a commit_link array
* @param links[OUT] array of link information to return
* @return #GNUNET_SYSERR on internal error,
* #GNUNET_NO if commitment was not found
* #GNUNET_OK on success
*/
static int
postgres_get_refresh_commit_link (void *cls,
postgres_get_refresh_commit_links (void *cls,
struct TALER_MINTDB_Session *session,
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
unsigned int cnc_index,
unsigned int oldcoin_index,
struct RefreshCommitLink *cc)
unsigned int i,
unsigned int num_links,
struct RefreshCommitLink *links)
{
// FIXME: check logic!
uint16_t cnc_index_nbo = htons (cnc_index);
uint16_t oldcoin_index_nbo = htons (oldcoin_index);
// FIXME: check logic: was written for a single link!
uint16_t cnc_index_nbo = htons (i);
uint16_t oldcoin_index_nbo = htons (num_links);
struct TALER_DB_QueryParam params[] = {
TALER_DB_QUERY_PARAM_PTR(refresh_session_pub),
@ -1988,15 +1994,14 @@ postgres_get_refresh_commit_link (void *cls,
}
struct TALER_DB_ResultSpec rs[] = {
TALER_DB_RESULT_SPEC("transfer_pub", &cc->transfer_pub),
TALER_DB_RESULT_SPEC("link_secret_enc", &cc->shared_secret_enc),
TALER_DB_RESULT_SPEC("transfer_pub", &links->transfer_pub),
TALER_DB_RESULT_SPEC("link_secret_enc", &links->shared_secret_enc),
TALER_DB_RESULT_SPEC_END
};
if (GNUNET_YES != TALER_DB_extract_result (result, rs, 0))
{
PQclear (result);
GNUNET_free (cc);
return GNUNET_SYSERR;
}
@ -2318,10 +2323,10 @@ libtaler_plugin_mintdb_postgres_init (void *cls)
plugin->get_refresh_melt = &postgres_get_refresh_melt;
plugin->insert_refresh_order = &postgres_insert_refresh_order;
plugin->get_refresh_order = &postgres_get_refresh_order;
plugin->insert_refresh_commit_coin = &postgres_insert_refresh_commit_coin;
plugin->get_refresh_commit_coin = &postgres_get_refresh_commit_coin;
plugin->insert_refresh_commit_link = &postgres_insert_refresh_commit_link;
plugin->get_refresh_commit_link = &postgres_get_refresh_commit_link;
plugin->insert_refresh_commit_coins = &postgres_insert_refresh_commit_coins;
plugin->get_refresh_commit_coins = &postgres_get_refresh_commit_coins;
plugin->insert_refresh_commit_links = &postgres_insert_refresh_commit_links;
plugin->get_refresh_commit_links = &postgres_get_refresh_commit_links;
plugin->insert_refresh_collectable = &postgres_insert_refresh_collectable;
plugin->get_link_data_list = &postgres_get_link_data_list;
plugin->free_link_data_list = &common_free_link_data_list;

View File

@ -609,7 +609,6 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
struct TALER_MINTDB_Session *session;
int res;
unsigned int i;
unsigned int j;
if (NULL == (session = plugin->get_session (plugin->cls,
GNUNET_NO)))
@ -667,57 +666,48 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
TALER_MINT_key_state_release (key_state);
/* store requested new denominations */
for (i=0;i<num_new_denoms;i++)
{
if (GNUNET_OK !=
plugin->insert_refresh_order (plugin->cls,
session,
refresh_session_pub,
i,
denom_pubs[i]))
num_new_denoms,
denom_pubs))
{
plugin->rollback (plugin->cls,
session);
return TALER_MINT_reply_internal_db_error (connection);
}
}
for (i = 0; i < kappa; i++)
{
for (j = 0; j < num_new_denoms; j++)
{
if (GNUNET_OK !=
plugin->insert_refresh_commit_coin (plugin->cls,
plugin->insert_refresh_commit_coins (plugin->cls,
session,
refresh_session_pub,
i,
j,
&commit_coin[i][j]))
num_new_denoms,
commit_coin[i]))
{
plugin->rollback (plugin->cls,
session);
return TALER_MINT_reply_internal_db_error (connection);
}
}
}
for (i = 0; i < kappa; i++)
{
for (j = 0; j < coin_count; j++)
{
if (GNUNET_OK !=
plugin->insert_refresh_commit_link (plugin->cls,
plugin->insert_refresh_commit_links (plugin->cls,
session,
refresh_session_pub,
i,
j,
&commit_link[i][j]))
coin_count,
commit_link[i]))
{
plugin->rollback (plugin->cls,
session);
return TALER_MINT_reply_internal_db_error (connection);
}
}
}
/* store 'global' session data */
@ -783,44 +773,48 @@ check_commitment (struct MHD_Connection *connection,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *transfer_privs,
const struct RefreshMelt *melts,
unsigned int num_newcoins,
struct GNUNET_CRYPTO_rsa_PublicKey *const*denom_pubs)
struct GNUNET_CRYPTO_rsa_PublicKey **denom_pubs)
{
unsigned int j;
int res;
struct TALER_LinkSecret last_shared_secret;
int secret_initialized = GNUNET_NO;
struct GNUNET_CRYPTO_EcdhePublicKey coin_ecdhe;
struct GNUNET_CRYPTO_EcdhePrivateKey transfer_ecdhe;
struct RefreshCommitLink *commit_links;
struct RefreshCommitCoin *commit_coins;
for (j = 0; j < num_oldcoins; j++)
{
struct RefreshCommitLink commit_link;
struct TALER_TransferSecret transfer_secret;
struct TALER_LinkSecret shared_secret;
struct GNUNET_CRYPTO_EcdsaPublicKey transfer_pub_check;
res = plugin->get_refresh_commit_link (plugin->cls,
commit_links = GNUNET_malloc (num_oldcoins *
sizeof (struct RefreshCommitLink));
if (GNUNET_OK !=
plugin->get_refresh_commit_links (plugin->cls,
session,
refresh_session,
off,
j,
&commit_link);
if (GNUNET_OK != res)
num_oldcoins,
commit_links))
{
GNUNET_break (0);
GNUNET_free (commit_links);
return (MHD_YES == TALER_MINT_reply_internal_db_error (connection))
? GNUNET_NO : GNUNET_SYSERR;
}
for (j = 0; j < num_oldcoins; j++)
{
struct TALER_TransferSecret transfer_secret;
struct TALER_LinkSecret shared_secret;
struct GNUNET_CRYPTO_EcdsaPublicKey transfer_pub_check;
GNUNET_CRYPTO_ecdsa_key_get_public (&transfer_privs[j],
&transfer_pub_check);
if (0 !=
memcmp (&transfer_pub_check,
&commit_link.transfer_pub,
&commit_links[j].transfer_pub,
sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"transfer keys do not match\n");
GNUNET_free (commit_links);
/* FIXME: return more specific error with original signature (#3712) */
return (MHD_YES ==
TALER_MINT_reply_refresh_reveal_missmatch (connection,
@ -843,17 +837,19 @@ check_commitment (struct MHD_Connection *connection,
{
GNUNET_break (0);
GNUNET_CRYPTO_ecdhe_key_clear (&transfer_ecdhe);
GNUNET_free (commit_links);
return (MHD_YES == TALER_MINT_reply_internal_error (connection,
"ECDH error"))
? GNUNET_NO : GNUNET_SYSERR;
}
GNUNET_CRYPTO_ecdhe_key_clear (&transfer_ecdhe);
if (GNUNET_OK !=
TALER_transfer_decrypt (&commit_link.shared_secret_enc,
TALER_transfer_decrypt (&commit_links[j].shared_secret_enc,
&transfer_secret,
&shared_secret))
{
GNUNET_break (0);
GNUNET_free (commit_links);
return (MHD_YES ==
TALER_MINT_reply_internal_error (connection,
"Decryption error"))
@ -871,6 +867,7 @@ check_commitment (struct MHD_Connection *connection,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"shared secrets do not match\n");
GNUNET_free (commit_links);
/* FIXME: return more specific error with original signature (#3712) */
return (MHD_YES ==
TALER_MINT_reply_refresh_reveal_missmatch (connection,
@ -881,36 +878,40 @@ check_commitment (struct MHD_Connection *connection,
}
}
GNUNET_break (GNUNET_YES == secret_initialized);
GNUNET_free (commit_links);
/* Check that the commitments for all new coins were correct */
commit_coins = GNUNET_malloc (num_newcoins *
sizeof (struct RefreshCommitCoin));
if (GNUNET_OK !=
plugin->get_refresh_commit_coins (plugin->cls,
session,
refresh_session,
off,
num_newcoins,
commit_coins))
{
GNUNET_break (0);
GNUNET_free (commit_coins);
return (MHD_YES == TALER_MINT_reply_internal_db_error (connection))
? GNUNET_NO : GNUNET_SYSERR;
}
for (j = 0; j < num_newcoins; j++)
{
struct RefreshCommitCoin commit_coin;
struct TALER_RefreshLinkDecrypted *link_data;
struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub;
struct GNUNET_HashCode h_msg;
char *buf;
size_t buf_len;
res = plugin->get_refresh_commit_coin (plugin->cls,
session,
refresh_session,
off,
j,
&commit_coin);
if (GNUNET_OK != res)
{
GNUNET_break (0);
return (MHD_YES == TALER_MINT_reply_internal_db_error (connection))
? GNUNET_NO : GNUNET_SYSERR;
}
link_data = TALER_refresh_decrypt (commit_coin.refresh_link,
link_data = TALER_refresh_decrypt (commit_coins[j].refresh_link,
&last_shared_secret);
if (NULL == link_data)
{
GNUNET_break (0);
GNUNET_free (commit_coins);
return (MHD_YES == TALER_MINT_reply_internal_error (connection,
"Decryption error"))
? GNUNET_NO : GNUNET_SYSERR;
@ -932,14 +933,15 @@ check_commitment (struct MHD_Connection *connection,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"blind failed\n");
GNUNET_free (commit_coins);
return (MHD_YES == TALER_MINT_reply_internal_error (connection,
"Blinding error"))
? GNUNET_NO : GNUNET_SYSERR;
}
if ( (buf_len != commit_coin.coin_ev_size) ||
if ( (buf_len != commit_coins[j].coin_ev_size) ||
(0 != memcmp (buf,
commit_coin.coin_ev,
commit_coins[j].coin_ev,
buf_len)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@ -947,6 +949,7 @@ check_commitment (struct MHD_Connection *connection,
off,
(int) j);
/* FIXME: return more specific error with original signature (#3712) */
GNUNET_free (commit_coins);
return (MHD_YES ==
TALER_MINT_reply_refresh_reveal_missmatch (connection,
off,
@ -956,6 +959,7 @@ check_commitment (struct MHD_Connection *connection,
}
GNUNET_free (buf);
}
GNUNET_free (commit_coins);
return GNUNET_OK;
}
@ -970,8 +974,7 @@ check_commitment (struct MHD_Connection *connection,
* @param refresh_session session to query
* @param key_state key state to lookup denomination pubs
* @param denom_pub denomination key for the coin to create
* @param noreveal_index which index should we use to obtain the
* envelope for the coin, based on cut-and-choose
* @param commit_coin the coin that was committed
* @param coin_off number of the coin
* @return NULL on error, otherwise signature over the coin
*/
@ -981,25 +984,12 @@ refresh_mint_coin (struct MHD_Connection *connection,
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session,
struct MintKeyState *key_state,
const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub,
unsigned int noreveal_index,
const struct RefreshCommitCoin *commit_coin,
unsigned int coin_off)
{
struct RefreshCommitCoin commit_coin;
struct TALER_MINT_DenomKeyIssuePriv *dki;
struct GNUNET_CRYPTO_rsa_Signature *ev_sig;
int res;
res = plugin->get_refresh_commit_coin (plugin->cls,
session,
refresh_session,
noreveal_index,
coin_off,
&commit_coin);
if (GNUNET_OK != res)
{
GNUNET_break (0);
return NULL;
}
dki = TALER_MINT_get_denom_key (key_state, denom_pub);
if (NULL == dki)
{
@ -1007,8 +997,8 @@ refresh_mint_coin (struct MHD_Connection *connection,
return NULL;
}
ev_sig = GNUNET_CRYPTO_rsa_sign (dki->denom_priv,
commit_coin.coin_ev,
commit_coin.coin_ev_size);
commit_coin->coin_ev,
commit_coin->coin_ev_size);
if (NULL == ev_sig)
{
GNUNET_break (0);
@ -1057,6 +1047,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
struct RefreshMelt *melts;
struct GNUNET_CRYPTO_rsa_PublicKey **denom_pubs;
struct GNUNET_CRYPTO_rsa_Signature **ev_sigs;
struct RefreshCommitCoin *commit_coins;
unsigned int i;
unsigned int j;
unsigned int off;
@ -1101,23 +1092,19 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
}
denom_pubs = GNUNET_malloc (refresh_session.num_newcoins *
sizeof (struct GNUNET_CRYPTO_rsa_PublicKey *));
for (j=0;j<refresh_session.num_newcoins;j++)
{
denom_pubs[j] = plugin->get_refresh_order (plugin->cls,
if (GNUNET_OK !=
plugin->get_refresh_order (plugin->cls,
session,
refresh_session_pub,
j);
if (NULL == denom_pubs[j])
refresh_session.num_newcoins,
denom_pubs))
{
GNUNET_break (0);
for (i=0;i<j;i++)
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[i]);
GNUNET_free (denom_pubs);
GNUNET_free (melts);
return (MHD_YES == TALER_MINT_reply_internal_db_error (connection))
? GNUNET_NO : GNUNET_SYSERR;
}
}
off = 0;
@ -1157,6 +1144,23 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
return TALER_MINT_reply_internal_db_error (connection);
}
commit_coins = GNUNET_malloc (refresh_session.num_newcoins *
sizeof (struct RefreshCommitCoin));
if (GNUNET_OK !=
plugin->get_refresh_commit_coins (plugin->cls,
session,
refresh_session_pub,
refresh_session.noreveal_index,
refresh_session.num_newcoins,
commit_coins))
{
GNUNET_break (0);
GNUNET_free (commit_coins);
for (j=0;j<refresh_session.num_newcoins;j++)
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]);
GNUNET_free (denom_pubs);
return TALER_MINT_reply_internal_db_error (connection);
}
ev_sigs = GNUNET_malloc (refresh_session.num_newcoins *
sizeof (struct GNUNET_CRYPTO_rsa_Signature *));
key_state = TALER_MINT_key_state_acquire ();
@ -1167,7 +1171,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
refresh_session_pub,
key_state,
denom_pubs[j],
refresh_session.noreveal_index,
&commit_coins[j],
j);
if (NULL == ev_sigs[j])
{
@ -1178,6 +1182,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
for (j=0;j<refresh_session.num_newcoins;j++)
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]);
GNUNET_free (denom_pubs);
GNUNET_free (commit_coins);
return TALER_MINT_reply_internal_db_error (connection);
}
}
@ -1185,6 +1190,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
for (j=0;j<refresh_session.num_newcoins;j++)
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]);
GNUNET_free (denom_pubs);
GNUNET_free (commit_coins);
if (GNUNET_OK !=
plugin->commit (plugin->cls,

View File

@ -126,7 +126,6 @@ struct MeltDetails
* future)
* @return MHD result code
*/
// FIXME: see #3635.
int
TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
const struct GNUNET_HashCode *melt_hash,

View File

@ -781,8 +781,8 @@ struct TALER_MINTDB_Plugin
* @param cls the @e cls of this struct with the plugin-specific state
* @param db_conn database connection
* @param session_pub refresh session key
* @param newcoin_index index of the coin to generate
* @param denom_pub denomination of the coin to create
* @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_SYSERR on internal error
*/
@ -790,48 +790,50 @@ struct TALER_MINTDB_Plugin
(*insert_refresh_order) (void *cls,
struct TALER_MINTDB_Session *db_conn,
const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub,
uint16_t newcoin_index,
const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub);
uint16_t num_newcoins,
struct GNUNET_CRYPTO_rsa_PublicKey *const*denom_pubs);
/**
* Lookup in the database the @a newcoin_index coin that we want to
* Lookup in the database for the @a num_newcoins coins that we want to
* create in the given refresh operation.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param db_conn database connection
* @param session_pub refresh session key
* @param newcoin_index index of the coin to generate
* @param denom_pub denomination of the coin to create
* @return NULL on error (not found or internal error)
* @param num_newcoins size of the @a denom_pubs array
* @param denom_pubs[OUT] where to write @a num_newcoins denomination keys
* @return #GNUNET_OK on success
* #GNUNET_SYSERR on internal error
*/
struct GNUNET_CRYPTO_rsa_PublicKey *
int
(*get_refresh_order) (void *cls,
struct TALER_MINTDB_Session *db_conn,
const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub,
uint16_t newcoin_index);
uint16_t num_newcoins,
struct GNUNET_CRYPTO_rsa_PublicKey **denom_pubs);
/**
* Store information about the commitment of the
* given coin for the given refresh session in the database.
* Store information about the commitments of the given index @a i
* for the given refresh session in the database.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param db_conn database connection to use
* @param refresh_session_pub refresh session this commitment belongs to
* @param i set index (1st dimension)
* @param j coin index (2nd dimension), corresponds to refreshed (new) coins
* @param commit_coin coin commitment to store
* @param i set index (1st dimension), relating to 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
* #GNUNET_SYSERR on error
*/
int
(*insert_refresh_commit_coin) (void *cls,
(*insert_refresh_commit_coins) (void *cls,
struct TALER_MINTDB_Session *db_conn,
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
unsigned int i,
unsigned int j,
const struct RefreshCommitCoin *commit_coin);
unsigned int num_newcoins,
const struct RefreshCommitCoin *commit_coins);
/**
@ -849,7 +851,7 @@ struct TALER_MINTDB_Plugin
* #GNUNET_SYSERR on error
*/
int
(*get_refresh_commit_coin) (void *cls,
(*get_refresh_commit_coins) (void *cls,
struct TALER_MINTDB_Session *db_conn,
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
unsigned int i,
@ -865,18 +867,18 @@ struct TALER_MINTDB_Plugin
* @param db_conn database connection to use
* @param refresh_session_pub public key of the refresh session this
* commitment belongs with
* @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 i set index (1st dimension), relating to 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
*/
int
(*insert_refresh_commit_link) (void *cls,
(*insert_refresh_commit_links) (void *cls,
struct TALER_MINTDB_Session *db_conn,
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
unsigned int i,
unsigned int j,
const struct RefreshCommitLink *commit_link);
unsigned int num_links,
const struct RefreshCommitLink *commit_links);
/**
* Obtain the commited (encrypted) refresh link data
@ -887,19 +889,19 @@ struct TALER_MINTDB_Plugin
* @param refresh_session_pub public key of the refresh session this
* commitment belongs with
* @param i set index (1st dimension)
* @param j coin index (2nd dimension), corresponds to melted (old) coins
* @param cc[OUT] link information to return
* @param num_links size of the @links array to return
* @param links[OUT] array link information to return
* @return #GNUNET_SYSERR on internal error,
* #GNUNET_NO if commitment was not found
* #GNUNET_OK on success
*/
int
(*get_refresh_commit_link) (void *cls,
(*get_refresh_commit_links) (void *cls,
struct TALER_MINTDB_Session *db_conn,
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub,
unsigned int i,
unsigned int j,
struct RefreshCommitLink *cc);
struct RefreshCommitLink *links);
/**