2015-01-08 18:37:20 +01:00
|
|
|
/*
|
2022-01-08 14:40:20 +01:00
|
|
|
This file is part of TALER
|
2022-02-17 15:10:14 +01:00
|
|
|
Copyright (C) 2014--2022 Taler Systems SA
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2022-01-08 14:40:20 +01:00
|
|
|
TALER is free software; you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 3, or (at your option) any later version.
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2022-01-08 14:40:20 +01:00
|
|
|
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2022-01-08 14:40:20 +01:00
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
2015-08-13 23:16:31 +02:00
|
|
|
|
2015-01-08 18:37:20 +01:00
|
|
|
/**
|
2016-03-01 15:35:04 +01:00
|
|
|
* @file plugin_exchangedb_postgres.c
|
|
|
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
2015-01-08 18:37:20 +01:00
|
|
|
* @author Florian Dold
|
2015-01-28 22:35:57 +01:00
|
|
|
* @author Christian Grothoff
|
2015-03-05 16:05:06 +01:00
|
|
|
* @author Sree Harsha Totakura
|
2016-10-18 12:34:57 +02:00
|
|
|
* @author Marcello Stanisci
|
2015-01-08 18:37:20 +01:00
|
|
|
*/
|
|
|
|
#include "platform.h"
|
2017-11-27 23:42:17 +01:00
|
|
|
#include "taler_error_codes.h"
|
2021-08-22 12:25:48 +02:00
|
|
|
#include "taler_dbevents.h"
|
2015-03-27 19:58:40 +01:00
|
|
|
#include "taler_pq_lib.h"
|
2021-11-09 20:36:30 +01:00
|
|
|
#include "taler_util.h"
|
2021-01-10 21:42:25 +01:00
|
|
|
#include "taler_json_lib.h"
|
2016-03-01 15:35:04 +01:00
|
|
|
#include "taler_exchangedb_plugin.h"
|
2022-10-13 22:43:22 +02:00
|
|
|
#include "plugin_exchangedb_common.h"
|
2022-11-07 16:35:34 +01:00
|
|
|
#include "pg_delete_aggregation_transient.h"
|
|
|
|
#include "pg_get_link_data.h"
|
2022-10-03 12:46:30 +02:00
|
|
|
#include "pg_helper.h"
|
2022-10-12 14:48:49 +02:00
|
|
|
#include "pg_do_reserve_open.h"
|
2022-11-08 13:34:53 +01:00
|
|
|
#include "pg_do_withdraw.h"
|
2022-10-13 22:43:22 +02:00
|
|
|
#include "pg_get_coin_transactions.h"
|
2022-10-13 19:07:25 +02:00
|
|
|
#include "pg_get_expired_reserves.h"
|
2022-11-08 13:28:17 +01:00
|
|
|
#include "pg_get_purse_request.h"
|
2022-10-15 16:19:14 +02:00
|
|
|
#include "pg_get_reserve_history.h"
|
2022-10-13 19:07:25 +02:00
|
|
|
#include "pg_get_unfinished_close_requests.h"
|
2022-10-03 12:46:30 +02:00
|
|
|
#include "pg_insert_close_request.h"
|
2022-10-08 18:07:05 +02:00
|
|
|
#include "pg_insert_records_by_table.h"
|
2022-10-03 12:46:30 +02:00
|
|
|
#include "pg_insert_reserve_open_deposit.h"
|
2022-10-03 23:54:12 +02:00
|
|
|
#include "pg_iterate_kyc_reference.h"
|
|
|
|
#include "pg_iterate_reserve_close_info.h"
|
2022-10-08 21:09:13 +02:00
|
|
|
#include "pg_lookup_records_by_table.h"
|
2022-10-10 08:20:36 +02:00
|
|
|
#include "pg_lookup_serial_by_table.h"
|
2022-11-02 12:17:05 +01:00
|
|
|
#include "pg_select_account_merges_above_serial_id.h"
|
|
|
|
#include "pg_select_all_purse_decisions_above_serial_id.h"
|
|
|
|
#include "pg_select_purse.h"
|
|
|
|
#include "pg_select_purse_deposits_above_serial_id.h"
|
|
|
|
#include "pg_select_purse_merges_above_serial_id.h"
|
|
|
|
#include "pg_select_purse_requests_above_serial_id.h"
|
2022-10-03 23:54:12 +02:00
|
|
|
#include "pg_select_reserve_close_info.h"
|
2022-10-30 17:36:57 +01:00
|
|
|
#include "pg_select_reserve_closed_above_serial_id.h"
|
|
|
|
#include "pg_select_reserve_open_above_serial_id.h"
|
2021-08-13 22:35:13 +02:00
|
|
|
#include <poll.h>
|
2015-01-08 18:37:20 +01:00
|
|
|
#include <pthread.h>
|
2015-03-20 23:51:28 +01:00
|
|
|
#include <libpq-fe.h>
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2022-12-05 10:53:24 +01:00
|
|
|
/**NEW INCLUDES**/
|
2022-11-08 13:28:17 +01:00
|
|
|
#include "pg_insert_purse_request.h"
|
2022-11-08 15:21:01 +01:00
|
|
|
#include "pg_iterate_active_signkeys.h"
|
2022-11-10 16:37:28 +01:00
|
|
|
#include "pg_preflight.h"
|
2022-11-08 15:21:01 +01:00
|
|
|
#include "pg_commit.h"
|
2022-11-08 17:40:47 +01:00
|
|
|
#include "pg_insert_aggregation_tracking.h"
|
|
|
|
#include "pg_drop_tables.h"
|
2022-11-10 16:37:28 +01:00
|
|
|
#include "pg_select_satisfied_kyc_processes.h"
|
|
|
|
#include "pg_select_aggregation_amounts_for_kyc_check.h"
|
|
|
|
#include "pg_kyc_provider_account_lookup.h"
|
|
|
|
#include "pg_lookup_kyc_requirement_by_row.h"
|
|
|
|
#include "pg_insert_kyc_requirement_for_account.h"
|
|
|
|
#include "pg_lookup_kyc_process_by_account.h"
|
|
|
|
#include "pg_update_kyc_process_by_row.h"
|
|
|
|
#include "pg_insert_kyc_requirement_process.h"
|
|
|
|
#include "pg_select_withdraw_amounts_for_kyc_check.h"
|
|
|
|
#include "pg_select_merge_amounts_for_kyc_check.h"
|
|
|
|
#include "pg_profit_drains_set_finished.h"
|
|
|
|
#include "pg_profit_drains_get_pending.h"
|
|
|
|
#include "pg_get_drain_profit.h"
|
|
|
|
#include "pg_get_purse_deposit.h"
|
|
|
|
#include "pg_insert_contract.h"
|
|
|
|
#include "pg_select_contract.h"
|
|
|
|
#include "pg_select_purse_merge.h"
|
|
|
|
#include "pg_select_contract_by_purse.h"
|
|
|
|
#include "pg_insert_drain_profit.h"
|
|
|
|
#include "pg_do_reserve_purse.h"
|
|
|
|
#include "pg_lookup_global_fee_by_time.h"
|
|
|
|
#include "pg_do_purse_deposit.h"
|
|
|
|
#include "pg_activate_signing_key.h"
|
|
|
|
#include "pg_update_auditor.h"
|
|
|
|
#include "pg_begin_revolving_shard.h"
|
|
|
|
#include "pg_get_extension_manifest.h"
|
|
|
|
#include "pg_insert_history_request.h"
|
|
|
|
#include "pg_do_purse_merge.h"
|
|
|
|
#include "pg_start_read_committed.h"
|
|
|
|
#include "pg_start_read_only.h"
|
|
|
|
#include "pg_insert_denomination_info.h"
|
|
|
|
#include "pg_do_batch_withdraw_insert.h"
|
|
|
|
#include "pg_lookup_wire_fee_by_time.h"
|
|
|
|
#include "pg_start.h"
|
|
|
|
#include "pg_rollback.h"
|
2022-11-14 13:35:56 +01:00
|
|
|
#include "pg_create_tables.h"
|
|
|
|
#include "pg_event_listen.h"
|
|
|
|
#include "pg_event_listen_cancel.h"
|
|
|
|
#include "pg_event_notify.h"
|
|
|
|
#include "pg_get_denomination_info.h"
|
|
|
|
#include "pg_iterate_denomination_info.h"
|
|
|
|
#include "pg_iterate_denominations.h"
|
|
|
|
#include "pg_iterate_active_auditors.h"
|
|
|
|
#include "pg_iterate_auditor_denominations.h"
|
|
|
|
#include "pg_reserves_get.h"
|
|
|
|
#include "pg_reserves_get_origin.h"
|
|
|
|
#include "pg_drain_kyc_alert.h"
|
|
|
|
#include "pg_reserves_in_insert.h"
|
|
|
|
#include "pg_get_withdraw_info.h"
|
|
|
|
#include "pg_do_batch_withdraw.h"
|
|
|
|
#include "pg_get_policy_details.h"
|
|
|
|
#include "pg_persist_policy_details.h"
|
|
|
|
#include "pg_do_deposit.h"
|
|
|
|
#include "pg_add_policy_fulfillment_proof.h"
|
|
|
|
#include "pg_do_melt.h"
|
|
|
|
#include "pg_do_refund.h"
|
|
|
|
#include "pg_do_recoup.h"
|
|
|
|
#include "pg_do_recoup_refresh.h"
|
|
|
|
#include "pg_get_reserve_balance.h"
|
|
|
|
#include "pg_count_known_coins.h"
|
|
|
|
#include "pg_ensure_coin_known.h"
|
|
|
|
#include "pg_get_known_coin.h"
|
|
|
|
#include "pg_get_coin_denomination.h"
|
|
|
|
#include "pg_have_deposit2.h"
|
|
|
|
#include "pg_aggregate.h"
|
|
|
|
#include "pg_create_aggregation_transient.h"
|
|
|
|
#include "pg_select_aggregation_transient.h"
|
|
|
|
#include "pg_find_aggregation_transient.h"
|
|
|
|
#include "pg_update_aggregation_transient.h"
|
|
|
|
#include "pg_get_ready_deposit.h"
|
|
|
|
#include "pg_insert_deposit.h"
|
|
|
|
#include "pg_insert_refund.h"
|
|
|
|
#include "pg_select_refunds_by_coin.h"
|
|
|
|
#include "pg_get_melt.h"
|
|
|
|
#include "pg_insert_refresh_reveal.h"
|
|
|
|
#include "pg_get_refresh_reveal.h"
|
|
|
|
#include "pg_lookup_wire_transfer.h"
|
|
|
|
#include "pg_lookup_transfer_by_deposit.h"
|
|
|
|
#include "pg_insert_wire_fee.h"
|
|
|
|
#include "pg_insert_global_fee.h"
|
|
|
|
#include "pg_get_wire_fee.h"
|
|
|
|
#include "pg_get_global_fee.h"
|
|
|
|
#include "pg_get_global_fees.h"
|
|
|
|
#include "pg_insert_reserve_closed.h"
|
|
|
|
#include "pg_wire_prepare_data_insert.h"
|
|
|
|
#include "pg_wire_prepare_data_mark_finished.h"
|
|
|
|
#include "pg_wire_prepare_data_mark_failed.h"
|
|
|
|
#include "pg_wire_prepare_data_get.h"
|
|
|
|
#include "pg_start_deferred_wire_out.h"
|
|
|
|
#include "pg_store_wire_transfer_out.h"
|
|
|
|
#include "pg_gc.h"
|
|
|
|
#include "pg_select_deposits_above_serial_id.h"
|
|
|
|
#include "pg_select_history_requests_above_serial_id.h"
|
|
|
|
#include "pg_select_purse_decisions_above_serial_id.h"
|
|
|
|
#include "pg_select_purse_deposits_by_purse.h"
|
|
|
|
#include "pg_select_refreshes_above_serial_id.h"
|
|
|
|
#include "pg_select_refunds_above_serial_id.h"
|
|
|
|
#include "pg_select_reserves_in_above_serial_id.h"
|
|
|
|
#include "pg_select_reserves_in_above_serial_id_by_account.h"
|
|
|
|
#include "pg_select_withdrawals_above_serial_id.h"
|
|
|
|
#include "pg_select_wire_out_above_serial_id.h"
|
|
|
|
#include "pg_select_wire_out_above_serial_id_by_account.h"
|
|
|
|
#include "pg_select_recoup_above_serial_id.h"
|
|
|
|
#include "pg_select_recoup_refresh_above_serial_id.h"
|
|
|
|
#include "pg_get_reserve_by_h_blind.h"
|
|
|
|
#include "pg_get_old_coin_by_h_blind.h"
|
|
|
|
#include "pg_insert_denomination_revocation.h"
|
|
|
|
#include "pg_get_denomination_revocation.h"
|
|
|
|
#include "pg_select_deposits_missing_wire.h"
|
|
|
|
#include "pg_lookup_auditor_timestamp.h"
|
|
|
|
#include "pg_lookup_auditor_status.h"
|
|
|
|
#include "pg_insert_auditor.h"
|
|
|
|
#include "pg_lookup_wire_timestamp.h"
|
|
|
|
#include "pg_insert_wire.h"
|
|
|
|
#include "pg_update_wire.h"
|
|
|
|
#include "pg_get_wire_accounts.h"
|
|
|
|
#include "pg_get_wire_fees.h"
|
|
|
|
#include "pg_insert_signkey_revocation.h"
|
|
|
|
#include "pg_lookup_signkey_revocation.h"
|
|
|
|
#include "pg_lookup_denomination_key.h"
|
|
|
|
#include "pg_insert_auditor_denom_sig.h"
|
|
|
|
#include "pg_select_auditor_denom_sig.h"
|
|
|
|
#include "pg_add_denomination_key.h"
|
|
|
|
#include "pg_lookup_signing_key.h"
|
|
|
|
#include "pg_begin_shard.h"
|
|
|
|
#include "pg_abort_shard.h"
|
|
|
|
#include "pg_complete_shard.h"
|
|
|
|
#include "pg_release_revolving_shard.h"
|
|
|
|
#include "pg_delete_shard_locks.h"
|
|
|
|
#include "pg_set_extension_manifest.h"
|
|
|
|
#include "pg_insert_partner.h"
|
|
|
|
#include "pg_expire_purse.h"
|
|
|
|
#include "pg_select_purse_by_merge_pub.h"
|
|
|
|
#include "pg_set_purse_balance.h"
|
|
|
|
#include "pg_reserves_update.h"
|
|
|
|
#include "pg_setup_wire_target.h"
|
|
|
|
#include "pg_compute_shard.h"
|
2022-11-16 17:44:48 +01:00
|
|
|
#include "pg_batch_reserves_in_insert.h"
|
2022-11-25 12:09:20 +01:00
|
|
|
#include "pg_batch2_reserves_in_insert.h"
|
2018-08-10 22:30:38 +02:00
|
|
|
/**
|
|
|
|
* Set to 1 to enable Postgres auto_explain module. This will
|
|
|
|
* slow down things a _lot_, but also provide extensive logging
|
|
|
|
* in the Postgres database logger for performance analysis.
|
|
|
|
*/
|
|
|
|
#define AUTO_EXPLAIN 1
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2019-08-17 21:35:21 +02:00
|
|
|
|
2015-06-03 11:31:51 +02:00
|
|
|
/**
|
2017-03-18 03:44:59 +01:00
|
|
|
* Log a really unexpected PQ error with all the details we can get hold of.
|
2015-06-03 11:31:51 +02:00
|
|
|
*
|
|
|
|
* @param result PQ result object of the PQ operation that failed
|
2017-03-18 03:44:59 +01:00
|
|
|
* @param conn SQL connection that was used
|
2015-06-03 11:31:51 +02:00
|
|
|
*/
|
2019-10-11 23:28:05 +02:00
|
|
|
#define BREAK_DB_ERR(result,conn) do { \
|
|
|
|
GNUNET_break (0); \
|
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
|
|
|
|
"Database failure: %s/%s/%s/%s/%s", \
|
|
|
|
PQresultErrorField (result, PG_DIAG_MESSAGE_PRIMARY), \
|
|
|
|
PQresultErrorField (result, PG_DIAG_MESSAGE_DETAIL), \
|
|
|
|
PQresultErrorMessage (result), \
|
|
|
|
PQresStatus (PQresultStatus (result)), \
|
|
|
|
PQerrorMessage (conn)); \
|
2019-08-25 16:18:24 +02:00
|
|
|
} while (0)
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2015-06-03 11:31:51 +02:00
|
|
|
|
2021-08-13 22:35:13 +02:00
|
|
|
/**
|
2021-08-23 00:06:36 +02:00
|
|
|
* Initialize prepared statements for @a pg.
|
2021-08-13 22:35:13 +02:00
|
|
|
*
|
2021-08-23 00:06:36 +02:00
|
|
|
* @param[in,out] pg connection to initialize
|
2021-08-13 22:35:13 +02:00
|
|
|
* @return #GNUNET_OK on success
|
|
|
|
*/
|
2022-11-14 05:08:11 +01:00
|
|
|
enum GNUNET_GenericReturnValue
|
2021-08-23 00:00:32 +02:00
|
|
|
prepare_statements (struct PostgresClosure *pg)
|
2021-08-13 22:35:13 +02:00
|
|
|
{
|
|
|
|
enum GNUNET_GenericReturnValue ret;
|
|
|
|
struct GNUNET_PQ_PreparedStatement ps[] = {
|
2021-11-15 14:39:18 +01:00
|
|
|
GNUNET_PQ_make_prepare (
|
|
|
|
"get_kyc_h_payto",
|
|
|
|
"SELECT"
|
2022-03-03 23:52:08 +01:00
|
|
|
" wire_target_h_payto"
|
2021-11-15 14:39:18 +01:00
|
|
|
" FROM wire_targets"
|
2022-03-03 23:52:08 +01:00
|
|
|
" WHERE wire_target_h_payto=$1"
|
2022-10-12 14:48:49 +02:00
|
|
|
" LIMIT 1;"),
|
2021-08-13 22:35:13 +02:00
|
|
|
/* Used in #postgres_ensure_coin_known() */
|
2021-10-31 13:27:50 +01:00
|
|
|
GNUNET_PQ_make_prepare (
|
|
|
|
"get_known_coin_dh",
|
|
|
|
"SELECT"
|
|
|
|
" denominations.denom_pub_hash"
|
|
|
|
" FROM known_coins"
|
|
|
|
" JOIN denominations USING (denominations_serial)"
|
2022-10-12 14:48:49 +02:00
|
|
|
" WHERE coin_pub=$1;"),
|
2021-08-13 22:35:13 +02:00
|
|
|
/* Store information about the desired denominations for a
|
|
|
|
refresh operation, used in #postgres_insert_refresh_reveal() */
|
2021-10-31 13:27:50 +01:00
|
|
|
GNUNET_PQ_make_prepare (
|
|
|
|
"insert_refresh_revealed_coin",
|
|
|
|
"INSERT INTO refresh_revealed_coins "
|
|
|
|
"(melt_serial_id "
|
|
|
|
",freshcoin_index "
|
|
|
|
",link_sig "
|
|
|
|
",denominations_serial "
|
|
|
|
",coin_ev"
|
2022-02-10 23:39:00 +01:00
|
|
|
",ewv"
|
2021-10-31 13:27:50 +01:00
|
|
|
",h_coin_ev"
|
|
|
|
",ev_sig"
|
2021-12-25 13:56:33 +01:00
|
|
|
") SELECT $1, $2, $3, "
|
2022-02-10 23:39:00 +01:00
|
|
|
" denominations_serial, $5, $6, $7, $8"
|
2021-10-31 13:27:50 +01:00
|
|
|
" FROM denominations"
|
2022-05-12 13:31:15 +02:00
|
|
|
" WHERE denom_pub_hash=$4"
|
2022-10-12 14:48:49 +02:00
|
|
|
" ON CONFLICT DO NOTHING;"),
|
2022-06-13 15:31:52 +02:00
|
|
|
GNUNET_PQ_make_prepare (
|
|
|
|
"test_refund_full",
|
|
|
|
"SELECT"
|
|
|
|
" CAST(SUM(CAST(ref.amount_with_fee_frac AS INT8)) AS INT8) AS s_f"
|
|
|
|
",CAST(SUM(ref.amount_with_fee_val) AS INT8) AS s_v"
|
|
|
|
",dep.amount_with_fee_val"
|
|
|
|
",dep.amount_with_fee_frac"
|
|
|
|
" FROM refunds ref"
|
|
|
|
" JOIN deposits dep"
|
|
|
|
" ON (ref.coin_pub=dep.coin_pub AND ref.deposit_serial_id=dep.deposit_serial_id)"
|
|
|
|
" WHERE ref.refund_serial_id=$1"
|
2022-10-12 14:48:49 +02:00
|
|
|
" GROUP BY (dep.amount_with_fee_val, dep.amount_with_fee_frac);"),
|
2022-11-14 13:35:56 +01:00
|
|
|
/* Used in #postgres_update_kyc_requirement_by_row() */
|
2021-10-31 13:27:50 +01:00
|
|
|
GNUNET_PQ_make_prepare (
|
2022-11-14 13:35:56 +01:00
|
|
|
"update_legitimization_process",
|
|
|
|
"UPDATE legitimization_processes"
|
|
|
|
" SET provider_user_id=$4"
|
|
|
|
" ,provider_legitimization_id=$5"
|
|
|
|
" ,expiration_time=GREATEST(expiration_time,$6)"
|
|
|
|
" WHERE"
|
|
|
|
" h_payto=$3"
|
|
|
|
" AND legitimization_process_serial_id=$1"
|
|
|
|
" AND provider_section=$2;"),
|
|
|
|
GNUNET_PQ_PREPARED_STATEMENT_END
|
|
|
|
};
|
2022-06-15 20:49:39 +02:00
|
|
|
|
2022-11-14 13:35:56 +01:00
|
|
|
ret = GNUNET_PQ_prepare_statements (pg->conn,
|
|
|
|
ps);
|
|
|
|
if (GNUNET_OK != ret)
|
|
|
|
return ret;
|
|
|
|
pg->init = true;
|
|
|
|
return GNUNET_OK;
|
|
|
|
}
|
2021-08-13 22:35:13 +02:00
|
|
|
|
|
|
|
|
2015-01-08 18:37:20 +01:00
|
|
|
/**
|
2021-08-23 00:00:32 +02:00
|
|
|
* Connect to the database if the connection does not exist yet.
|
2015-01-08 18:37:20 +01:00
|
|
|
*
|
2021-08-23 00:00:32 +02:00
|
|
|
* @param pg the plugin-specific state
|
2021-08-13 22:35:13 +02:00
|
|
|
* @param skip_prepare true if we should skip prepared statement setup
|
2021-08-23 00:00:32 +02:00
|
|
|
* @return #GNUNET_OK on success
|
2015-01-08 18:37:20 +01:00
|
|
|
*/
|
2022-11-14 05:08:11 +01:00
|
|
|
enum GNUNET_GenericReturnValue
|
|
|
|
TEH_PG_internal_setup (struct PostgresClosure *pg,
|
|
|
|
bool skip_prepare)
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
2021-08-23 00:00:32 +02:00
|
|
|
if (NULL == pg->conn)
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
2018-08-10 22:30:38 +02:00
|
|
|
#if AUTO_EXPLAIN
|
2019-10-11 23:28:05 +02:00
|
|
|
/* Enable verbose logging to see where queries do not
|
|
|
|
properly use indices */
|
2018-08-10 22:30:38 +02:00
|
|
|
struct GNUNET_PQ_ExecuteStatement es[] = {
|
2019-05-09 12:55:09 +02:00
|
|
|
GNUNET_PQ_make_try_execute ("LOAD 'auto_explain';"),
|
|
|
|
GNUNET_PQ_make_try_execute ("SET auto_explain.log_min_duration=50;"),
|
|
|
|
GNUNET_PQ_make_try_execute ("SET auto_explain.log_timing=TRUE;"),
|
|
|
|
GNUNET_PQ_make_try_execute ("SET auto_explain.log_analyze=TRUE;"),
|
2020-08-08 20:01:56 +02:00
|
|
|
/* https://wiki.postgresql.org/wiki/Serializable suggests to really
|
|
|
|
force the default to 'serializable' if SSI is to be used. */
|
|
|
|
GNUNET_PQ_make_try_execute (
|
|
|
|
"SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"),
|
2019-05-09 12:55:09 +02:00
|
|
|
GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"),
|
|
|
|
GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"),
|
2022-07-25 20:18:08 +02:00
|
|
|
GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
|
2018-08-10 22:30:38 +02:00
|
|
|
GNUNET_PQ_EXECUTE_STATEMENT_END
|
|
|
|
};
|
2019-10-11 23:28:05 +02:00
|
|
|
#else
|
2021-12-25 13:56:33 +01:00
|
|
|
struct GNUNET_PQ_ExecuteStatement es[] = {
|
|
|
|
GNUNET_PQ_make_try_execute (
|
|
|
|
"SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"),
|
|
|
|
GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"),
|
|
|
|
GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"),
|
|
|
|
GNUNET_PQ_make_try_execute ("SET autocommit=OFF;"),
|
2022-07-25 20:18:08 +02:00
|
|
|
GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
|
2021-12-25 13:56:33 +01:00
|
|
|
GNUNET_PQ_EXECUTE_STATEMENT_END
|
|
|
|
};
|
2018-08-10 22:30:38 +02:00
|
|
|
#endif
|
2021-08-23 00:00:32 +02:00
|
|
|
struct GNUNET_PQ_Context *db_conn;
|
2018-08-10 22:30:38 +02:00
|
|
|
|
2021-08-23 00:00:32 +02:00
|
|
|
db_conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
|
2020-02-09 16:34:40 +01:00
|
|
|
"exchangedb-postgres",
|
|
|
|
NULL,
|
|
|
|
es,
|
2021-08-13 22:35:13 +02:00
|
|
|
NULL);
|
2021-08-23 00:00:32 +02:00
|
|
|
if (NULL == db_conn)
|
|
|
|
return GNUNET_SYSERR;
|
2022-10-03 12:46:30 +02:00
|
|
|
pg->prep_gen++;
|
2021-08-23 00:00:32 +02:00
|
|
|
pg->conn = db_conn;
|
2019-10-11 23:28:05 +02:00
|
|
|
}
|
2021-08-23 00:00:32 +02:00
|
|
|
if (NULL == pg->transaction_name)
|
|
|
|
GNUNET_PQ_reconnect_if_down (pg->conn);
|
|
|
|
if (pg->init)
|
|
|
|
return GNUNET_OK;
|
|
|
|
if (skip_prepare)
|
|
|
|
return GNUNET_OK;
|
|
|
|
return prepare_statements (pg);
|
2015-01-08 18:37:20 +01:00
|
|
|
}
|
|
|
|
|
2020-01-15 15:44:24 +01:00
|
|
|
|
2015-01-28 22:47:03 +01:00
|
|
|
/**
|
2015-03-20 23:51:28 +01:00
|
|
|
* Initialize Postgres database subsystem.
|
2015-01-28 22:47:03 +01:00
|
|
|
*
|
2015-03-20 23:51:28 +01:00
|
|
|
* @param cls a configuration instance
|
2018-07-06 15:24:03 +02:00
|
|
|
* @return NULL on error, otherwise a `struct
|
|
|
|
* TALER_EXCHANGEDB_Plugin`
|
2015-01-28 22:47:03 +01:00
|
|
|
*/
|
2015-03-20 23:51:28 +01:00
|
|
|
void *
|
2016-03-01 15:35:04 +01:00
|
|
|
libtaler_plugin_exchangedb_postgres_init (void *cls)
|
2015-01-28 22:47:03 +01:00
|
|
|
{
|
2020-02-09 15:53:28 +01:00
|
|
|
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
|
2015-03-20 23:51:28 +01:00
|
|
|
struct PostgresClosure *pg;
|
2016-03-01 15:35:04 +01:00
|
|
|
struct TALER_EXCHANGEDB_Plugin *plugin;
|
2022-10-09 23:23:14 +02:00
|
|
|
unsigned long long dpl;
|
2015-03-20 23:51:28 +01:00
|
|
|
|
|
|
|
pg = GNUNET_new (struct PostgresClosure);
|
2020-02-09 15:53:28 +01:00
|
|
|
pg->cfg = cfg;
|
2020-01-17 03:08:30 +01:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_filename (cfg,
|
|
|
|
"exchangedb-postgres",
|
|
|
|
"SQL_DIR",
|
|
|
|
&pg->sql_dir))
|
|
|
|
{
|
|
|
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"exchangedb-postgres",
|
2022-12-19 14:08:26 +01:00
|
|
|
"SQL_DIR");
|
2020-01-17 03:08:30 +01:00
|
|
|
GNUNET_free (pg);
|
|
|
|
return NULL;
|
|
|
|
}
|
2021-10-29 11:28:12 +02:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
|
|
"exchange",
|
|
|
|
"BASE_URL",
|
|
|
|
&pg->exchange_url))
|
|
|
|
{
|
|
|
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"exchange",
|
|
|
|
"BASE_URL");
|
|
|
|
GNUNET_free (pg->sql_dir);
|
|
|
|
GNUNET_free (pg);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-07-24 12:19:36 +02:00
|
|
|
if ( (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_time (cfg,
|
|
|
|
"exchangedb",
|
|
|
|
"IDLE_RESERVE_EXPIRATION_TIME",
|
2019-08-25 16:18:24 +02:00
|
|
|
&pg->idle_reserve_expiration_time))
|
|
|
|
||
|
2019-07-24 12:19:36 +02:00
|
|
|
(GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_time (cfg,
|
|
|
|
"exchangedb",
|
|
|
|
"LEGAL_RESERVE_EXPIRATION_TIME",
|
|
|
|
&pg->legal_reserve_expiration_time)) )
|
2017-04-20 21:38:02 +02:00
|
|
|
{
|
|
|
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"exchangedb",
|
2019-07-24 12:19:36 +02:00
|
|
|
"LEGAL/IDLE_RESERVE_EXPIRATION_TIME");
|
2021-10-29 11:28:12 +02:00
|
|
|
GNUNET_free (pg->exchange_url);
|
2020-01-17 03:08:30 +01:00
|
|
|
GNUNET_free (pg->sql_dir);
|
2017-04-20 21:38:02 +02:00
|
|
|
GNUNET_free (pg);
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-03-26 09:00:19 +01:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_time (cfg,
|
|
|
|
"exchangedb",
|
|
|
|
"AGGREGATOR_SHIFT",
|
|
|
|
&pg->aggregator_shift))
|
|
|
|
{
|
|
|
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
|
|
|
"exchangedb",
|
|
|
|
"AGGREGATOR_SHIFT");
|
|
|
|
}
|
2022-10-09 23:23:14 +02:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_number (cfg,
|
|
|
|
"exchangedb",
|
|
|
|
"DEFAULT_PURSE_LIMIT",
|
|
|
|
&dpl))
|
|
|
|
{
|
|
|
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
|
|
|
"exchangedb",
|
|
|
|
"DEFAULT_PURSE_LIMIT");
|
|
|
|
pg->def_purse_limit = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pg->def_purse_limit = (uint32_t) dpl;
|
|
|
|
}
|
2022-03-26 09:00:19 +01:00
|
|
|
|
2019-08-17 21:35:21 +02:00
|
|
|
if (GNUNET_OK !=
|
2020-03-15 20:08:38 +01:00
|
|
|
TALER_config_get_currency (cfg,
|
|
|
|
&pg->currency))
|
2019-08-17 21:35:21 +02:00
|
|
|
{
|
2021-10-29 11:28:12 +02:00
|
|
|
GNUNET_free (pg->exchange_url);
|
2020-01-17 03:08:30 +01:00
|
|
|
GNUNET_free (pg->sql_dir);
|
2019-08-17 21:35:21 +02:00
|
|
|
GNUNET_free (pg);
|
|
|
|
return NULL;
|
|
|
|
}
|
2021-08-23 00:00:32 +02:00
|
|
|
if (GNUNET_OK !=
|
2022-11-14 05:08:11 +01:00
|
|
|
TEH_PG_internal_setup (pg,
|
|
|
|
true))
|
2021-08-13 22:35:13 +02:00
|
|
|
{
|
2021-10-29 11:28:12 +02:00
|
|
|
GNUNET_free (pg->exchange_url);
|
2021-08-23 00:00:32 +02:00
|
|
|
GNUNET_free (pg->currency);
|
|
|
|
GNUNET_free (pg->sql_dir);
|
|
|
|
GNUNET_free (pg);
|
|
|
|
return NULL;
|
2021-08-13 22:35:13 +02:00
|
|
|
}
|
2016-03-01 15:35:04 +01:00
|
|
|
plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin);
|
2015-03-20 23:51:28 +01:00
|
|
|
plugin->cls = pg;
|
2022-11-14 13:35:56 +01:00
|
|
|
/* New style, sort alphabetically! */
|
2022-10-12 14:48:49 +02:00
|
|
|
plugin->do_reserve_open
|
|
|
|
= &TEH_PG_do_reserve_open;
|
2022-11-08 17:40:47 +01:00
|
|
|
plugin->drop_tables
|
|
|
|
= &TEH_PG_drop_tables;
|
2022-11-08 13:34:53 +01:00
|
|
|
plugin->do_withdraw
|
|
|
|
= &TEH_PG_do_withdraw;
|
2022-10-13 22:43:22 +02:00
|
|
|
plugin->free_coin_transaction_list
|
|
|
|
= &TEH_COMMON_free_coin_transaction_list;
|
|
|
|
plugin->free_reserve_history
|
|
|
|
= &TEH_COMMON_free_reserve_history;
|
|
|
|
plugin->get_coin_transactions
|
|
|
|
= &TEH_PG_get_coin_transactions;
|
2022-10-13 19:07:25 +02:00
|
|
|
plugin->get_expired_reserves
|
|
|
|
= &TEH_PG_get_expired_reserves;
|
2022-11-08 13:28:17 +01:00
|
|
|
plugin->get_purse_request
|
|
|
|
= &TEH_PG_get_purse_request;
|
2022-10-15 16:19:14 +02:00
|
|
|
plugin->get_reserve_history
|
|
|
|
= &TEH_PG_get_reserve_history;
|
|
|
|
plugin->get_reserve_status
|
|
|
|
= &TEH_PG_get_reserve_status;
|
2022-10-13 19:07:25 +02:00
|
|
|
plugin->get_unfinished_close_requests
|
|
|
|
= &TEH_PG_get_unfinished_close_requests;
|
2022-10-08 18:07:05 +02:00
|
|
|
plugin->insert_records_by_table
|
|
|
|
= &TEH_PG_insert_records_by_table;
|
2022-10-04 19:18:43 +02:00
|
|
|
plugin->insert_reserve_open_deposit
|
|
|
|
= &TEH_PG_insert_reserve_open_deposit;
|
2022-10-03 23:54:12 +02:00
|
|
|
plugin->insert_close_request
|
|
|
|
= &TEH_PG_insert_close_request;
|
2022-11-07 16:35:34 +01:00
|
|
|
plugin->delete_aggregation_transient
|
|
|
|
= &TEH_PG_delete_aggregation_transient;
|
|
|
|
plugin->get_link_data
|
|
|
|
= &TEH_PG_get_link_data;
|
2022-10-03 23:54:12 +02:00
|
|
|
plugin->iterate_reserve_close_info
|
|
|
|
= &TEH_PG_iterate_reserve_close_info;
|
|
|
|
plugin->iterate_kyc_reference
|
|
|
|
= &TEH_PG_iterate_kyc_reference;
|
2022-10-10 08:20:36 +02:00
|
|
|
plugin->lookup_records_by_table
|
|
|
|
= &TEH_PG_lookup_records_by_table;
|
|
|
|
plugin->lookup_serial_by_table
|
|
|
|
= &TEH_PG_lookup_serial_by_table;
|
2022-11-02 12:17:05 +01:00
|
|
|
plugin->select_account_merges_above_serial_id
|
|
|
|
= &TEH_PG_select_account_merges_above_serial_id;
|
|
|
|
plugin->select_all_purse_decisions_above_serial_id
|
|
|
|
= &TEH_PG_select_all_purse_decisions_above_serial_id;
|
|
|
|
plugin->select_purse
|
|
|
|
= &TEH_PG_select_purse;
|
|
|
|
plugin->select_purse_deposits_above_serial_id
|
|
|
|
= &TEH_PG_select_purse_deposits_above_serial_id;
|
|
|
|
plugin->select_purse_merges_above_serial_id
|
|
|
|
= &TEH_PG_select_purse_merges_above_serial_id;
|
|
|
|
plugin->select_purse_requests_above_serial_id
|
|
|
|
= &TEH_PG_select_purse_requests_above_serial_id;
|
2022-10-03 23:54:12 +02:00
|
|
|
plugin->select_reserve_close_info
|
|
|
|
= &TEH_PG_select_reserve_close_info;
|
2022-10-30 17:36:57 +01:00
|
|
|
plugin->select_reserve_closed_above_serial_id
|
|
|
|
= &TEH_PG_select_reserve_closed_above_serial_id;
|
|
|
|
plugin->select_reserve_open_above_serial_id
|
|
|
|
= &TEH_PG_select_reserve_open_above_serial_id;
|
2022-11-10 16:37:28 +01:00
|
|
|
/*need to sort*/
|
2022-11-08 13:28:17 +01:00
|
|
|
plugin->insert_purse_request
|
|
|
|
= &TEH_PG_insert_purse_request;
|
2022-11-08 15:21:01 +01:00
|
|
|
plugin->iterate_active_signkeys
|
|
|
|
= &TEH_PG_iterate_active_signkeys;
|
|
|
|
plugin->commit
|
|
|
|
= &TEH_PG_commit;
|
2022-11-08 17:40:47 +01:00
|
|
|
plugin->preflight
|
|
|
|
= &TEH_PG_preflight;
|
|
|
|
plugin->insert_aggregation_tracking
|
|
|
|
= &TEH_PG_insert_aggregation_tracking;
|
2022-11-10 16:37:28 +01:00
|
|
|
plugin->select_aggregation_amounts_for_kyc_check
|
|
|
|
= &TEH_PG_select_aggregation_amounts_for_kyc_check;
|
|
|
|
|
|
|
|
plugin->select_satisfied_kyc_processes
|
|
|
|
= &TEH_PG_select_satisfied_kyc_processes;
|
|
|
|
plugin->kyc_provider_account_lookup
|
|
|
|
= &TEH_PG_kyc_provider_account_lookup;
|
|
|
|
plugin->lookup_kyc_requirement_by_row
|
|
|
|
= &TEH_PG_lookup_kyc_requirement_by_row;
|
|
|
|
plugin->insert_kyc_requirement_for_account
|
2022-11-14 05:08:11 +01:00
|
|
|
= &TEH_PG_insert_kyc_requirement_for_account;
|
2022-11-10 16:37:28 +01:00
|
|
|
plugin->lookup_kyc_process_by_account
|
|
|
|
= &TEH_PG_lookup_kyc_process_by_account;
|
|
|
|
plugin->update_kyc_process_by_row
|
|
|
|
= &TEH_PG_update_kyc_process_by_row;
|
|
|
|
plugin->insert_kyc_requirement_process
|
|
|
|
= &TEH_PG_insert_kyc_requirement_process;
|
|
|
|
plugin->select_withdraw_amounts_for_kyc_check
|
|
|
|
= &TEH_PG_select_withdraw_amounts_for_kyc_check;
|
|
|
|
plugin->select_merge_amounts_for_kyc_check
|
|
|
|
= &TEH_PG_select_merge_amounts_for_kyc_check;
|
|
|
|
plugin->profit_drains_set_finished
|
|
|
|
= &TEH_PG_profit_drains_set_finished;
|
|
|
|
plugin->profit_drains_get_pending
|
|
|
|
= &TEH_PG_profit_drains_get_pending;
|
|
|
|
plugin->get_drain_profit
|
|
|
|
= &TEH_PG_get_drain_profit;
|
|
|
|
plugin->get_purse_deposit
|
|
|
|
= &TEH_PG_get_purse_deposit;
|
|
|
|
plugin->insert_contract
|
|
|
|
= &TEH_PG_insert_contract;
|
|
|
|
plugin->select_contract
|
|
|
|
= &TEH_PG_select_contract;
|
|
|
|
plugin->select_purse_merge
|
|
|
|
= &TEH_PG_select_purse_merge;
|
|
|
|
plugin->select_contract_by_purse
|
|
|
|
= &TEH_PG_select_contract_by_purse;
|
|
|
|
plugin->insert_drain_profit
|
|
|
|
= &TEH_PG_insert_drain_profit;
|
|
|
|
plugin->do_reserve_purse
|
|
|
|
= &TEH_PG_do_reserve_purse;
|
|
|
|
plugin->lookup_global_fee_by_time
|
|
|
|
= &TEH_PG_lookup_global_fee_by_time;
|
|
|
|
plugin->do_purse_deposit
|
|
|
|
= &TEH_PG_do_purse_deposit;
|
|
|
|
plugin->activate_signing_key
|
|
|
|
= &TEH_PG_activate_signing_key;
|
|
|
|
plugin->update_auditor
|
|
|
|
= &TEH_PG_update_auditor;
|
|
|
|
plugin->begin_revolving_shard
|
|
|
|
= &TEH_PG_begin_revolving_shard;
|
|
|
|
plugin->get_extension_manifest
|
|
|
|
= &TEH_PG_get_extension_manifest;
|
|
|
|
plugin->insert_history_request
|
|
|
|
= &TEH_PG_insert_history_request;
|
|
|
|
plugin->do_purse_merge
|
|
|
|
= &TEH_PG_do_purse_merge;
|
|
|
|
plugin->start_read_committed
|
|
|
|
= &TEH_PG_start_read_committed;
|
|
|
|
plugin->start_read_only
|
|
|
|
= &TEH_PG_start_read_only;
|
|
|
|
plugin->insert_denomination_info
|
|
|
|
= &TEH_PG_insert_denomination_info;
|
|
|
|
plugin->do_batch_withdraw_insert
|
|
|
|
= &TEH_PG_do_batch_withdraw_insert;
|
|
|
|
plugin->lookup_wire_fee_by_time
|
|
|
|
= &TEH_PG_lookup_wire_fee_by_time;
|
|
|
|
plugin->start
|
|
|
|
= &TEH_PG_start;
|
|
|
|
plugin->rollback
|
|
|
|
= &TEH_PG_rollback;
|
2022-11-26 23:26:44 +01:00
|
|
|
plugin->create_tables
|
2022-11-14 13:35:56 +01:00
|
|
|
= &TEH_PG_create_tables;
|
|
|
|
plugin->event_listen
|
|
|
|
= &TEH_PG_event_listen;
|
|
|
|
plugin->event_listen_cancel
|
|
|
|
= &TEH_PG_event_listen_cancel;
|
|
|
|
plugin->event_notify
|
|
|
|
= &TEH_PG_event_notify;
|
|
|
|
plugin->get_denomination_info
|
|
|
|
= &TEH_PG_get_denomination_info;
|
|
|
|
plugin->iterate_denomination_info
|
|
|
|
= &TEH_PG_iterate_denomination_info;
|
|
|
|
plugin->iterate_denominations
|
|
|
|
= &TEH_PG_iterate_denominations;
|
|
|
|
plugin->iterate_active_auditors
|
|
|
|
= &TEH_PG_iterate_active_auditors;
|
|
|
|
plugin->iterate_auditor_denominations
|
|
|
|
= &TEH_PG_iterate_auditor_denominations;
|
|
|
|
plugin->reserves_get
|
|
|
|
= &TEH_PG_reserves_get;
|
|
|
|
plugin->reserves_get_origin
|
|
|
|
= &TEH_PG_reserves_get_origin;
|
|
|
|
plugin->drain_kyc_alert
|
|
|
|
= &TEH_PG_drain_kyc_alert;
|
|
|
|
plugin->reserves_in_insert
|
|
|
|
= &TEH_PG_reserves_in_insert;
|
|
|
|
plugin->get_withdraw_info
|
|
|
|
= &TEH_PG_get_withdraw_info;
|
|
|
|
plugin->do_batch_withdraw
|
|
|
|
= &TEH_PG_do_batch_withdraw;
|
|
|
|
plugin->get_policy_details
|
|
|
|
= &TEH_PG_get_policy_details;
|
|
|
|
plugin->persist_policy_details
|
|
|
|
= &TEH_PG_persist_policy_details;
|
|
|
|
plugin->do_deposit
|
|
|
|
= &TEH_PG_do_deposit;
|
|
|
|
plugin->add_policy_fulfillment_proof
|
|
|
|
= &TEH_PG_add_policy_fulfillment_proof;
|
|
|
|
plugin->do_melt
|
|
|
|
= &TEH_PG_do_melt;
|
|
|
|
plugin->do_refund
|
|
|
|
= &TEH_PG_do_refund;
|
|
|
|
plugin->do_recoup
|
|
|
|
= &TEH_PG_do_recoup;
|
|
|
|
plugin->do_recoup_refresh
|
|
|
|
= &TEH_PG_do_recoup_refresh;
|
|
|
|
plugin->get_reserve_balance
|
|
|
|
= &TEH_PG_get_reserve_balance;
|
|
|
|
plugin->count_known_coins
|
|
|
|
= &TEH_PG_count_known_coins;
|
|
|
|
plugin->ensure_coin_known
|
|
|
|
= &TEH_PG_ensure_coin_known;
|
|
|
|
plugin->get_known_coin
|
|
|
|
= &TEH_PG_get_known_coin;
|
|
|
|
plugin->get_coin_denomination
|
|
|
|
= &TEH_PG_get_coin_denomination;
|
|
|
|
plugin->have_deposit2
|
|
|
|
= &TEH_PG_have_deposit2;
|
|
|
|
plugin->aggregate
|
|
|
|
= &TEH_PG_aggregate;
|
|
|
|
plugin->create_aggregation_transient
|
|
|
|
= &TEH_PG_create_aggregation_transient;
|
|
|
|
plugin->select_aggregation_transient
|
|
|
|
= &TEH_PG_select_aggregation_transient;
|
|
|
|
plugin->find_aggregation_transient
|
|
|
|
= &TEH_PG_find_aggregation_transient;
|
|
|
|
plugin->update_aggregation_transient
|
|
|
|
= &TEH_PG_update_aggregation_transient;
|
|
|
|
plugin->get_ready_deposit
|
|
|
|
= &TEH_PG_get_ready_deposit;
|
|
|
|
plugin->insert_deposit
|
|
|
|
= &TEH_PG_insert_deposit;
|
|
|
|
plugin->insert_refund
|
|
|
|
= &TEH_PG_insert_refund;
|
|
|
|
plugin->select_refunds_by_coin
|
|
|
|
= &TEH_PG_select_refunds_by_coin;
|
|
|
|
plugin->get_melt
|
|
|
|
= &TEH_PG_get_melt;
|
|
|
|
plugin->insert_refresh_reveal
|
|
|
|
= &TEH_PG_insert_refresh_reveal;
|
|
|
|
plugin->get_refresh_reveal
|
|
|
|
= &TEH_PG_get_refresh_reveal;
|
|
|
|
plugin->lookup_wire_transfer
|
|
|
|
= &TEH_PG_lookup_wire_transfer;
|
|
|
|
plugin->lookup_transfer_by_deposit
|
|
|
|
= &TEH_PG_lookup_transfer_by_deposit;
|
|
|
|
plugin->insert_wire_fee
|
|
|
|
= &TEH_PG_insert_wire_fee;
|
|
|
|
plugin->insert_global_fee
|
|
|
|
= &TEH_PG_insert_global_fee;
|
|
|
|
plugin->get_wire_fee
|
|
|
|
= &TEH_PG_get_wire_fee;
|
|
|
|
plugin->get_global_fee
|
|
|
|
= &TEH_PG_get_global_fee;
|
|
|
|
plugin->get_global_fees
|
|
|
|
= &TEH_PG_get_global_fees;
|
|
|
|
plugin->insert_reserve_closed
|
|
|
|
= &TEH_PG_insert_reserve_closed;
|
|
|
|
plugin->wire_prepare_data_insert
|
|
|
|
= &TEH_PG_wire_prepare_data_insert;
|
|
|
|
plugin->wire_prepare_data_mark_finished
|
|
|
|
= &TEH_PG_wire_prepare_data_mark_finished;
|
|
|
|
plugin->wire_prepare_data_mark_failed
|
|
|
|
= &TEH_PG_wire_prepare_data_mark_failed;
|
|
|
|
plugin->wire_prepare_data_get
|
|
|
|
= &TEH_PG_wire_prepare_data_get;
|
|
|
|
plugin->start_deferred_wire_out
|
|
|
|
= &TEH_PG_start_deferred_wire_out;
|
|
|
|
plugin->store_wire_transfer_out
|
|
|
|
= &TEH_PG_store_wire_transfer_out;
|
|
|
|
plugin->gc
|
|
|
|
= &TEH_PG_gc;
|
|
|
|
plugin->select_deposits_above_serial_id
|
|
|
|
= &TEH_PG_select_deposits_above_serial_id;
|
|
|
|
plugin->select_history_requests_above_serial_id
|
|
|
|
= &TEH_PG_select_history_requests_above_serial_id;
|
|
|
|
plugin->select_purse_decisions_above_serial_id
|
|
|
|
= &TEH_PG_select_purse_decisions_above_serial_id;
|
|
|
|
plugin->select_purse_deposits_by_purse
|
|
|
|
= &TEH_PG_select_purse_deposits_by_purse;
|
|
|
|
plugin->select_refreshes_above_serial_id
|
|
|
|
= &TEH_PG_select_refreshes_above_serial_id;
|
|
|
|
plugin->select_refunds_above_serial_id
|
|
|
|
= &TEH_PG_select_refunds_above_serial_id;
|
|
|
|
plugin->select_reserves_in_above_serial_id
|
|
|
|
= &TEH_PG_select_reserves_in_above_serial_id;
|
|
|
|
plugin->select_reserves_in_above_serial_id_by_account
|
|
|
|
= &TEH_PG_select_reserves_in_above_serial_id_by_account;
|
|
|
|
plugin->select_withdrawals_above_serial_id
|
|
|
|
= &TEH_PG_select_withdrawals_above_serial_id;
|
|
|
|
plugin->select_wire_out_above_serial_id
|
|
|
|
= &TEH_PG_select_wire_out_above_serial_id;
|
|
|
|
plugin->select_wire_out_above_serial_id_by_account
|
|
|
|
= &TEH_PG_select_wire_out_above_serial_id_by_account;
|
|
|
|
plugin->select_recoup_above_serial_id
|
|
|
|
= &TEH_PG_select_recoup_above_serial_id;
|
|
|
|
plugin->select_recoup_refresh_above_serial_id
|
|
|
|
= &TEH_PG_select_recoup_refresh_above_serial_id;
|
|
|
|
plugin->get_reserve_by_h_blind
|
|
|
|
= &TEH_PG_get_reserve_by_h_blind;
|
|
|
|
plugin->get_old_coin_by_h_blind
|
|
|
|
= &TEH_PG_get_old_coin_by_h_blind;
|
|
|
|
plugin->insert_denomination_revocation
|
|
|
|
= &TEH_PG_insert_denomination_revocation;
|
|
|
|
plugin->get_denomination_revocation
|
|
|
|
= &TEH_PG_get_denomination_revocation;
|
|
|
|
plugin->select_deposits_missing_wire
|
|
|
|
= &TEH_PG_select_deposits_missing_wire;
|
|
|
|
plugin->lookup_auditor_timestamp
|
|
|
|
= &TEH_PG_lookup_auditor_timestamp;
|
|
|
|
plugin->lookup_auditor_status
|
|
|
|
= &TEH_PG_lookup_auditor_status;
|
|
|
|
plugin->insert_auditor
|
|
|
|
= &TEH_PG_insert_auditor;
|
|
|
|
plugin->lookup_wire_timestamp
|
|
|
|
= &TEH_PG_lookup_wire_timestamp;
|
|
|
|
plugin->insert_wire
|
|
|
|
= &TEH_PG_insert_wire;
|
|
|
|
plugin->update_wire
|
|
|
|
= &TEH_PG_update_wire;
|
|
|
|
plugin->get_wire_accounts
|
|
|
|
= &TEH_PG_get_wire_accounts;
|
|
|
|
plugin->get_wire_fees
|
|
|
|
= &TEH_PG_get_wire_fees;
|
|
|
|
plugin->insert_signkey_revocation
|
|
|
|
= &TEH_PG_insert_signkey_revocation;
|
|
|
|
plugin->lookup_signkey_revocation
|
|
|
|
= &TEH_PG_lookup_signkey_revocation;
|
|
|
|
plugin->lookup_denomination_key
|
|
|
|
= &TEH_PG_lookup_denomination_key;
|
|
|
|
plugin->insert_auditor_denom_sig
|
|
|
|
= &TEH_PG_insert_auditor_denom_sig;
|
|
|
|
plugin->select_auditor_denom_sig
|
|
|
|
= &TEH_PG_select_auditor_denom_sig;
|
|
|
|
plugin->add_denomination_key
|
|
|
|
= &TEH_PG_add_denomination_key;
|
|
|
|
plugin->lookup_signing_key
|
|
|
|
= &TEH_PG_lookup_signing_key;
|
|
|
|
plugin->begin_shard
|
|
|
|
= &TEH_PG_begin_shard;
|
|
|
|
plugin->abort_shard
|
|
|
|
= &TEH_PG_abort_shard;
|
|
|
|
plugin->complete_shard
|
|
|
|
= &TEH_PG_complete_shard;
|
|
|
|
plugin->release_revolving_shard
|
|
|
|
= &TEH_PG_release_revolving_shard;
|
|
|
|
plugin->delete_shard_locks
|
|
|
|
= &TEH_PG_delete_shard_locks;
|
|
|
|
plugin->set_extension_manifest
|
|
|
|
= &TEH_PG_set_extension_manifest;
|
|
|
|
plugin->insert_partner
|
|
|
|
= &TEH_PG_insert_partner;
|
|
|
|
plugin->expire_purse
|
|
|
|
= &TEH_PG_expire_purse;
|
|
|
|
plugin->select_purse_by_merge_pub
|
|
|
|
= &TEH_PG_select_purse_by_merge_pub;
|
|
|
|
plugin->set_purse_balance
|
|
|
|
= &TEH_PG_set_purse_balance;
|
2022-11-16 17:44:48 +01:00
|
|
|
plugin->batch_reserves_in_insert
|
|
|
|
= &TEH_PG_batch_reserves_in_insert;
|
2022-11-25 12:09:20 +01:00
|
|
|
plugin->batch2_reserves_in_insert
|
|
|
|
= &TEH_PG_batch2_reserves_in_insert;
|
2022-11-18 17:18:45 +01:00
|
|
|
|
2015-03-20 23:51:28 +01:00
|
|
|
return plugin;
|
2015-01-28 22:47:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-20 23:51:28 +01:00
|
|
|
/**
|
|
|
|
* Shutdown Postgres database subsystem.
|
|
|
|
*
|
2016-03-01 15:35:04 +01:00
|
|
|
* @param cls a `struct TALER_EXCHANGEDB_Plugin`
|
2015-03-20 23:51:28 +01:00
|
|
|
* @return NULL (always)
|
|
|
|
*/
|
|
|
|
void *
|
2016-03-01 15:35:04 +01:00
|
|
|
libtaler_plugin_exchangedb_postgres_done (void *cls)
|
2015-03-20 23:51:28 +01:00
|
|
|
{
|
2016-03-01 15:35:04 +01:00
|
|
|
struct TALER_EXCHANGEDB_Plugin *plugin = cls;
|
2015-03-20 23:51:28 +01:00
|
|
|
struct PostgresClosure *pg = plugin->cls;
|
|
|
|
|
2021-08-23 00:00:32 +02:00
|
|
|
if (NULL != pg->conn)
|
2021-11-21 15:16:58 +01:00
|
|
|
{
|
2021-08-23 00:00:32 +02:00
|
|
|
GNUNET_PQ_disconnect (pg->conn);
|
2021-11-21 15:16:58 +01:00
|
|
|
pg->conn = NULL;
|
|
|
|
}
|
2021-10-29 11:28:12 +02:00
|
|
|
GNUNET_free (pg->exchange_url);
|
2020-01-17 03:08:30 +01:00
|
|
|
GNUNET_free (pg->sql_dir);
|
2019-09-05 03:53:47 +02:00
|
|
|
GNUNET_free (pg->currency);
|
2015-03-20 23:51:28 +01:00
|
|
|
GNUNET_free (pg);
|
|
|
|
GNUNET_free (plugin);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-10-31 12:59:50 +01:00
|
|
|
|
2016-03-01 15:35:04 +01:00
|
|
|
/* end of plugin_exchangedb_postgres.c */
|