diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-01-08 23:36:09 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-01-08 23:36:09 +0100 |
commit | 260e287685680d97448920432b4673469a99a83f (patch) | |
tree | c06e99b6724f8ca2d2a815d1c95f80dd4a4bec53 /src/exchangedb | |
parent | db61628a9cffbfc4e33e0f0094039c71ef7b96be (diff) | |
download | exchange-260e287685680d97448920432b4673469a99a83f.tar.xz |
change wire_reference to be uint64_t always; more work on lrbt_callbacks
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/lrbt_callbacks.c | 134 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_common.c | 1 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 62 |
3 files changed, 189 insertions, 8 deletions
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; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + GNUNET_PQ_result_spec_rsa_public_key ( + "denom_pub", + &td.details.denominations.denom_pub.rsa_public_key), + GNUNET_PQ_result_spec_auto_from_type ("master_sig", + &td.details.denominations.master_sig), + TALER_PQ_result_spec_absolute_time ("valid_from", + &td.details.denominations.valid_from), + TALER_PQ_result_spec_absolute_time ("expire_withdraw", + &td.details.denominations. + expire_withdraw), + TALER_PQ_result_spec_absolute_time ("expire_deposit", + &td.details.denominations. + expire_deposit), + TALER_PQ_result_spec_absolute_time ("expire_legal", + &td.details.denominations.expire_legal), + TALER_PQ_RESULT_SPEC_AMOUNT ("coin", + &td.details.denominations.coin), + TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw", + &td.details.denominations.fee_withdraw), + TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit", + &td.details.denominations.fee_deposit), + TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh", + &td.details.denominations.fee_refresh), + TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund", + &td.details.denominations.fee_refund), GNUNET_PQ_result_spec_end }; @@ -84,6 +112,14 @@ lrbt_cb_table_denomination_revocations (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "denom_pub_hash", + &td.details.denomination_revocations.denom_pub_hash), + GNUNET_PQ_result_spec_auto_from_type ( + "master_sig", + &td.details.denomination_revocations.master_sig), GNUNET_PQ_result_spec_end }; @@ -116,6 +152,7 @@ lrbt_cb_table_reserves (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; 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; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", + &td.details.reserves.reserve_pub), + GNUNET_PQ_result_spec_string ("account_details", + &td.details.reserves.account_details), + TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance", + &td.details.reserves.current_balance), + TALER_PQ_result_spec_absolute_time ("expiration_date", + &td.details.reserves.expiration_date), + TALER_PQ_result_spec_absolute_time ("gc_date", + &td.details.reserves.gc_date), GNUNET_PQ_result_spec_end }; @@ -155,6 +204,7 @@ lrbt_cb_table_reserves_in (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; 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; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + GNUNET_PQ_result_spec_uint64 ("wire_reference", + &td.details.reserves_in.wire_reference), + TALER_PQ_RESULT_SPEC_AMOUNT ("credit", + &td.details.reserves_in.credit), + GNUNET_PQ_result_spec_string ("sender_account_details", + &td.details.reserves_in. + sender_account_details), + GNUNET_PQ_result_spec_string ("exchange_account_section", + &td.details.reserves_in. + exchange_account_section), + TALER_PQ_result_spec_absolute_time ("execution_date", + &td.details.reserves_in.execution_date), + GNUNET_PQ_result_spec_uint64 ("reserve_uuid", + &td.details.reserves_in.reserve_uuid), GNUNET_PQ_result_spec_end }; @@ -194,6 +260,7 @@ lrbt_cb_table_reserves_close (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; 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; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + TALER_PQ_result_spec_absolute_time ( + "execution_date", + &td.details.reserves_close.execution_date), + GNUNET_PQ_result_spec_auto_from_type ("wtid", + &td.details.reserves_close.wtid), + GNUNET_PQ_result_spec_string ( + "receiver_account", + &td.details.reserves_close.receiver_account), + TALER_PQ_RESULT_SPEC_AMOUNT ("amount", + &td.details.reserves_close.amount), + TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee", + &td.details.reserves_close.closing_fee), + GNUNET_PQ_result_spec_uint64 ("reserve_uuid", + &td.details.reserves_close.reserve_uuid), + GNUNET_PQ_result_spec_end }; @@ -233,6 +317,7 @@ lrbt_cb_table_reserves_out (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; 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; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ("h_blind_ev", + &td.details.reserves_out.h_blind_ev), + GNUNET_PQ_result_spec_rsa_signature ( + "denom_sig", + &td.details.reserves_out.denom_sig.rsa_signature), + GNUNET_PQ_result_spec_auto_from_type ("reserve_sig", + &td.details.reserves_out.reserve_sig), + TALER_PQ_result_spec_absolute_time ( + "execution_date", + &td.details.reserves_out.execution_date), + TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", + &td.details.reserves_out.amount_with_fee), + GNUNET_PQ_result_spec_uint64 ("reserve_uuid", + &td.details.reserves_out.reserve_uuid), + GNUNET_PQ_result_spec_uint64 ("denominations_serial", + &td.details.reserves_out. + denominations_serial), GNUNET_PQ_result_spec_end }; @@ -279,6 +383,8 @@ lrbt_cb_table_auditors (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -318,6 +424,8 @@ lrbt_cb_table_auditor_denom_sigs (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -357,6 +465,8 @@ lrbt_cb_table_exchange_sign_keys (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -396,6 +506,8 @@ lrbt_cb_table_signkey_revocations (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -435,6 +547,8 @@ lrbt_cb_table_known_coins (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -474,6 +588,8 @@ lrbt_cb_table_refresh_commitments (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -513,6 +629,8 @@ lrbt_cb_table_refresh_revealed_coins (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -552,6 +670,8 @@ lrbt_cb_table_refresh_transfer_keys (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -591,6 +711,8 @@ lrbt_cb_table_deposits (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -630,6 +752,8 @@ lrbt_cb_table_refunds (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -669,6 +793,8 @@ lrbt_cb_table_wire_out (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -708,6 +834,8 @@ lrbt_cb_table_aggregation_tracking (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -747,6 +875,8 @@ lrbt_cb_table_wire_fee (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -786,6 +916,8 @@ lrbt_cb_table_recoup (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; @@ -825,6 +957,8 @@ lrbt_cb_table_recoup_refresh (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), GNUNET_PQ_result_spec_end }; diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c index 6db0c0e02..fb697dae8 100644 --- a/src/exchangedb/plugin_exchangedb_common.c +++ b/src/exchangedb/plugin_exchangedb_common.c @@ -41,7 +41,6 @@ common_free_reserve_history (void *cls, bt = rh->details.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 }; |