diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-21 13:38:57 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-21 13:38:57 +0100 |
commit | 53a7140a0bcfc47a373e6392e38e498f9b091f18 (patch) | |
tree | 50424865d835f833d708da5a269c6718a5b0cf97 | |
parent | 4d8f4903db35e9ef6492864c018238e89033ccc7 (diff) | |
download | exchange-53a7140a0bcfc47a373e6392e38e498f9b091f18.tar.gz exchange-53a7140a0bcfc47a373e6392e38e498f9b091f18.zip |
move /refresh/reveal response generation to taler-mint-httpd_responses.c
-rw-r--r-- | src/mint/taler-mint-httpd_refresh.c | 28 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.c | 29 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.h | 16 |
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, | |||
436 | denom_pubs, | 436 | denom_pubs, |
437 | coin_count, | 437 | coin_count, |
438 | coin_public_infos); | 438 | coin_public_infos); |
439 | 439 | // FIXME: free memory | |
440 | return res; | 440 | return res; |
441 | } | 441 | } |
442 | 442 | ||
@@ -696,8 +696,7 @@ helper_refresh_reveal_send_response (struct MHD_Connection *connection, | |||
696 | int res; | 696 | int res; |
697 | int newcoin_index; | 697 | int newcoin_index; |
698 | struct RefreshSession refresh_session; | 698 | struct RefreshSession refresh_session; |
699 | json_t *root; | 699 | struct TALER_RSA_Signature *sigs; |
700 | json_t *list; | ||
701 | 700 | ||
702 | res = TALER_MINT_DB_get_refresh_session (db_conn, | 701 | res = TALER_MINT_DB_get_refresh_session (db_conn, |
703 | refresh_session_pub, | 702 | refresh_session_pub, |
@@ -710,32 +709,27 @@ helper_refresh_reveal_send_response (struct MHD_Connection *connection, | |||
710 | } | 709 | } |
711 | 710 | ||
712 | GNUNET_assert (0 != refresh_session.reveal_ok); | 711 | GNUNET_assert (0 != refresh_session.reveal_ok); |
713 | 712 | sigs = GNUNET_malloc (refresh_session.num_newcoins * | |
714 | root = json_object (); | 713 | sizeof (struct TALER_RSA_Signature)); |
715 | list = json_array (); | ||
716 | json_object_set_new (root, "ev_sigs", list); | ||
717 | |||
718 | for (newcoin_index = 0; newcoin_index < refresh_session.num_newcoins; newcoin_index++) | 714 | for (newcoin_index = 0; newcoin_index < refresh_session.num_newcoins; newcoin_index++) |
719 | { | 715 | { |
720 | struct TALER_RSA_Signature ev_sig; | ||
721 | |||
722 | res = TALER_MINT_DB_get_refresh_collectable (db_conn, | 716 | res = TALER_MINT_DB_get_refresh_collectable (db_conn, |
723 | newcoin_index, | 717 | newcoin_index, |
724 | refresh_session_pub, | 718 | refresh_session_pub, |
725 | &ev_sig); | 719 | &sigs[newcoin_index]); |
726 | if (GNUNET_OK != res) | 720 | if (GNUNET_OK != res) |
727 | { | 721 | { |
728 | // FIXME: return 'internal error' | 722 | // FIXME: return 'internal error' |
729 | GNUNET_break (0); | 723 | GNUNET_break (0); |
724 | GNUNET_free (sigs); | ||
730 | return MHD_NO; | 725 | return MHD_NO; |
731 | } | 726 | } |
732 | json_array_append_new (list, | ||
733 | TALER_JSON_from_data (&ev_sig, | ||
734 | sizeof (struct TALER_RSA_Signature))); | ||
735 | } | 727 | } |
736 | return TALER_MINT_reply_json (connection, | 728 | res = TALER_MINT_reply_refresh_reveal_success (connection, |
737 | root, | 729 | refresh_session.num_newcoins, |
738 | MHD_HTTP_OK); | 730 | sigs); |
731 | GNUNET_free (sigs); | ||
732 | return res; | ||
739 | } | 733 | } |
740 | 734 | ||
741 | 735 | ||
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, | |||
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | /** | ||
366 | * Send a response for "/refresh/reveal". | ||
367 | * | ||
368 | * @param connection the connection to send the response to | ||
369 | * @param num_newcoins number of new coins for which we reveal data | ||
370 | * @param sigs array of @a num_newcoins signatures revealed | ||
371 | * @return a MHD result code | ||
372 | */ | ||
373 | int | ||
374 | TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, | ||
375 | unsigned int num_newcoins, | ||
376 | const struct TALER_RSA_Signature *sigs) | ||
377 | { | ||
378 | int newcoin_index; | ||
379 | json_t *root; | ||
380 | json_t *list; | ||
381 | |||
382 | root = json_object (); | ||
383 | list = json_array (); | ||
384 | json_object_set_new (root, "ev_sigs", list); | ||
385 | for (newcoin_index = 0; newcoin_index < num_newcoins; newcoin_index++) | ||
386 | json_array_append_new (list, | ||
387 | TALER_JSON_from_data (&sigs[newcoin_index], | ||
388 | sizeof (struct TALER_RSA_Signature))); | ||
389 | return TALER_MINT_reply_json (connection, | ||
390 | root, | ||
391 | MHD_HTTP_OK); | ||
392 | |||
393 | } | ||
365 | 394 | ||
366 | 395 | ||
367 | 396 | ||
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, | |||
177 | * Send a response for "/refresh/melt". | 177 | * Send a response for "/refresh/melt". |
178 | * | 178 | * |
179 | * @param connection the connection to send the response to | 179 | * @param connection the connection to send the response to |
180 | * @param db_conn the database connection to fetch values from | 180 | * @param session session data to generate reply from |
181 | * @param session_pub the refresh session public key. | 181 | * @param session_pub the refresh session public key. |
182 | * @return a MHD result code | 182 | * @return a MHD result code |
183 | */ | 183 | */ |
@@ -187,5 +187,19 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, | |||
187 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub); | 187 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub); |
188 | 188 | ||
189 | 189 | ||
190 | /** | ||
191 | * Send a response for "/refresh/reveal". | ||
192 | * | ||
193 | * @param connection the connection to send the response to | ||
194 | * @param num_newcoins number of new coins for which we reveal data | ||
195 | * @param sigs array of @a num_newcoins signatures revealed | ||
196 | * @return a MHD result code | ||
197 | */ | ||
198 | int | ||
199 | TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, | ||
200 | unsigned int num_newcoins, | ||
201 | const struct TALER_RSA_Signature *sigs); | ||
202 | |||
203 | |||
190 | 204 | ||
191 | #endif | 205 | #endif |