summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-21 13:38:57 +0100
committerChristian Grothoff <christian@grothoff.org>2015-01-21 13:38:57 +0100
commit53a7140a0bcfc47a373e6392e38e498f9b091f18 (patch)
tree50424865d835f833d708da5a269c6718a5b0cf97
parent4d8f4903db35e9ef6492864c018238e89033ccc7 (diff)
downloadexchange-53a7140a0bcfc47a373e6392e38e498f9b091f18.tar.gz
exchange-53a7140a0bcfc47a373e6392e38e498f9b091f18.tar.bz2
exchange-53a7140a0bcfc47a373e6392e38e498f9b091f18.zip
move /refresh/reveal response generation to taler-mint-httpd_responses.c
-rw-r--r--src/mint/taler-mint-httpd_refresh.c28
-rw-r--r--src/mint/taler-mint-httpd_responses.c29
-rw-r--r--src/mint/taler-mint-httpd_responses.h16
3 files changed, 55 insertions, 18 deletions
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c
index 3751ee17d..2030eb3d6 100644
--- a/src/mint/taler-mint-httpd_refresh.c
+++ b/src/mint/taler-mint-httpd_refresh.c
@@ -436,7 +436,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
denom_pubs,
coin_count,
coin_public_infos);
-
+ // FIXME: free memory
return res;
}
@@ -696,8 +696,7 @@ helper_refresh_reveal_send_response (struct MHD_Connection *connection,
int res;
int newcoin_index;
struct RefreshSession refresh_session;
- json_t *root;
- json_t *list;
+ struct TALER_RSA_Signature *sigs;
res = TALER_MINT_DB_get_refresh_session (db_conn,
refresh_session_pub,
@@ -710,32 +709,27 @@ helper_refresh_reveal_send_response (struct MHD_Connection *connection,
}
GNUNET_assert (0 != refresh_session.reveal_ok);
-
- root = json_object ();
- list = json_array ();
- json_object_set_new (root, "ev_sigs", list);
-
+ sigs = GNUNET_malloc (refresh_session.num_newcoins *
+ sizeof (struct TALER_RSA_Signature));
for (newcoin_index = 0; newcoin_index < refresh_session.num_newcoins; newcoin_index++)
{
- struct TALER_RSA_Signature ev_sig;
-
res = TALER_MINT_DB_get_refresh_collectable (db_conn,
newcoin_index,
refresh_session_pub,
- &ev_sig);
+ &sigs[newcoin_index]);
if (GNUNET_OK != res)
{
// FIXME: return 'internal error'
GNUNET_break (0);
+ GNUNET_free (sigs);
return MHD_NO;
}
- json_array_append_new (list,
- TALER_JSON_from_data (&ev_sig,
- sizeof (struct TALER_RSA_Signature)));
}
- return TALER_MINT_reply_json (connection,
- root,
- MHD_HTTP_OK);
+ res = TALER_MINT_reply_refresh_reveal_success (connection,
+ refresh_session.num_newcoins,
+ sigs);
+ GNUNET_free (sigs);
+ return res;
}
diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c
index 89d79b362..9ba855eea 100644
--- a/src/mint/taler-mint-httpd_responses.c
+++ b/src/mint/taler-mint-httpd_responses.c
@@ -362,6 +362,35 @@ TALER_MINT_reply_refresh_commit_success (struct MHD_Connection *connection,
}
+/**
+ * Send a response for "/refresh/reveal".
+ *
+ * @param connection the connection to send the response to
+ * @param num_newcoins number of new coins for which we reveal data
+ * @param sigs array of @a num_newcoins signatures revealed
+ * @return a MHD result code
+ */
+int
+TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection,
+ unsigned int num_newcoins,
+ const struct TALER_RSA_Signature *sigs)
+{
+ int newcoin_index;
+ json_t *root;
+ json_t *list;
+
+ root = json_object ();
+ list = json_array ();
+ json_object_set_new (root, "ev_sigs", list);
+ for (newcoin_index = 0; newcoin_index < num_newcoins; newcoin_index++)
+ json_array_append_new (list,
+ TALER_JSON_from_data (&sigs[newcoin_index],
+ sizeof (struct TALER_RSA_Signature)));
+ return TALER_MINT_reply_json (connection,
+ root,
+ MHD_HTTP_OK);
+
+}
diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h
index ab771cb31..55ebc0ca9 100644
--- a/src/mint/taler-mint-httpd_responses.h
+++ b/src/mint/taler-mint-httpd_responses.h
@@ -177,7 +177,7 @@ TALER_MINT_reply_refresh_commit_success (struct MHD_Connection *connection,
* Send a response for "/refresh/melt".
*
* @param connection the connection to send the response to
- * @param db_conn the database connection to fetch values from
+ * @param session session data to generate reply from
* @param session_pub the refresh session public key.
* @return a MHD result code
*/
@@ -187,5 +187,19 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection,
const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub);
+/**
+ * Send a response for "/refresh/reveal".
+ *
+ * @param connection the connection to send the response to
+ * @param num_newcoins number of new coins for which we reveal data
+ * @param sigs array of @a num_newcoins signatures revealed
+ * @return a MHD result code
+ */
+int
+TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection,
+ unsigned int num_newcoins,
+ const struct TALER_RSA_Signature *sigs);
+
+
#endif