From 3cdee2eb6a245695f00952aa09a9033f0d84c128 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 12 Jun 2015 10:55:03 +0200 Subject: fix #3811 --- src/include/taler_mintdb_plugin.h | 35 ------------------------- src/mintdb/plugin_mintdb_postgres.c | 45 ++++++++++++++------------------ src/mintdb/test_mintdb.c | 52 +------------------------------------ 3 files changed, 21 insertions(+), 111 deletions(-) (limited to 'src') diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index 7cbc3505d..a249c6ade 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -871,41 +871,6 @@ struct TALER_MINTDB_Plugin const struct TALER_MINTDB_RefreshSession *refresh_session); - /** - * Retrieve the record for a known coin. - * - * @param cls the plugin closure - * @param session the database session handle - * @param coin_pub the public key of the coin to search for - * @param coin_info place holder for the returned coin information object - * @return #GNUNET_SYSERR upon error; #GNUNET_NO if no coin is found; #GNUNET_OK - * if upon succesfullying retrieving the record data info @a - * ret_coin_info - * @deprecated (#3811) - */ - int - (*get_known_coin) (void *cls, - struct TALER_MINTDB_Session *session, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - struct TALER_CoinPublicInfo *coin_info); - - - /** - * Insert a coin we know of into the DB. The coin can then be referenced by - * tables for deposits, lock and refresh functionality. - * - * @param cls plugin closure - * @param session the shared database session - * @param coin_info the public coin info - * @return #GNUNET_SYSERR upon error; #GNUNET_OK upon success - * @deprecated (#3811) - */ - int - (*insert_known_coin) (void *cls, - struct TALER_MINTDB_Session *session, - const struct TALER_CoinPublicInfo *coin_info); - - /** * Store the given /refresh/melt request in the database. * diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index b1dffc68c..f381a9437 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -467,7 +467,7 @@ postgres_prepare (PGconn *db_conn) /* Used in #postgres_get_denomination_info() */ PREPARE ("denomination_get", - "SELECT FROM denominations" + "SELECT" " master_pub" ",master_sig" ",valid_from" @@ -486,6 +486,7 @@ postgres_prepare (PGconn *db_conn) ",fee_refresh_val" ",fee_refresh_frac" ",fee_refresh_curr" /* must match coin_curr */ + " FROM denominations" " WHERE pub=$1;", 1, NULL); @@ -1964,13 +1965,11 @@ postgres_create_refresh_session (void *cls, * @param session the shared database session * @param coin_info the public coin info * @return #GNUNET_SYSERR upon error; #GNUNET_OK upon success - * @deprecated (certainly should not be in public API, not sure if - * we want to keep this normalization internally, #3811) */ static int -postgres_insert_known_coin (void *cls, - struct TALER_MINTDB_Session *session, - const struct TALER_CoinPublicInfo *coin_info) +insert_known_coin (void *cls, + struct TALER_MINTDB_Session *session, + const struct TALER_CoinPublicInfo *coin_info) { PGresult *result; struct TALER_PQ_QueryParam params[] = { @@ -2003,14 +2002,12 @@ postgres_insert_known_coin (void *cls, * @return #GNUNET_SYSERR upon error; #GNUNET_NO if no coin is found; #GNUNET_OK * if upon succesfullying retrieving the record data info @a * coin_info - * @deprecated (certainly should not be in public API, not sure if - * we want to keep this normalization internally, #3811) */ static int -postgres_get_known_coin (void *cls, - struct TALER_MINTDB_Session *session, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - struct TALER_CoinPublicInfo *coin_info) +get_known_coin (void *cls, + struct TALER_MINTDB_Session *session, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + struct TALER_CoinPublicInfo *coin_info) { PGresult *result; struct TALER_PQ_QueryParam params[] = { @@ -2085,10 +2082,10 @@ postgres_insert_refresh_melt (void *cls, int ret; /* check if the coin is already known */ - ret = postgres_get_known_coin (cls, - session, - &melt->coin.coin_pub, - NULL); + ret = get_known_coin (cls, + session, + &melt->coin.coin_pub, + NULL); if (GNUNET_SYSERR == ret) { GNUNET_break (0); @@ -2096,9 +2093,9 @@ postgres_insert_refresh_melt (void *cls, } if (GNUNET_NO == ret) /* if not, insert it */ { - ret = postgres_insert_known_coin (cls, - session, - &melt->coin); + ret = insert_known_coin (cls, + session, + &melt->coin); if (ret == GNUNET_SYSERR) { GNUNET_break (0); @@ -2187,10 +2184,10 @@ postgres_get_refresh_melt (void *cls, PQclear (result); } /* fetch the coin info and denomination info */ - if (GNUNET_OK != postgres_get_known_coin (cls, - session, - &coin.coin_pub, - &coin)) + if (GNUNET_OK != get_known_coin (cls, + session, + &coin.coin_pub, + &coin)) return GNUNET_SYSERR; if (NULL == melt) return GNUNET_OK; @@ -3170,8 +3167,6 @@ libtaler_plugin_mintdb_postgres_init (void *cls) plugin->get_refresh_session = &postgres_get_refresh_session; plugin->create_refresh_session = &postgres_create_refresh_session; - plugin->get_known_coin = &postgres_get_known_coin; - plugin->insert_known_coin = &postgres_insert_known_coin; plugin->insert_refresh_melt = &postgres_insert_refresh_melt; plugin->get_refresh_melt = &postgres_get_refresh_melt; plugin->insert_refresh_order = &postgres_insert_refresh_order; diff --git a/src/mintdb/test_mintdb.c b/src/mintdb/test_mintdb.c index 88b6ec6d6..a6add0286 100644 --- a/src/mintdb/test_mintdb.c +++ b/src/mintdb/test_mintdb.c @@ -174,56 +174,6 @@ destroy_denom_key_pair (struct DenomKeyPair *dkp) } -/** - * Tests on the known_coins relation - * - * @param session the DB session - * @return #GNUNET_OK if the tests are successful; #GNUNET_SYSERR if not. - */ -static int -test_known_coins (struct TALER_MINTDB_Session *session) -{ - struct TALER_CoinPublicInfo coin_info; - struct TALER_CoinPublicInfo ret_coin_info; - struct DenomKeyPair *dkp; - int ret = GNUNET_SYSERR; - - dkp = create_denom_key_pair (1024, session); - RND_BLK (&coin_info); - coin_info.denom_pub = dkp->pub; - coin_info.denom_sig.rsa_signature = - GNUNET_CRYPTO_rsa_sign (dkp->priv.rsa_private_key, - "foobar", 6); - FAILIF (GNUNET_NO != - plugin->get_known_coin (plugin->cls, - session, - &coin_info.coin_pub, - &ret_coin_info)); - FAILIF (GNUNET_OK != - plugin->insert_known_coin (plugin->cls, - session, - &coin_info)); - FAILIF (GNUNET_YES != - plugin->get_known_coin (plugin->cls, - session, - &coin_info.coin_pub, - &ret_coin_info)); - FAILIF (0 != GNUNET_CRYPTO_rsa_public_key_cmp - (ret_coin_info.denom_pub.rsa_public_key, - coin_info.denom_pub.rsa_public_key)); - FAILIF (0 != GNUNET_CRYPTO_rsa_signature_cmp - (ret_coin_info.denom_sig.rsa_signature, - coin_info.denom_sig.rsa_signature)); - GNUNET_CRYPTO_rsa_public_key_free (ret_coin_info.denom_pub.rsa_public_key); - GNUNET_CRYPTO_rsa_signature_free (ret_coin_info.denom_sig.rsa_signature); - ret = GNUNET_OK; - drop: - destroy_denom_key_pair (dkp); - GNUNET_CRYPTO_rsa_signature_free (coin_info.denom_sig.rsa_signature); - return ret; -} - - /** * Main function that will be run by the scheduler. * @@ -461,7 +411,7 @@ run (void *cls, &refresh_session, sizeof (refresh_session))); } - FAILIF (GNUNET_OK != test_known_coins (session)); + // FAILIF (GNUNET_OK != test_known_coins (session)); result = 0; /* FIXME: test_refresh_melts */ -- cgit v1.2.3