From 260e287685680d97448920432b4673469a99a83f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 8 Jan 2021 23:36:09 +0100 Subject: change wire_reference to be uint64_t always; more work on lrbt_callbacks --- src/exchange/taler-exchange-httpd_responses.c | 5 +- src/exchangedb/lrbt_callbacks.c | 134 +++++++++++++++++++++ src/exchangedb/plugin_exchangedb_common.c | 1 - src/exchangedb/plugin_exchangedb_postgres.c | 62 ++++++++-- src/include/taler_exchange_service.h | 7 +- src/include/taler_exchangedb_plugin.h | 9 +- src/lib/exchange_api_common.c | 12 +- .../testing_api_cmd_bank_admin_add_incoming.c | 10 +- src/testing/testing_api_cmd_status.c | 7 +- 9 files changed, 200 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index ba050e9f7..ea9729af0 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -511,7 +511,7 @@ TEH_RESPONSE_compile_reserve_history ( if (0 != json_array_append_new ( json_history, - json_pack ("{s:s, s:o, s:s, s:o, s:o}", + json_pack ("{s:s, s:o, s:s, s:I, s:o}", "type", "CREDIT", "timestamp", @@ -519,8 +519,7 @@ TEH_RESPONSE_compile_reserve_history ( "sender_account_url", bank->sender_account_details, "wire_reference", - GNUNET_JSON_from_data (bank->wire_reference, - bank->wire_reference_size), + (json_int_t) bank->wire_reference, "amount", TALER_JSON_from_amount (&bank->amount)))) { diff --git a/src/exchangedb/lrbt_callbacks.c b/src/exchangedb/lrbt_callbacks.c index 71bc2ae7a..e2dbe99a3 100644 --- a/src/exchangedb/lrbt_callbacks.c +++ b/src/exchangedb/lrbt_callbacks.c @@ -38,6 +38,7 @@ lrbt_cb_table_denominations (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_DENOMINATIONS }; @@ -45,6 +46,33 @@ lrbt_cb_table_denominations (void *cls, for (unsigned int i = 0; ipg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_RESERVES }; @@ -123,6 +160,18 @@ lrbt_cb_table_reserves (void *cls, for (unsigned int i = 0; ipg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_RESERVES_IN }; @@ -162,6 +212,22 @@ lrbt_cb_table_reserves_in (void *cls, for (unsigned int i = 0; ipg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_RESERVES_CLOSE }; @@ -201,6 +268,23 @@ lrbt_cb_table_reserves_close (void *cls, for (unsigned int i = 0; ipg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_RESERVES_OUT }; @@ -240,6 +325,25 @@ lrbt_cb_table_reserves_out (void *cls, for (unsigned int i = 0; idetails.bank; GNUNET_free (bt->sender_account_details); - GNUNET_free (bt->wire_reference); GNUNET_free (bt); break; } diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 9cd4ad734..6d8e72732 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -2056,18 +2056,45 @@ postgres_get_session (void *cls) GNUNET_PQ_make_prepare ("select_above_serial_by_table_deposits", "SELECT" " deposit_serial_id AS serial" + ",amount_with_fee_val" + ",amount_with_fee_frac" + ",wallet_timestamp" + ",exchange_timestamp" + ",refund_deadline" + ",wire_deadline" + ",merchant_pub" + ",h_contract_terms" + ",h_wire" + ",coin_sig" + ",wire" + ",tiny" + ",done" + ",known_coin_id" " FROM deposits" " ORDER BY deposit_serial_id ASC;", 0), GNUNET_PQ_make_prepare ("select_above_serial_by_table_refunds", "SELECT" " refund_serial_id AS serial" + ",merchant_pub" + ",merchant_sig" + ",h_contract_terms" + ",rtransaction_id" + ",amount_with_fee_val" + ",amount_with_fee_frac" + ",known_coin_id" " FROM refunds" " ORDER BY refund_serial_id ASC;", 0), GNUNET_PQ_make_prepare ("select_above_serial_by_table_wire_out", "SELECT" " wireout_uuid AS serial" + ",execution_date" + ",wtid_raw" + ",wire_target" + ",exchange_account_section" + ",amount_val" + ",amount_frac" " FROM wire_out" " ORDER BY wireout_uuid ASC;", 0), @@ -2075,29 +2102,51 @@ postgres_get_session (void *cls) "select_above_serial_by_table_aggregation_tracking", "SELECT" " aggregation_serial_id AS serial" + ",deposit_serial_id" + ",wtid_raw" " FROM aggregation_tracking" " ORDER BY aggregation_serial_id ASC;", 0), GNUNET_PQ_make_prepare ("select_above_serial_by_table_wire_fee", "SELECT" " wire_fee_serial AS serial" + ",wire_method" + ",start_date" + ",end_date" + ",wire_fee_val" + ",wire_fee_frac" + ",closing_fee_val" + ",closing_fee_frac" + ",master_sig" " FROM wire_fee" " ORDER BY wire_fee_serial ASC;", 0), GNUNET_PQ_make_prepare ("select_above_serial_by_table_recoup", "SELECT" " recoup_uuid AS serial" + ",coin_sig" + ",coin_blind" + ",amount_val" + ",amount_frac" + ",timestamp" + ",known_coin_id" + ",reserve_out_serial_id" " FROM recoup" " ORDER BY recoup_uuid ASC;", 0), GNUNET_PQ_make_prepare ("select_above_serial_by_table_recoup_refresh", "SELECT" " recoup_refresh_uuid AS serial" + ",coin_sig" + ",coin_blind" + ",amount_val" + ",amount_frac" + ",timestamp" + ",known_coin_id" + ",rrc_serial" " FROM recoup_refresh" " ORDER BY recoup_refresh_uuid ASC;", 0), - - // FIXME... /* For postgres_insert_records_by_table */ // FIXME... GNUNET_PQ_PREPARED_STATEMENT_END @@ -3432,9 +3481,8 @@ add_bank_to_exchange (void *cls, bt = GNUNET_new (struct TALER_EXCHANGEDB_BankTransfer); { struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_variable_size ("wire_reference", - &bt->wire_reference, - &bt->wire_reference_size), + GNUNET_PQ_result_spec_uint64 ("wire_reference", + &bt->wire_reference), TALER_PQ_RESULT_SPEC_AMOUNT ("credit", &bt->amount), TALER_PQ_result_spec_absolute_time ("execution_date", @@ -9534,7 +9582,7 @@ struct LookupRecordsByTableContext /** * Plugin context. */ - struct PostgresClosure *pc; + struct PostgresClosure *pg; /** * Function to call with the results. @@ -9583,7 +9631,7 @@ postgres_lookup_records_by_table (void *cls, GNUNET_PQ_query_param_end }; struct LookupRecordsByTableContext ctx = { - .pc = pc, + .pg = pc, .cb = cb, .cb_cls = cb_cls }; diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 557348dd5..98af4f9f3 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -1027,18 +1027,13 @@ struct TALER_EXCHANGE_ReserveHistory /** * Information that uniquely identifies the wire transfer. */ - void *wire_reference; + uint64_t wire_reference; /** * When did the wire transfer happen? */ struct GNUNET_TIME_Absolute timestamp; - /** - * Number of bytes stored in @e wire_reference. - */ - size_t wire_reference_size; - } in_details; /** diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index d713e52d6..e26a20960 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -186,12 +186,12 @@ struct TALER_EXCHANGEDB_TableData struct { struct GNUNET_HashCode h_blind_ev; - struct GNUNET_HashCode denom_pub_hash; // FIXME struct TALER_DenominationSignature denom_sig; struct TALER_ReserveSignatureP reserve_sig; struct GNUNET_TIME_Absolute execution_date; struct TALER_Amount amount_with_fee; uint64_t reserve_uuid; + uint64_t denominations_serial; } reserves_out; struct {} auditors; @@ -287,12 +287,7 @@ struct TALER_EXCHANGEDB_BankTransfer /** * Data uniquely identifying the wire transfer (wire transfer-type specific) */ - void *wire_reference; - - /** - * Number of bytes in @e wire_reference. - */ - size_t wire_reference_size; + uint64_t wire_reference; }; diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 3591a7bbc..82604e0b1 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -101,14 +101,11 @@ TALER_EXCHANGE_parse_reserve_history ( "CREDIT")) { const char *wire_url; - void *wire_reference; - size_t wire_reference_size; + uint64_t wire_reference; struct GNUNET_TIME_Absolute timestamp; - struct GNUNET_JSON_Specification withdraw_spec[] = { - GNUNET_JSON_spec_varsize ("wire_reference", - &wire_reference, - &wire_reference_size), + GNUNET_JSON_spec_uint64 ("wire_reference", + &wire_reference), TALER_JSON_spec_absolute_time ("timestamp", ×tamp), GNUNET_JSON_spec_string ("sender_account_url", @@ -136,8 +133,6 @@ TALER_EXCHANGE_parse_reserve_history ( } rh->details.in_details.sender_url = GNUNET_strdup (wire_url); rh->details.in_details.wire_reference = wire_reference; - rh->details.in_details.wire_reference_size = - wire_reference_size; rh->details.in_details.timestamp = timestamp; /* end type==DEPOSIT */ } @@ -425,7 +420,6 @@ TALER_EXCHANGE_free_reserve_history ( switch (rhistory[i].type) { case TALER_EXCHANGE_RTT_CREDIT: - GNUNET_free (rhistory[i].details.in_details.wire_reference); GNUNET_free (rhistory[i].details.in_details.sender_url); break; case TALER_EXCHANGE_RTT_WITHDRAWAL: diff --git a/src/testing/testing_api_cmd_bank_admin_add_incoming.c b/src/testing/testing_api_cmd_bank_admin_add_incoming.c index df1eb0a32..e467063aa 100644 --- a/src/testing/testing_api_cmd_bank_admin_add_incoming.c +++ b/src/testing/testing_api_cmd_bank_admin_add_incoming.c @@ -114,11 +114,6 @@ struct AdminAddIncomingState */ uint64_t serial_id; - /** - * Set to the wire transfer's row ID in network byte order. - */ - uint64_t row_id_nbo; - /** * Timestamp of the transaction (as returned from the bank). */ @@ -214,11 +209,8 @@ confirmation_cb (void *cls, struct TALER_TESTING_Interpreter *is = fts->is; (void) json; - fts->row_id_nbo = GNUNET_htonll (serial_id); fts->reserve_history.details.in_details.timestamp = timestamp; - fts->reserve_history.details.in_details.wire_reference = &fts->row_id_nbo; - fts->reserve_history.details.in_details.wire_reference_size - = sizeof (fts->row_id_nbo); + fts->reserve_history.details.in_details.wire_reference = serial_id; fts->aih = NULL; switch (http_status) { diff --git a/src/testing/testing_api_cmd_status.c b/src/testing/testing_api_cmd_status.c index 26c1b813b..f395af28a 100644 --- a/src/testing/testing_api_cmd_status.c +++ b/src/testing/testing_api_cmd_status.c @@ -84,13 +84,10 @@ history_entry_cmp (const struct TALER_EXCHANGE_ReserveHistory *h1, if ( (0 == TALER_amount_cmp (&h1->amount, &h2->amount)) && - (h1->details.in_details.wire_reference_size == - h2->details.in_details.wire_reference_size) && (0 == strcasecmp (h1->details.in_details.sender_url, h2->details.in_details.sender_url)) && - (0 == memcmp (h1->details.in_details.wire_reference, - h2->details.in_details.wire_reference, - h1->details.in_details.wire_reference_size)) && + (h1->details.in_details.wire_reference == + h2->details.in_details.wire_reference) && (h1->details.in_details.timestamp.abs_value_us == h2->details.in_details.timestamp.abs_value_us) ) return 0; -- cgit v1.2.3