diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-01-16 23:49:34 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-01-16 23:49:34 +0100 |
commit | d61c2e400ac07574fc326c8d2be6f51be7c2a25c (patch) | |
tree | 277d9bf5ad2cd160a85d75992ae590e59dd28ac9 /src/exchangedb | |
parent | 0305cf5f9eb904e7a3ab3e8d39f4974a92a9a0b3 (diff) |
kill another FIXME
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/exchangedb_transactions.c | 7 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_common.c | 12 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 140 | ||||
-rw-r--r-- | src/exchangedb/test_exchangedb.c | 65 |
4 files changed, 84 insertions, 140 deletions
diff --git a/src/exchangedb/exchangedb_transactions.c b/src/exchangedb/exchangedb_transactions.c index 2891f0adb..871061aa2 100644 --- a/src/exchangedb/exchangedb_transactions.c +++ b/src/exchangedb/exchangedb_transactions.c @@ -46,8 +46,9 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (struct GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (spent.currency, &refunded)); - for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; NULL != pos; pos = - pos->next) + for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; + NULL != pos; + pos = pos->next) { switch (pos->type) { @@ -67,7 +68,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (struct if (GNUNET_OK != TALER_amount_add (&spent, &spent, - &pos->details.melt->session.amount_with_fee)) + &pos->details.melt->amount_with_fee)) { GNUNET_break (0); return GNUNET_SYSERR; diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c index dac746b09..02f06cc1f 100644 --- a/src/exchangedb/plugin_exchangedb_common.c +++ b/src/exchangedb/plugin_exchangedb_common.c @@ -92,15 +92,9 @@ common_free_coin_transaction_list (void *cls, case TALER_EXCHANGEDB_TT_DEPOSIT: if (NULL != list->details.deposit->receiver_wire_account) json_decref (list->details.deposit->receiver_wire_account); - if (NULL != list->details.deposit->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free ( - list->details.deposit->coin.denom_sig.rsa_signature); GNUNET_free (list->details.deposit); break; case TALER_EXCHANGEDB_TT_REFRESH_MELT: - if (NULL != list->details.melt->session.coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free ( - list->details.melt->session.coin.denom_sig.rsa_signature); GNUNET_free (list->details.melt); break; case TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK: @@ -110,15 +104,9 @@ common_free_coin_transaction_list (void *cls, GNUNET_free (list->details.old_coin_payback); break; case TALER_EXCHANGEDB_TT_REFUND: - if (NULL != list->details.refund->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free ( - list->details.refund->coin.denom_sig.rsa_signature); GNUNET_free (list->details.refund); break; case TALER_EXCHANGEDB_TT_PAYBACK: - if (NULL != list->details.payback->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free ( - list->details.payback->coin.denom_sig.rsa_signature); GNUNET_free (list->details.payback); break; case TALER_EXCHANGEDB_TT_PAYBACK_REFRESH: diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 65e52e675..59f0efe49 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1630,12 +1630,8 @@ postgres_get_session (void *cls) ",amount_val" ",amount_frac" ",timestamp" - ",coins.denom_pub_hash" - ",coins.denom_sig" ",payback_uuid" " FROM payback" - " JOIN known_coins coins" - " USING (coin_pub)" " JOIN reserves_out ro" " USING (h_blind_ev)" " WHERE payback.coin_pub=$1" @@ -2982,7 +2978,10 @@ postgres_mark_deposit_tiny (void *cls, * * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to the database - * @param deposit the deposit to check + * @param coin_pub the coin to check for deposit + * @param merchant_pub merchant to receive the deposit + * @param h_contract_terms contract terms of the deposit + * @param h_wire hash of the merchant's wire details * @return #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if is is marked done, * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if not, * otherwise transaction error status (incl. deposit unknown) @@ -2990,13 +2989,16 @@ postgres_mark_deposit_tiny (void *cls, static enum GNUNET_DB_QueryStatus postgres_test_deposit_done (void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct TALER_EXCHANGEDB_Deposit *deposit) + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct GNUNET_HashCode *h_contract_terms, + const struct GNUNET_HashCode *h_wire) { struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (&deposit->coin.coin_pub), - GNUNET_PQ_query_param_auto_from_type (&deposit->merchant_pub), - GNUNET_PQ_query_param_auto_from_type (&deposit->h_contract_terms), - GNUNET_PQ_query_param_auto_from_type (&deposit->h_wire), + GNUNET_PQ_query_param_auto_from_type (coin_pub), + GNUNET_PQ_query_param_auto_from_type (merchant_pub), + GNUNET_PQ_query_param_auto_from_type (h_contract_terms), + GNUNET_PQ_query_param_auto_from_type (h_wire), GNUNET_PQ_query_param_end }; uint8_t done = 0; @@ -3517,18 +3519,18 @@ postgres_insert_refund (void *cls, { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&refund->coin.coin_pub), - GNUNET_PQ_query_param_auto_from_type (&refund->merchant_pub), - GNUNET_PQ_query_param_auto_from_type (&refund->merchant_sig), - GNUNET_PQ_query_param_auto_from_type (&refund->h_contract_terms), - GNUNET_PQ_query_param_uint64 (&refund->rtransaction_id), - TALER_PQ_query_param_amount (&refund->refund_amount), + GNUNET_PQ_query_param_auto_from_type (&refund->details.merchant_pub), + GNUNET_PQ_query_param_auto_from_type (&refund->details.merchant_sig), + GNUNET_PQ_query_param_auto_from_type (&refund->details.h_contract_terms), + GNUNET_PQ_query_param_uint64 (&refund->details.rtransaction_id), + TALER_PQ_query_param_amount (&refund->details.refund_amount), GNUNET_PQ_query_param_end }; (void) cls; GNUNET_assert (GNUNET_YES == - TALER_amount_cmp_currency (&refund->refund_amount, - &refund->refund_fee)); + TALER_amount_cmp_currency (&refund->details.refund_amount, + &refund->details.refund_fee)); return GNUNET_PQ_eval_prepared_non_select (session->conn, "insert_refund", params); @@ -4296,12 +4298,11 @@ add_coin_deposit (void *cls, for (unsigned int i = 0; i < num_results; i++) { - struct TALER_EXCHANGEDB_Deposit *deposit; + struct TALER_EXCHANGEDB_DepositListEntry *deposit; struct TALER_EXCHANGEDB_TransactionList *tl; - enum GNUNET_DB_QueryStatus qs; uint64_t serial_id; - deposit = GNUNET_new (struct TALER_EXCHANGEDB_Deposit); + deposit = GNUNET_new (struct TALER_EXCHANGEDB_DepositListEntry); { struct GNUNET_PQ_ResultSpec rs[] = { TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", @@ -4339,24 +4340,12 @@ add_coin_deposit (void *cls, chc->status = GNUNET_DB_STATUS_HARD_ERROR; return; } - deposit->coin.coin_pub = *chc->coin_pub; } tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList); tl->next = chc->head; tl->type = TALER_EXCHANGEDB_TT_DEPOSIT; tl->details.deposit = deposit; tl->serial_id = serial_id; - qs = postgres_get_known_coin (chc->db_cls, - chc->session, - chc->coin_pub, - &deposit->coin); - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) - { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - GNUNET_free (deposit); - chc->status = qs; - return; - } chc->head = tl; } } @@ -4380,21 +4369,20 @@ add_coin_melt (void *cls, for (unsigned int i = 0; i<num_results; i++) { - struct TALER_EXCHANGEDB_RefreshMelt *melt; + struct TALER_EXCHANGEDB_RefreshMeltListEntry *melt; struct TALER_EXCHANGEDB_TransactionList *tl; - enum GNUNET_DB_QueryStatus qs; uint64_t serial_id; - melt = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt); + melt = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMeltListEntry); { struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("rc", - &melt->session.rc), + &melt->rc), /* oldcoin_index not needed */ GNUNET_PQ_result_spec_auto_from_type ("old_coin_sig", - &melt->session.coin_sig), + &melt->coin_sig), TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", - &melt->session.amount_with_fee), + &melt->amount_with_fee), TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh", &melt->melt_fee), GNUNET_PQ_result_spec_uint64 ("melt_serial_id", @@ -4412,25 +4400,12 @@ add_coin_melt (void *cls, chc->status = GNUNET_DB_STATUS_HARD_ERROR; return; } - melt->session.coin.coin_pub = *chc->coin_pub; } tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList); tl->next = chc->head; tl->type = TALER_EXCHANGEDB_TT_REFRESH_MELT; tl->details.melt = melt; tl->serial_id = serial_id; - /* FIXME: integrate via JOIN in main select, instead of using separate query */ - qs = postgres_get_known_coin (chc->db_cls, - chc->session, - chc->coin_pub, - &melt->session.coin); - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) - { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - GNUNET_free (melt); - chc->status = qs; - return; - } chc->head = tl; } } @@ -4454,12 +4429,11 @@ add_coin_refund (void *cls, for (unsigned int i = 0; i<num_results; i++) { - struct TALER_EXCHANGEDB_Refund *refund; + struct TALER_EXCHANGEDB_RefundListEntry *refund; struct TALER_EXCHANGEDB_TransactionList *tl; - enum GNUNET_DB_QueryStatus qs; uint64_t serial_id; - refund = GNUNET_new (struct TALER_EXCHANGEDB_Refund); + refund = GNUNET_new (struct TALER_EXCHANGEDB_RefundListEntry); { struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("merchant_pub", @@ -4489,24 +4463,12 @@ add_coin_refund (void *cls, chc->status = GNUNET_DB_STATUS_HARD_ERROR; return; } - refund->coin.coin_pub = *chc->coin_pub; } tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList); tl->next = chc->head; tl->type = TALER_EXCHANGEDB_TT_REFUND; tl->details.refund = refund; tl->serial_id = serial_id; - qs = postgres_get_known_coin (chc->db_cls, - chc->session, - chc->coin_pub, - &refund->coin); - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) - { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - GNUNET_free (refund); - chc->status = qs; - return; - } chc->head = tl; } } @@ -4530,11 +4492,11 @@ add_old_coin_payback (void *cls, for (unsigned int i = 0; i<num_results; i++) { - struct TALER_EXCHANGEDB_PaybackRefresh *payback; + struct TALER_EXCHANGEDB_PaybackRefreshListEntry *payback; struct TALER_EXCHANGEDB_TransactionList *tl; uint64_t serial_id; - payback = GNUNET_new (struct TALER_EXCHANGEDB_PaybackRefresh); + payback = GNUNET_new (struct TALER_EXCHANGEDB_PaybackRefreshListEntry); { struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("coin_pub", @@ -4597,28 +4559,23 @@ add_coin_payback (void *cls, for (unsigned int i = 0; i<num_results; i++) { - struct TALER_EXCHANGEDB_Payback *payback; + struct TALER_EXCHANGEDB_PaybackListEntry *payback; struct TALER_EXCHANGEDB_TransactionList *tl; uint64_t serial_id; - payback = GNUNET_new (struct TALER_EXCHANGEDB_Payback); + payback = GNUNET_new (struct TALER_EXCHANGEDB_PaybackListEntry); { struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", - &payback->value), GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &payback->reserve_pub), - GNUNET_PQ_result_spec_auto_from_type ("coin_blind", - &payback->coin_blind), GNUNET_PQ_result_spec_auto_from_type ("coin_sig", &payback->coin_sig), + GNUNET_PQ_result_spec_auto_from_type ("coin_blind", + &payback->coin_blind), + TALER_PQ_RESULT_SPEC_AMOUNT ("amount", + &payback->value), TALER_PQ_result_spec_absolute_time ("timestamp", &payback->timestamp), - GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", - &payback->coin.denom_pub_hash), - GNUNET_PQ_result_spec_rsa_signature ("denom_sig", - &payback->coin.denom_sig. - rsa_signature), GNUNET_PQ_result_spec_uint64 ("payback_uuid", &serial_id), GNUNET_PQ_result_spec_end @@ -4634,7 +4591,6 @@ add_coin_payback (void *cls, chc->status = GNUNET_DB_STATUS_HARD_ERROR; return; } - payback->coin.coin_pub = *chc->coin_pub; } tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList); tl->next = chc->head; @@ -4664,11 +4620,11 @@ add_coin_payback_refresh (void *cls, for (unsigned int i = 0; i<num_results; i++) { - struct TALER_EXCHANGEDB_PaybackRefresh *payback; + struct TALER_EXCHANGEDB_PaybackRefreshListEntry *payback; struct TALER_EXCHANGEDB_TransactionList *tl; uint64_t serial_id; - payback = GNUNET_new (struct TALER_EXCHANGEDB_PaybackRefresh); + payback = GNUNET_new (struct TALER_EXCHANGEDB_PaybackRefreshListEntry); { struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("old_coin_pub", @@ -6066,19 +6022,19 @@ refunds_serial_helper_cb (void *cls, uint64_t rowid; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("merchant_pub", - &refund.merchant_pub), + &refund.details.merchant_pub), GNUNET_PQ_result_spec_auto_from_type ("merchant_sig", - &refund.merchant_sig), + &refund.details.merchant_sig), GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms", - &refund.h_contract_terms), + &refund.details.h_contract_terms), GNUNET_PQ_result_spec_uint64 ("rtransaction_id", - &refund.rtransaction_id), + &refund.details.rtransaction_id), GNUNET_PQ_result_spec_rsa_public_key ("denom_pub", &denom_pub.rsa_public_key), GNUNET_PQ_result_spec_auto_from_type ("coin_pub", &refund.coin.coin_pub), TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", - &refund.refund_amount), + &refund.details.refund_amount), GNUNET_PQ_result_spec_uint64 ("refund_serial_id", &rowid), GNUNET_PQ_result_spec_end @@ -6098,11 +6054,11 @@ refunds_serial_helper_cb (void *cls, rowid, &denom_pub, &refund.coin.coin_pub, - &refund.merchant_pub, - &refund.merchant_sig, - &refund.h_contract_terms, - refund.rtransaction_id, - &refund.refund_amount); + &refund.details.merchant_pub, + &refund.details.merchant_sig, + &refund.details.h_contract_terms, + refund.details.rtransaction_id, + &refund.details.refund_amount); GNUNET_PQ_cleanup_result (rs); if (GNUNET_OK != ret) break; diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 73d89e0b2..e9fe67b43 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -1432,36 +1432,36 @@ check_refund_cb (void *cls, const struct TALER_EXCHANGEDB_Refund *refund = cls; if (0 != GNUNET_memcmp (merchant_pub, - &refund->merchant_pub)) + &refund->details.merchant_pub)) { GNUNET_break (0); result = 66; } if (0 != GNUNET_memcmp (merchant_sig, - &refund->merchant_sig)) + &refund->details.merchant_sig)) { GNUNET_break (0); result = 66; } if (0 != GNUNET_memcmp (h_contract, - &refund->h_contract_terms)) + &refund->details.h_contract_terms)) { GNUNET_break (0); result = 66; } - if (rtransaction_id != refund->rtransaction_id) + if (rtransaction_id != refund->details.rtransaction_id) { GNUNET_break (0); result = 66; } if (0 != TALER_amount_cmp (amount_with_fee, - &refund->refund_amount)) + &refund->details.refund_amount)) { GNUNET_break (0); result = 66; } if (0 != TALER_amount_cmp (refund_fee, - &refund->refund_fee)) + &refund->details.refund_fee)) { GNUNET_break (0); result = 66; @@ -1925,7 +1925,10 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->test_deposit_done (plugin->cls, session, - &deposit)); + &deposit.coin.coin_pub, + &deposit.merchant_pub, + &deposit.h_contract_terms, + &deposit.h_wire)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->mark_deposit_done (plugin->cls, session, @@ -1936,7 +1939,10 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->test_deposit_done (plugin->cls, session, - &deposit)); + &deposit.coin.coin_pub, + &deposit.merchant_pub, + &deposit.h_contract_terms, + &deposit.h_wire)); result = 10; deposit2 = deposit; @@ -1966,13 +1972,14 @@ run (void *cls) /* test insert_refund! */ refund.coin = deposit.coin; - refund.merchant_pub = deposit.merchant_pub; - RND_BLK (&refund.merchant_sig); - refund.h_contract_terms = deposit.h_contract_terms; - refund.rtransaction_id = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX); - refund.refund_amount = deposit.amount_with_fee; - refund.refund_fee = fee_refund; + refund.details.merchant_pub = deposit.merchant_pub; + RND_BLK (&refund.details.merchant_sig); + refund.details.h_contract_terms = deposit.h_contract_terms; + refund.details.rtransaction_id + = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, + UINT64_MAX); + refund.details.refund_amount = deposit.amount_with_fee; + refund.details.refund_fee = fee_refund; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_refund (plugin->cls, session, @@ -2064,11 +2071,8 @@ run (void *cls) { case TALER_EXCHANGEDB_TT_DEPOSIT: { - struct TALER_EXCHANGEDB_Deposit *have = tlp->details.deposit; + struct TALER_EXCHANGEDB_DepositListEntry *have = tlp->details.deposit; - FAILIF (0 != memcmp (&have->coin.coin_pub, - &deposit.coin.coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP))); /* Note: we're not comparing the denomination keys, as there is still the question of whether we should even bother exporting them here. */ @@ -2108,31 +2112,29 @@ run (void *cls) #endif case TALER_EXCHANGEDB_TT_REFUND: { - struct TALER_EXCHANGEDB_Refund *have = tlp->details.refund; + struct TALER_EXCHANGEDB_RefundListEntry *have = tlp->details.refund; - FAILIF (0 != memcmp (&have->coin.coin_pub, - &refund.coin.coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP))); /* Note: we're not comparing the denomination keys, as there is still the question of whether we should even bother exporting them here. */ FAILIF (0 != GNUNET_memcmp (&have->merchant_pub, - &refund.merchant_pub)); + &refund.details.merchant_pub)); FAILIF (0 != GNUNET_memcmp (&have->merchant_sig, - &refund.merchant_sig)); + &refund.details.merchant_sig)); FAILIF (0 != GNUNET_memcmp (&have->h_contract_terms, - &refund.h_contract_terms)); - FAILIF (have->rtransaction_id != refund.rtransaction_id); + &refund.details.h_contract_terms)); + FAILIF (have->rtransaction_id != refund.details.rtransaction_id); FAILIF (0 != TALER_amount_cmp (&have->refund_amount, - &refund.refund_amount)); + &refund.details.refund_amount)); FAILIF (0 != TALER_amount_cmp (&have->refund_fee, - &refund.refund_fee)); + &refund.details.refund_fee)); matched |= 4; break; } case TALER_EXCHANGEDB_TT_PAYBACK: { - struct TALER_EXCHANGEDB_Payback *payback = tlp->details.payback; + struct TALER_EXCHANGEDB_PaybackListEntry *payback = + tlp->details.payback; FAILIF (0 != GNUNET_memcmp (&payback->coin_sig, &coin_sig)); @@ -2140,9 +2142,6 @@ run (void *cls) &coin_blind)); FAILIF (0 != GNUNET_memcmp (&payback->reserve_pub, &reserve_pub)); - FAILIF (0 != memcmp (&payback->coin.coin_pub, - &deposit.coin.coin_pub, - sizeof (deposit.coin.coin_pub))); FAILIF (0 != TALER_amount_cmp (&payback->value, &value)); matched |= 8; |