diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-21 14:52:41 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-21 14:52:41 +0100 |
commit | c2b32e75dc84814c5f7a03e54c4d18213119b4b4 (patch) | |
tree | 0c3b0ee2c44078efd5664e6d64b8882a582534ec | |
parent | 9c56c91c1f9879352e5be51ccb2447128e0cd735 (diff) | |
download | exchange-c2b32e75dc84814c5f7a03e54c4d18213119b4b4.tar.gz exchange-c2b32e75dc84814c5f7a03e54c4d18213119b4b4.zip |
avoid querying DB for refresh session twice
-rw-r--r-- | src/mint/taler-mint-httpd_db.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index a581d486b..369e88967 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c | |||
@@ -816,27 +816,16 @@ TALER_MINT_db_execute_refresh_commit (struct MHD_Connection *connection, | |||
816 | static int | 816 | static int |
817 | helper_refresh_reveal_send_response (struct MHD_Connection *connection, | 817 | helper_refresh_reveal_send_response (struct MHD_Connection *connection, |
818 | PGconn *db_conn, | 818 | PGconn *db_conn, |
819 | const struct RefreshSession *refresh_session, | ||
819 | const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub) | 820 | const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub) |
820 | { | 821 | { |
821 | int res; | 822 | int res; |
822 | int newcoin_index; | 823 | unsigned int newcoin_index; |
823 | struct RefreshSession refresh_session; | ||
824 | struct TALER_RSA_Signature *sigs; | 824 | struct TALER_RSA_Signature *sigs; |
825 | 825 | ||
826 | res = TALER_MINT_DB_get_refresh_session (db_conn, | 826 | sigs = GNUNET_malloc (refresh_session->num_newcoins * |
827 | refresh_session_pub, | ||
828 | &refresh_session); | ||
829 | if (GNUNET_OK != res) | ||
830 | { | ||
831 | // FIXME: return 'internal error' | ||
832 | GNUNET_break (0); | ||
833 | return MHD_NO; | ||
834 | } | ||
835 | |||
836 | GNUNET_assert (0 != refresh_session.reveal_ok); | ||
837 | sigs = GNUNET_malloc (refresh_session.num_newcoins * | ||
838 | sizeof (struct TALER_RSA_Signature)); | 827 | sizeof (struct TALER_RSA_Signature)); |
839 | for (newcoin_index = 0; newcoin_index < refresh_session.num_newcoins; newcoin_index++) | 828 | for (newcoin_index = 0; newcoin_index < refresh_session->num_newcoins; newcoin_index++) |
840 | { | 829 | { |
841 | res = TALER_MINT_DB_get_refresh_collectable (db_conn, | 830 | res = TALER_MINT_DB_get_refresh_collectable (db_conn, |
842 | newcoin_index, | 831 | newcoin_index, |
@@ -851,7 +840,7 @@ helper_refresh_reveal_send_response (struct MHD_Connection *connection, | |||
851 | } | 840 | } |
852 | } | 841 | } |
853 | res = TALER_MINT_reply_refresh_reveal_success (connection, | 842 | res = TALER_MINT_reply_refresh_reveal_success (connection, |
854 | refresh_session.num_newcoins, | 843 | refresh_session->num_newcoins, |
855 | sigs); | 844 | sigs); |
856 | GNUNET_free (sigs); | 845 | GNUNET_free (sigs); |
857 | return res; | 846 | return res; |
@@ -886,8 +875,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, | |||
886 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) | 875 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) |
887 | { | 876 | { |
888 | GNUNET_break (0); | 877 | GNUNET_break (0); |
889 | // FIXME: return 'internal error'? | 878 | return TALER_MINT_reply_internal_db_error (connection); |
890 | return MHD_NO; | ||
891 | } | 879 | } |
892 | 880 | ||
893 | /* Send response immediately if we already know the session, | 881 | /* Send response immediately if we already know the session, |
@@ -900,6 +888,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, | |||
900 | if (GNUNET_YES == res && 0 != refresh_session.reveal_ok) | 888 | if (GNUNET_YES == res && 0 != refresh_session.reveal_ok) |
901 | return helper_refresh_reveal_send_response (connection, | 889 | return helper_refresh_reveal_send_response (connection, |
902 | db_conn, | 890 | db_conn, |
891 | &refresh_session, | ||
903 | refresh_session_pub); | 892 | refresh_session_pub); |
904 | if (GNUNET_SYSERR == res) | 893 | if (GNUNET_SYSERR == res) |
905 | { | 894 | { |
@@ -1140,7 +1129,10 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, | |||
1140 | return MHD_NO; | 1129 | return MHD_NO; |
1141 | } | 1130 | } |
1142 | 1131 | ||
1143 | return helper_refresh_reveal_send_response (connection, db_conn, refresh_session_pub); | 1132 | return helper_refresh_reveal_send_response (connection, |
1133 | db_conn, | ||
1134 | &refresh_session, | ||
1135 | refresh_session_pub); | ||
1144 | } | 1136 | } |
1145 | 1137 | ||
1146 | 1138 | ||