diff options
Diffstat (limited to 'src/backenddb/plugin_merchantdb_postgres.c')
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 144 |
1 files changed, 63 insertions, 81 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 016cb4e2..70a3e644 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -284,7 +284,6 @@ lookup_deposits_by_order_cb (void *cls, unsigned int num_results) { struct LookupDepositsByOrderContext *ldoc = cls; - struct PostgresClosure *pg = ldoc->pg; for (unsigned int i = 0; i<num_results; i++) { @@ -301,10 +300,10 @@ lookup_deposits_by_order_cb (void *cls, &exchange_url), GNUNET_PQ_result_spec_auto_from_type ("h_wire", &h_wire), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", - &amount_with_fee), - TALER_PQ_RESULT_SPEC_AMOUNT ("deposit_fee", - &deposit_fee), + TALER_PQ_result_spec_amount_with_currency ("amount_with_fee", + &amount_with_fee), + TALER_PQ_result_spec_amount_with_currency ("deposit_fee", + &deposit_fee), GNUNET_PQ_result_spec_auto_from_type ("coin_pub", &coin_pub), GNUNET_PQ_result_spec_end @@ -412,7 +411,6 @@ lookup_transfer_details_by_order_cb (void *cls, unsigned int num_results) { struct LookupTransferDetailsByOrderContext *ltdo = cls; - struct PostgresClosure *pg = ltdo->pg; for (unsigned int i = 0; i<num_results; i++) { @@ -432,10 +430,10 @@ lookup_transfer_details_by_order_cb (void *cls, &exchange_url), GNUNET_PQ_result_spec_auto_from_type ("wtid", &wtid), - TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_deposit_value", - &deposit_value), - TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_deposit_fee", - &deposit_fee), + TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_value", + &deposit_value), + TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_fee", + &deposit_fee), GNUNET_PQ_result_spec_auto_from_type ("transfer_confirmed", &transfer_confirmed), GNUNET_PQ_result_spec_end @@ -568,7 +566,6 @@ lookup_refunds_detailed_cb (void *cls, unsigned int num_results) { struct LookupRefundsDetailedContext *lrdc = cls; - struct PostgresClosure *pg = lrdc->pg; for (unsigned int i = 0; i<num_results; i++) { @@ -593,8 +590,8 @@ lookup_refunds_detailed_cb (void *cls, &rtransaction_id), GNUNET_PQ_result_spec_string ("reason", &reason), - TALER_PQ_RESULT_SPEC_AMOUNT ("refund_amount", - &refund_amount), + TALER_PQ_result_spec_amount_with_currency ("refund_amount", + &refund_amount), GNUNET_PQ_result_spec_auto_from_type ("pending", &pending8), GNUNET_PQ_result_spec_end @@ -906,10 +903,10 @@ postgres_lookup_wire_fee (void *cls, GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee", - &fees->wire), - TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee", - &fees->closing), + TALER_PQ_result_spec_amount_with_currency ("wire_fee", + &fees->wire), + TALER_PQ_result_spec_amount_with_currency ("closing_fee", + &fees->closing), GNUNET_PQ_result_spec_timestamp ("start_date", start_date), GNUNET_PQ_result_spec_timestamp ("end_date", @@ -971,7 +968,6 @@ lookup_deposits_by_contract_and_coin_cb (void *cls, unsigned int num_results) { struct LookupDepositsByCnCContext *ldcc = cls; - struct PostgresClosure *pg = ldcc->pg; for (unsigned int i = 0; i<num_results; i++) { @@ -988,14 +984,14 @@ lookup_deposits_by_contract_and_coin_cb (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_string ("exchange_url", &exchange_url), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", - &amount_with_fee), - TALER_PQ_RESULT_SPEC_AMOUNT ("deposit_fee", - &deposit_fee), - TALER_PQ_RESULT_SPEC_AMOUNT ("refund_fee", - &refund_fee), - TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee", - &wire_fee), + TALER_PQ_result_spec_amount_with_currency ("amount_with_fee", + &amount_with_fee), + TALER_PQ_result_spec_amount_with_currency ("deposit_fee", + &deposit_fee), + TALER_PQ_result_spec_amount_with_currency ("refund_fee", + &refund_fee), + TALER_PQ_result_spec_amount_with_currency ("wire_fee", + &wire_fee), GNUNET_PQ_result_spec_auto_from_type ("h_wire", &h_wire), GNUNET_PQ_result_spec_timestamp ("deposit_timestamp", @@ -1125,15 +1121,15 @@ postgres_lookup_transfer ( bool no_sig; struct TALER_Amount credit_amount; struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT ("credit_amount", - &credit_amount), + TALER_PQ_result_spec_amount_with_currency ("credit_amount", + &credit_amount), GNUNET_PQ_result_spec_allow_null ( - TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee", - wire_fee), + TALER_PQ_result_spec_amount_with_currency ("wire_fee", + wire_fee), &no_sig), GNUNET_PQ_result_spec_allow_null ( - TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_amount", - exchange_amount), + TALER_PQ_result_spec_amount_with_currency ("exchange_amount", + exchange_amount), NULL), GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_timestamp ("execution_time", @@ -1218,7 +1214,6 @@ lookup_transfer_summary_cb (void *cls, unsigned int num_results) { struct LookupTransferSummaryContext *ltdc = cls; - struct PostgresClosure *pg = ltdc->pg; for (unsigned int i = 0; i<num_results; i++) { @@ -1228,10 +1223,10 @@ lookup_transfer_summary_cb (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_string ("order_id", &order_id), - TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_deposit_value", - &deposit_value), - TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_deposit_fee", - &deposit_fee), + TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_value", + &deposit_value), + TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_fee", + &deposit_fee), GNUNET_PQ_result_spec_end }; @@ -1339,7 +1334,6 @@ lookup_transfer_details_cb (void *cls, unsigned int num_results) { struct LookupTransferDetailsContext *ltdc = cls; - struct PostgresClosure *pg = ltdc->pg; for (unsigned int i = 0; i<num_results; i++) { @@ -1352,10 +1346,10 @@ lookup_transfer_details_cb (void *cls, &ttd.h_contract_terms), GNUNET_PQ_result_spec_auto_from_type ("coin_pub", &ttd.coin_pub), - TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_deposit_value", - &ttd.coin_value), - TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_deposit_fee", - &ttd.coin_fee), + TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_value", + &ttd.coin_value), + TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_fee", + &ttd.coin_fee), GNUNET_PQ_result_spec_end }; @@ -1463,7 +1457,6 @@ lookup_pending_reserves_cb (void *cls, unsigned int num_results) { struct LookupPendingReservesContext *lrc = cls; - struct PostgresClosure *pg = lrc->pg; for (unsigned int i = 0; i < num_results; i++) { @@ -1478,8 +1471,8 @@ lookup_pending_reserves_cb (void *cls, &instance_id), GNUNET_PQ_result_spec_string ("exchange_url", &exchange_url), - TALER_PQ_RESULT_SPEC_AMOUNT ("merchant_initial_balance", - &merchant_initial_balance), + TALER_PQ_result_spec_amount_with_currency ("merchant_initial_balance", + &merchant_initial_balance), GNUNET_PQ_result_spec_end }; @@ -1579,7 +1572,6 @@ lookup_reserve_rewards_cb (void *cls, unsigned int num_results) { struct LookupRewardsContext *ltc = cls; - struct PostgresClosure *pg = ltc->pg; GNUNET_array_grow (ltc->rewards, ltc->rewards_length, @@ -1592,8 +1584,8 @@ lookup_reserve_rewards_cb (void *cls, &td->reason), GNUNET_PQ_result_spec_auto_from_type ("reward_id", &td->reward_id), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", - &td->total_amount), + TALER_PQ_result_spec_amount_with_currency ("amount", + &td->total_amount), GNUNET_PQ_result_spec_end }; @@ -1653,14 +1645,14 @@ postgres_lookup_reserve (void *cls, &creation_time), GNUNET_PQ_result_spec_timestamp ("expiration", &expiration_time), - TALER_PQ_RESULT_SPEC_AMOUNT ("merchant_initial_balance", - &merchant_initial_balance), - TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_initial_balance", - &exchange_initial_balance), - TALER_PQ_RESULT_SPEC_AMOUNT ("rewards_picked_up", - &pickup_amount), - TALER_PQ_RESULT_SPEC_AMOUNT ("rewards_committed", - &committed_amount), + TALER_PQ_result_spec_amount_with_currency ("merchant_initial_balance", + &merchant_initial_balance), + TALER_PQ_result_spec_amount_with_currency ("exchange_initial_balance", + &exchange_initial_balance), + TALER_PQ_result_spec_amount_with_currency ("rewards_picked_up", + &pickup_amount), + TALER_PQ_result_spec_amount_with_currency ("rewards_committed", + &committed_amount), GNUNET_PQ_result_spec_auto_from_type ("master_pub", &master_pub), GNUNET_PQ_result_spec_bool ("active", @@ -1955,10 +1947,10 @@ postgres_lookup_reward (void *cls, GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", - total_authorized), - TALER_PQ_RESULT_SPEC_AMOUNT ("picked_up", - total_picked_up), + TALER_PQ_result_spec_amount_with_currency ("amount", + total_authorized), + TALER_PQ_result_spec_amount_with_currency ("picked_up", + total_picked_up), GNUNET_PQ_result_spec_timestamp ("expiration", expiration), GNUNET_PQ_result_spec_string ("exchange_url", @@ -2018,7 +2010,6 @@ lookup_rewards_cb (void *cls, unsigned int num_results) { struct LookupMerchantRewardsContext *plc = cls; - struct PostgresClosure *pg = plc->pg; for (unsigned int i = 0; i < num_results; i++) { @@ -2030,8 +2021,8 @@ lookup_rewards_cb (void *cls, &row_id), GNUNET_PQ_result_spec_auto_from_type ("reward_id", &reward_id), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", - &reward_amount), + TALER_PQ_result_spec_amount_with_currency ("amount", + &reward_amount), GNUNET_PQ_result_spec_end }; @@ -2154,7 +2145,6 @@ lookup_pickup_details_cb (void *cls, unsigned int num_results) { struct LookupRewardDetailsContext *ltdc = cls; - struct PostgresClosure *pg = ltdc->pg; *ltdc->pickups_length = num_results; *ltdc->pickups = GNUNET_new_array (num_results, @@ -2166,8 +2156,8 @@ lookup_pickup_details_cb (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("pickup_id", &pd->pickup_id), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", - &pd->requested_amount), + TALER_PQ_result_spec_amount_with_currency ("amount", + &pd->requested_amount), GNUNET_PQ_result_spec_uint64 ("num_planchets", &num_planchets), GNUNET_PQ_result_spec_end @@ -2232,10 +2222,10 @@ postgres_lookup_reward_details (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("reward_serial", &reward_serial), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", - total_authorized), - TALER_PQ_RESULT_SPEC_AMOUNT ("picked_up", - total_picked_up), + TALER_PQ_result_spec_amount_with_currency ("amount", + total_authorized), + TALER_PQ_result_spec_amount_with_currency ("picked_up", + total_picked_up), GNUNET_PQ_result_spec_string ("justification", justification), GNUNET_PQ_result_spec_timestamp ("expiration", @@ -3550,10 +3540,11 @@ postgres_connect (void *cls) ",merchant_id" ",exchange_url" ",merchant_initial_balance" - " FROM merchant_reward_reserves" + " FROM merchant_reward_reserves mrr" " JOIN merchant_instances USING (merchant_serial)" " JOIN merchant_reward_reserve_keys USING (reserve_serial)" - " WHERE exchange_initial_balance=CAST((0,0) AS taler_amount)"), + " WHERE (mrr.exchange_initial_balance).val=0" + " AND (mrr.exchange_initial_balance).frac=0"), /* For postgres_lookup_reserve() */ GNUNET_PQ_make_prepare ("lookup_reserve", "SELECT" @@ -4000,14 +3991,6 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) GNUNET_free (pg); return NULL; } - if (GNUNET_OK != - TALER_config_get_currency (cfg, - &pg->currency)) - { - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; - } plugin = GNUNET_new (struct TALER_MERCHANTDB_Plugin); plugin->cls = pg; plugin->connect = &postgres_connect; @@ -4213,7 +4196,6 @@ libtaler_plugin_merchantdb_postgres_done (void *cls) pg->conn = NULL; } GNUNET_free (pg->sql_dir); - GNUNET_free (pg->currency); GNUNET_free (pg); GNUNET_free (plugin); return NULL; |