This commit is contained in:
Christian Grothoff 2015-06-12 10:55:03 +02:00
parent 5fe7fd24c1
commit 3cdee2eb6a
3 changed files with 21 additions and 111 deletions

View File

@ -871,41 +871,6 @@ struct TALER_MINTDB_Plugin
const struct TALER_MINTDB_RefreshSession *refresh_session); 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. * Store the given /refresh/melt request in the database.
* *

View File

@ -467,7 +467,7 @@ postgres_prepare (PGconn *db_conn)
/* Used in #postgres_get_denomination_info() */ /* Used in #postgres_get_denomination_info() */
PREPARE ("denomination_get", PREPARE ("denomination_get",
"SELECT FROM denominations" "SELECT"
" master_pub" " master_pub"
",master_sig" ",master_sig"
",valid_from" ",valid_from"
@ -486,6 +486,7 @@ postgres_prepare (PGconn *db_conn)
",fee_refresh_val" ",fee_refresh_val"
",fee_refresh_frac" ",fee_refresh_frac"
",fee_refresh_curr" /* must match coin_curr */ ",fee_refresh_curr" /* must match coin_curr */
" FROM denominations"
" WHERE pub=$1;", " WHERE pub=$1;",
1, NULL); 1, NULL);
@ -1964,11 +1965,9 @@ postgres_create_refresh_session (void *cls,
* @param session the shared database session * @param session the shared database session
* @param coin_info the public coin info * @param coin_info the public coin info
* @return #GNUNET_SYSERR upon error; #GNUNET_OK upon success * @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 static int
postgres_insert_known_coin (void *cls, insert_known_coin (void *cls,
struct TALER_MINTDB_Session *session, struct TALER_MINTDB_Session *session,
const struct TALER_CoinPublicInfo *coin_info) const struct TALER_CoinPublicInfo *coin_info)
{ {
@ -2003,11 +2002,9 @@ postgres_insert_known_coin (void *cls,
* @return #GNUNET_SYSERR upon error; #GNUNET_NO if no coin is found; #GNUNET_OK * @return #GNUNET_SYSERR upon error; #GNUNET_NO if no coin is found; #GNUNET_OK
* if upon succesfullying retrieving the record data info @a * if upon succesfullying retrieving the record data info @a
* coin_info * coin_info
* @deprecated (certainly should not be in public API, not sure if
* we want to keep this normalization internally, #3811)
*/ */
static int static int
postgres_get_known_coin (void *cls, get_known_coin (void *cls,
struct TALER_MINTDB_Session *session, struct TALER_MINTDB_Session *session,
const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub,
struct TALER_CoinPublicInfo *coin_info) struct TALER_CoinPublicInfo *coin_info)
@ -2085,7 +2082,7 @@ postgres_insert_refresh_melt (void *cls,
int ret; int ret;
/* check if the coin is already known */ /* check if the coin is already known */
ret = postgres_get_known_coin (cls, ret = get_known_coin (cls,
session, session,
&melt->coin.coin_pub, &melt->coin.coin_pub,
NULL); NULL);
@ -2096,7 +2093,7 @@ postgres_insert_refresh_melt (void *cls,
} }
if (GNUNET_NO == ret) /* if not, insert it */ if (GNUNET_NO == ret) /* if not, insert it */
{ {
ret = postgres_insert_known_coin (cls, ret = insert_known_coin (cls,
session, session,
&melt->coin); &melt->coin);
if (ret == GNUNET_SYSERR) if (ret == GNUNET_SYSERR)
@ -2187,7 +2184,7 @@ postgres_get_refresh_melt (void *cls,
PQclear (result); PQclear (result);
} }
/* fetch the coin info and denomination info */ /* fetch the coin info and denomination info */
if (GNUNET_OK != postgres_get_known_coin (cls, if (GNUNET_OK != get_known_coin (cls,
session, session,
&coin.coin_pub, &coin.coin_pub,
&coin)) &coin))
@ -3170,8 +3167,6 @@ libtaler_plugin_mintdb_postgres_init (void *cls)
plugin->get_refresh_session = &postgres_get_refresh_session; plugin->get_refresh_session = &postgres_get_refresh_session;
plugin->create_refresh_session = &postgres_create_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->insert_refresh_melt = &postgres_insert_refresh_melt;
plugin->get_refresh_melt = &postgres_get_refresh_melt; plugin->get_refresh_melt = &postgres_get_refresh_melt;
plugin->insert_refresh_order = &postgres_insert_refresh_order; plugin->insert_refresh_order = &postgres_insert_refresh_order;

View File

@ -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. * Main function that will be run by the scheduler.
* *
@ -461,7 +411,7 @@ run (void *cls,
&refresh_session, &refresh_session,
sizeof (refresh_session))); sizeof (refresh_session)));
} }
FAILIF (GNUNET_OK != test_known_coins (session)); // FAILIF (GNUNET_OK != test_known_coins (session));
result = 0; result = 0;
/* FIXME: test_refresh_melts */ /* FIXME: test_refresh_melts */