diff options
Diffstat (limited to 'src/mint/mint_db.c')
-rw-r--r-- | src/mint/mint_db.c | 198 |
1 files changed, 0 insertions, 198 deletions
diff --git a/src/mint/mint_db.c b/src/mint/mint_db.c index a9595f2eb..c4d1ff743 100644 --- a/src/mint/mint_db.c +++ b/src/mint/mint_db.c @@ -581,98 +581,6 @@ TALER_MINT_DB_insert_refresh_order (PGconn *db_conn, int -TALER_MINT_DB_get_known_coin (PGconn *db_conn, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub, - struct KnownCoin *known_coin) -{ - int res; - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(coin_pub), - TALER_DB_QUERY_PARAM_END - }; - - PGresult *result = TALER_DB_exec_prepared (db_conn, "get_known_coin", params); - - if (PGRES_TUPLES_OK != PQresultStatus (result)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Query failed: %s\n", - PQresultErrorMessage (result)); - PQclear (result); - return GNUNET_SYSERR; - } - - if (0 == PQntuples (result)) - return GNUNET_NO; - - GNUNET_assert (1 == PQntuples (result)); - - /* extract basic information about the known coin */ - - { - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC("coin_pub", &known_coin->public_info.coin_pub), - TALER_DB_RESULT_SPEC("denom_pub", &known_coin->public_info.denom_pub), - TALER_DB_RESULT_SPEC("denom_sig", &known_coin->public_info.denom_sig), - TALER_DB_RESULT_SPEC_END - }; - - if (GNUNET_OK != (res = TALER_DB_extract_result (result, rs, 0))) - { - GNUNET_break (0); - PQclear (result); - return GNUNET_SYSERR; - } - } - - /* extract the expended amount of the coin */ - - if (GNUNET_OK != - TALER_DB_extract_amount (result, - 0, - "expended_value", - "expended_fraction", - "expended_currency", - &known_coin->expended_balance)) - { - GNUNET_break (0); - PQclear (result); - return GNUNET_SYSERR; - } - - /* extract the refresh session of the coin or mark it as missing */ - - { - struct TALER_DB_ResultSpec rs[] = { - TALER_DB_RESULT_SPEC("refresh_session_pub", &known_coin->refresh_session_pub), - TALER_DB_RESULT_SPEC_END - }; - - if (GNUNET_SYSERR == (res = TALER_DB_extract_result (result, rs, 0))) - { - GNUNET_break (0); - PQclear (result); - return GNUNET_SYSERR; - } - if (GNUNET_NO == res) - { - known_coin->is_refreshed = GNUNET_NO; - memset (&known_coin->refresh_session_pub, - 0, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); - } - else - { - known_coin->is_refreshed = GNUNET_YES; - } - } - - PQclear (result); - return GNUNET_YES; -} - - -int TALER_MINT_DB_set_commit_signature (PGconn *db_conn, const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, const struct GNUNET_CRYPTO_EddsaSignature *commit_sig) @@ -711,112 +619,6 @@ TALER_MINT_DB_set_reveal_ok (PGconn *db_conn, } -int -TALER_MINT_DB_update_known_coin (PGconn *db_conn, - const struct KnownCoin *known_coin) -{ - struct TALER_AmountNBO expended_nbo = TALER_amount_hton (known_coin->expended_balance); - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(&known_coin->public_info.coin_pub), - TALER_DB_QUERY_PARAM_PTR(&known_coin->public_info.denom_pub), - TALER_DB_QUERY_PARAM_PTR(&known_coin->public_info.denom_sig), - TALER_DB_QUERY_PARAM_PTR(&expended_nbo.value), - TALER_DB_QUERY_PARAM_PTR(&expended_nbo.fraction), - TALER_DB_QUERY_PARAM_PTR_SIZED(expended_nbo.currency, strlen (expended_nbo.currency)), - TALER_DB_QUERY_PARAM_PTR(&known_coin->refresh_session_pub), - TALER_DB_QUERY_PARAM_END - }; - - if (GNUNET_NO == known_coin->is_refreshed) - { - // Mind the magic index! - params[6].data = NULL; - params[6].size = 0; - } - - PGresult *result = TALER_DB_exec_prepared (db_conn, "update_known_coin", params); - - if (PGRES_COMMAND_OK != PQresultStatus (result)) - { - break_db_err (result); - PQclear (result); - return GNUNET_SYSERR; - } - - if (0 != strcmp ("1", PQcmdTuples (result))) - { - PQclear (result); - // return 'no' here (don't fail) so that we can - // insert if update fails (=> "upsert") - return GNUNET_NO; - } - - PQclear (result); - return GNUNET_YES; -} - -int -TALER_MINT_DB_insert_known_coin (PGconn *db_conn, - const struct KnownCoin *known_coin) -{ - struct TALER_AmountNBO expended_nbo = TALER_amount_hton (known_coin->expended_balance); - struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(&known_coin->public_info.coin_pub), - TALER_DB_QUERY_PARAM_PTR(&known_coin->public_info.denom_pub), - TALER_DB_QUERY_PARAM_PTR(&known_coin->public_info.denom_sig), - TALER_DB_QUERY_PARAM_PTR(&expended_nbo.value), - TALER_DB_QUERY_PARAM_PTR(&expended_nbo.fraction), - TALER_DB_QUERY_PARAM_PTR_SIZED(&expended_nbo.currency, strlen (expended_nbo.currency)), - TALER_DB_QUERY_PARAM_PTR(&known_coin->refresh_session_pub), - TALER_DB_QUERY_PARAM_END - }; - - if (GNUNET_NO == known_coin->is_refreshed) - { - // Mind the magic index! - params[6].data = NULL; - params[6].size = 0; - } - - PGresult *result = TALER_DB_exec_prepared (db_conn, "insert_known_coin", params); - - if (PGRES_COMMAND_OK != PQresultStatus (result)) - { - break_db_err (result); - PQclear (result); - return GNUNET_SYSERR; - } - - if (0 != strcmp ("1", PQcmdTuples (result))) - { - PQclear (result); - // return 'no' here (don't fail) so that we can - // update if insert fails (=> "upsert") - return GNUNET_NO; - } - - PQclear (result); - return GNUNET_YES; -} - - -int -TALER_MINT_DB_upsert_known_coin (PGconn *db_conn, - struct KnownCoin *known_coin) -{ - int ret; - ret = TALER_MINT_DB_update_known_coin (db_conn, known_coin); - if (GNUNET_SYSERR == ret) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (GNUNET_YES == ret) - return GNUNET_YES; - return TALER_MINT_DB_insert_known_coin (db_conn, known_coin); -} - - struct GNUNET_CRYPTO_rsa_PublicKey * TALER_MINT_DB_get_refresh_order (PGconn *db_conn, uint16_t newcoin_index, |