avoid querying DB for refresh session twice
This commit is contained in:
parent
9c56c91c1f
commit
c2b32e75dc
@ -816,27 +816,16 @@ TALER_MINT_db_execute_refresh_commit (struct MHD_Connection *connection,
|
|||||||
static int
|
static int
|
||||||
helper_refresh_reveal_send_response (struct MHD_Connection *connection,
|
helper_refresh_reveal_send_response (struct MHD_Connection *connection,
|
||||||
PGconn *db_conn,
|
PGconn *db_conn,
|
||||||
|
const struct RefreshSession *refresh_session,
|
||||||
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub)
|
const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
int newcoin_index;
|
unsigned int newcoin_index;
|
||||||
struct RefreshSession refresh_session;
|
|
||||||
struct TALER_RSA_Signature *sigs;
|
struct TALER_RSA_Signature *sigs;
|
||||||
|
|
||||||
res = TALER_MINT_DB_get_refresh_session (db_conn,
|
sigs = GNUNET_malloc (refresh_session->num_newcoins *
|
||||||
refresh_session_pub,
|
|
||||||
&refresh_session);
|
|
||||||
if (GNUNET_OK != res)
|
|
||||||
{
|
|
||||||
// FIXME: return 'internal error'
|
|
||||||
GNUNET_break (0);
|
|
||||||
return MHD_NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
GNUNET_assert (0 != refresh_session.reveal_ok);
|
|
||||||
sigs = GNUNET_malloc (refresh_session.num_newcoins *
|
|
||||||
sizeof (struct TALER_RSA_Signature));
|
sizeof (struct TALER_RSA_Signature));
|
||||||
for (newcoin_index = 0; newcoin_index < refresh_session.num_newcoins; newcoin_index++)
|
for (newcoin_index = 0; newcoin_index < refresh_session->num_newcoins; newcoin_index++)
|
||||||
{
|
{
|
||||||
res = TALER_MINT_DB_get_refresh_collectable (db_conn,
|
res = TALER_MINT_DB_get_refresh_collectable (db_conn,
|
||||||
newcoin_index,
|
newcoin_index,
|
||||||
@ -851,7 +840,7 @@ helper_refresh_reveal_send_response (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = TALER_MINT_reply_refresh_reveal_success (connection,
|
res = TALER_MINT_reply_refresh_reveal_success (connection,
|
||||||
refresh_session.num_newcoins,
|
refresh_session->num_newcoins,
|
||||||
sigs);
|
sigs);
|
||||||
GNUNET_free (sigs);
|
GNUNET_free (sigs);
|
||||||
return res;
|
return res;
|
||||||
@ -886,8 +875,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
if (NULL == (db_conn = TALER_MINT_DB_get_connection ()))
|
if (NULL == (db_conn = TALER_MINT_DB_get_connection ()))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
// FIXME: return 'internal error'?
|
return TALER_MINT_reply_internal_db_error (connection);
|
||||||
return MHD_NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send response immediately if we already know the session,
|
/* Send response immediately if we already know the session,
|
||||||
@ -900,6 +888,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_YES == res && 0 != refresh_session.reveal_ok)
|
if (GNUNET_YES == res && 0 != refresh_session.reveal_ok)
|
||||||
return helper_refresh_reveal_send_response (connection,
|
return helper_refresh_reveal_send_response (connection,
|
||||||
db_conn,
|
db_conn,
|
||||||
|
&refresh_session,
|
||||||
refresh_session_pub);
|
refresh_session_pub);
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
{
|
{
|
||||||
@ -1140,7 +1129,10 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return helper_refresh_reveal_send_response (connection, db_conn, refresh_session_pub);
|
return helper_refresh_reveal_send_response (connection,
|
||||||
|
db_conn,
|
||||||
|
&refresh_session,
|
||||||
|
refresh_session_pub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user