split up auditor db plugin into individual files per main query
This commit is contained in:
parent
d97ef7fcf6
commit
7cc7f81d8a
@ -33,7 +33,57 @@ plugin_LTLIBRARIES = \
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
libtaler_plugin_auditordb_postgres_la_SOURCES = \
|
libtaler_plugin_auditordb_postgres_la_SOURCES = \
|
||||||
plugin_auditordb_postgres.c
|
plugin_auditordb_postgres.c pg_helper.h \
|
||||||
|
pg_insert_auditor_progress_reserve.h pg_insert_auditor_progress_reserve.c \
|
||||||
|
pg_update_auditor_progress_reserve.h pg_update_auditor_progress_reserve.c \
|
||||||
|
pg_get_auditor_progress_reserve.h pg_get_auditor_progress_reserve.c \
|
||||||
|
pg_insert_auditor_progress_purse.h pg_insert_auditor_progress_purse.c \
|
||||||
|
pg_update_auditor_progress_purse.h pg_update_auditor_progress_purse.c \
|
||||||
|
pg_get_auditor_progress_purse.h pg_get_auditor_progress_purse.c \
|
||||||
|
pg_insert_auditor_progress_aggregation.h pg_insert_auditor_progress_aggregation.c \
|
||||||
|
pg_update_auditor_progress_aggregation.h pg_update_auditor_progress_aggregation.c \
|
||||||
|
pg_get_auditor_progress_aggregation.h pg_get_auditor_progress_aggregation.c \
|
||||||
|
pg_insert_auditor_progress_deposit_confirmation.h pg_insert_auditor_progress_deposit_confirmation.c \
|
||||||
|
pg_update_auditor_progress_deposit_confirmation.h pg_update_auditor_progress_deposit_confirmation.c \
|
||||||
|
pg_get_auditor_progress_deposit_confirmation.h pg_get_auditor_progress_deposit_confirmation.c \
|
||||||
|
pg_insert_auditor_progress_coin.h pg_insert_auditor_progress_coin.c \
|
||||||
|
pg_update_auditor_progress_coin.h pg_update_auditor_progress_coin.c \
|
||||||
|
pg_get_auditor_progress_coin.h pg_get_auditor_progress_coin.c \
|
||||||
|
pg_insert_wire_auditor_account_progress.h pg_insert_wire_auditor_account_progress.c \
|
||||||
|
pg_update_wire_auditor_account_progress.h pg_update_wire_auditor_account_progress.c \
|
||||||
|
pg_get_wire_auditor_account_progress.h pg_get_wire_auditor_account_progress.c \
|
||||||
|
pg_insert_wire_auditor_progress.h pg_insert_wire_auditor_progress.c \
|
||||||
|
pg_update_wire_auditor_progress.h pg_update_wire_auditor_progress.c \
|
||||||
|
pg_get_wire_auditor_progress.h pg_get_wire_auditor_progress.c \
|
||||||
|
pg_insert_reserve_info.h pg_insert_reserve_info.c \
|
||||||
|
pg_update_reserve_info.h pg_update_reserve_info.c \
|
||||||
|
pg_del_reserve_info.h pg_del_reserve_info.c \
|
||||||
|
pg_get_reserve_info.h pg_get_reserve_info.c \
|
||||||
|
pg_insert_reserve_summary.h pg_insert_reserve_summary.c \
|
||||||
|
pg_update_reserve_summary.h pg_update_reserve_summary.c \
|
||||||
|
pg_get_reserve_summary.h pg_get_reserve_summary.c \
|
||||||
|
pg_insert_wire_fee_summary.h pg_insert_wire_fee_summary.c \
|
||||||
|
pg_update_wire_fee_summary.h pg_update_wire_fee_summary.c \
|
||||||
|
pg_get_wire_fee_summary.h pg_get_wire_fee_summary.c \
|
||||||
|
pg_insert_denomination_balance.h pg_insert_denomination_balance.c \
|
||||||
|
pg_update_denomination_balance.h pg_update_denomination_balance.c \
|
||||||
|
pg_get_denomination_balance.h pg_get_denomination_balance.c \
|
||||||
|
pg_insert_balance_summary.h pg_insert_balance_summary.c \
|
||||||
|
pg_update_balance_summary.h pg_update_balance_summary.c \
|
||||||
|
pg_get_balance_summary.h pg_get_balance_summary.c \
|
||||||
|
pg_insert_historic_denom_revenue.h pg_insert_historic_denom_revenue.c \
|
||||||
|
pg_select_historic_denom_revenue.h pg_select_historic_denom_revenue.c \
|
||||||
|
pg_insert_historic_reserve_revenue.h pg_insert_historic_reserve_revenue.c \
|
||||||
|
pg_select_historic_reserve_revenue.h pg_select_historic_reserve_revenue.c \
|
||||||
|
pg_insert_predicted_result.h pg_insert_predicted_result.c \
|
||||||
|
pg_update_predicted_result.h pg_update_predicted_result.c \
|
||||||
|
pg_get_predicted_balance.h pg_get_predicted_balance.c \
|
||||||
|
pg_insert_exchange.h pg_insert_exchange.c \
|
||||||
|
pg_list_exchanges.h pg_list_exchanges.c \
|
||||||
|
pg_delete_exchange.h pg_delete_exchange.c \
|
||||||
|
pg_insert_exchange_signkey.h pg_insert_exchange_signkey.c \
|
||||||
|
pg_insert_deposit_confirmation.h pg_insert_deposit_confirmation.c \
|
||||||
|
pg_get_deposit_confirmations.h pg_get_deposit_confirmations.c
|
||||||
libtaler_plugin_auditordb_postgres_la_LIBADD = \
|
libtaler_plugin_auditordb_postgres_la_LIBADD = \
|
||||||
$(LTLIBINTL)
|
$(LTLIBINTL)
|
||||||
libtaler_plugin_auditordb_postgres_la_LDFLAGS = \
|
libtaler_plugin_auditordb_postgres_la_LDFLAGS = \
|
||||||
|
0
src/auditordb/hdr.h
Normal file
0
src/auditordb/hdr.h
Normal file
50
src/auditordb/pg_del_reserve_info.c
Normal file
50
src/auditordb/pg_del_reserve_info.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_del_reserve_info.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_del_reserve_info.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_del_reserve_info (void *cls,
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_reserves_delete",
|
||||||
|
"DELETE"
|
||||||
|
" FROM auditor_reserves"
|
||||||
|
" WHERE reserve_pub=$1"
|
||||||
|
" AND master_pub=$2;");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_reserves_delete",
|
||||||
|
params);
|
||||||
|
}
|
43
src/auditordb/pg_del_reserve_info.h
Normal file
43
src/auditordb/pg_del_reserve_info.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_del_reserve_info.h
|
||||||
|
* @brief implementation of the del_reserve_info function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_DEL_RESERVE_INFO_H
|
||||||
|
#define PG_DEL_RESERVE_INFO_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete information about a reserve.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param reserve_pub public key of the reserve
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_del_reserve_info (void *cls,
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
47
src/auditordb/pg_delete_exchange.c
Normal file
47
src/auditordb/pg_delete_exchange.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_delete_exchange.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_delete_exchange.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_delete_exchange (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_delete_exchange",
|
||||||
|
"DELETE"
|
||||||
|
" FROM auditor_exchanges"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_delete_exchange",
|
||||||
|
params);
|
||||||
|
}
|
43
src/auditordb/pg_delete_exchange.h
Normal file
43
src/auditordb/pg_delete_exchange.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_delete_exchange.h
|
||||||
|
* @brief implementation of the delete_exchange function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_DELETE_EXCHANGE_H
|
||||||
|
#define PG_DELETE_EXCHANGE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an exchange from the list of exchanges this auditor is auditing.
|
||||||
|
* Warning: this will cascade and delete all knowledge of this auditor related
|
||||||
|
* to this exchange!
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @return query result status
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_delete_exchange (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
56
src/auditordb/pg_get_auditor_progress_aggregation.c
Normal file
56
src/auditordb/pg_get_auditor_progress_aggregation.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_aggregation.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_auditor_progress_aggregation.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_aggregation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointAggregation *ppa)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_wire_out_serial_id",
|
||||||
|
&ppa->last_wire_out_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_select_aggregation",
|
||||||
|
"SELECT"
|
||||||
|
" last_wire_out_serial_id"
|
||||||
|
" FROM auditor_progress_aggregation"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_progress_select_aggregation",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
43
src/auditordb/pg_get_auditor_progress_aggregation.h
Normal file
43
src/auditordb/pg_get_auditor_progress_aggregation.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_aggregation.h
|
||||||
|
* @brief implementation of the get_auditor_progress_aggregation function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_AUDITOR_PROGRESS_AGGREGATION_H
|
||||||
|
#define PG_GET_AUDITOR_PROGRESS_AGGREGATION_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about the progress of the auditor.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param[out] ppa set to where the auditor is in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_aggregation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
|
||||||
|
|
||||||
|
#endif
|
77
src/auditordb/pg_get_auditor_progress_coin.c
Normal file
77
src/auditordb/pg_get_auditor_progress_coin.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_coin.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_auditor_progress_coin.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_coin (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointCoin *ppc)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_withdraw_serial_id",
|
||||||
|
&ppc->last_withdraw_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_deposit_serial_id",
|
||||||
|
&ppc->last_deposit_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_melt_serial_id",
|
||||||
|
&ppc->last_melt_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_refund_serial_id",
|
||||||
|
&ppc->last_refund_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_recoup_serial_id",
|
||||||
|
&ppc->last_recoup_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_recoup_refresh_serial_id",
|
||||||
|
&ppc->last_recoup_refresh_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_purse_deposits_serial_id",
|
||||||
|
&ppc->last_purse_deposits_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_purse_decision_serial_id",
|
||||||
|
&ppc->last_purse_refunds_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_select_coin",
|
||||||
|
"SELECT"
|
||||||
|
" last_withdraw_serial_id"
|
||||||
|
",last_deposit_serial_id"
|
||||||
|
",last_melt_serial_id"
|
||||||
|
",last_refund_serial_id"
|
||||||
|
",last_recoup_serial_id"
|
||||||
|
",last_recoup_refresh_serial_id"
|
||||||
|
",last_purse_deposits_serial_id"
|
||||||
|
",last_purse_decision_serial_id"
|
||||||
|
" FROM auditor_progress_coin"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_progress_select_coin",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
43
src/auditordb/pg_get_auditor_progress_coin.h
Normal file
43
src/auditordb/pg_get_auditor_progress_coin.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_coin.h
|
||||||
|
* @brief implementation of the get_auditor_progress_coin function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_AUDITOR_PROGRESS_COIN_H
|
||||||
|
#define PG_GET_AUDITOR_PROGRESS_COIN_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about the progress of the auditor.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param[out] ppc set to where the auditor is in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_coin (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointCoin *ppc);
|
||||||
|
|
||||||
|
#endif
|
56
src/auditordb/pg_get_auditor_progress_deposit_confirmation.c
Normal file
56
src/auditordb/pg_get_auditor_progress_deposit_confirmation.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_deposit_confirmation.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_auditor_progress_deposit_confirmation.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_deposit_confirmation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_deposit_confirmation_serial_id",
|
||||||
|
&ppdc->last_deposit_confirmation_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_select_deposit_confirmation",
|
||||||
|
"SELECT"
|
||||||
|
" last_deposit_confirmation_serial_id"
|
||||||
|
" FROM auditor_progress_deposit_confirmation"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_progress_select_deposit_confirmation",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
43
src/auditordb/pg_get_auditor_progress_deposit_confirmation.h
Normal file
43
src/auditordb/pg_get_auditor_progress_deposit_confirmation.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_deposit_confirmation.h
|
||||||
|
* @brief implementation of the get_auditor_progress_deposit_confirmation function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
|
||||||
|
#define PG_GET_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about the progress of the auditor.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param[out] ppdc set to where the auditor is in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_deposit_confirmation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc);
|
||||||
|
|
||||||
|
#endif
|
68
src/auditordb/pg_get_auditor_progress_purse.c
Normal file
68
src/auditordb/pg_get_auditor_progress_purse.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_purse.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_auditor_progress_purse.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_purse (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointPurse *ppp)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_purse_request_serial_id",
|
||||||
|
&ppp->last_purse_request_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_purse_decision_serial_id",
|
||||||
|
&ppp->last_purse_decision_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_purse_merges_serial_id",
|
||||||
|
&ppp->last_purse_merge_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_account_merges_serial_id",
|
||||||
|
&ppp->last_account_merge_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_purse_deposits_serial_id",
|
||||||
|
&ppp->last_purse_deposits_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_select_purse",
|
||||||
|
"SELECT"
|
||||||
|
" last_purse_request_serial_id"
|
||||||
|
",last_purse_decision_serial_id"
|
||||||
|
",last_purse_merges_serial_id"
|
||||||
|
",last_account_merges_serial_id"
|
||||||
|
",last_purse_deposits_serial_id"
|
||||||
|
" FROM auditor_progress_purse"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_progress_select_purse",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
44
src/auditordb/pg_get_auditor_progress_purse.h
Normal file
44
src/auditordb/pg_get_auditor_progress_purse.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_purse.h
|
||||||
|
* @brief implementation of the get_auditor_progress_purse function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_AUDITOR_PROGRESS_PURSE_H
|
||||||
|
#define PG_GET_AUDITOR_PROGRESS_PURSE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about the progress of the auditor.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param[out] ppp set to where the auditor is in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_purse (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointPurse *ppp);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
77
src/auditordb/pg_get_auditor_progress_reserve.c
Normal file
77
src/auditordb/pg_get_auditor_progress_reserve.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_reserve.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_auditor_progress_reserve.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_reserve (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointReserve *ppr)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_reserve_in_serial_id",
|
||||||
|
&ppr->last_reserve_in_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_reserve_out_serial_id",
|
||||||
|
&ppr->last_reserve_out_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_reserve_recoup_serial_id",
|
||||||
|
&ppr->last_reserve_recoup_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_reserve_open_serial_id",
|
||||||
|
&ppr->last_reserve_open_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_reserve_close_serial_id",
|
||||||
|
&ppr->last_reserve_close_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_purse_decision_serial_id",
|
||||||
|
&ppr->last_purse_decisions_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_account_merges_serial_id",
|
||||||
|
&ppr->last_account_merges_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_history_requests_serial_id",
|
||||||
|
&ppr->last_history_requests_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_select_reserve",
|
||||||
|
"SELECT"
|
||||||
|
" last_reserve_in_serial_id"
|
||||||
|
",last_reserve_out_serial_id"
|
||||||
|
",last_reserve_recoup_serial_id"
|
||||||
|
",last_reserve_close_serial_id"
|
||||||
|
",last_purse_decision_serial_id"
|
||||||
|
",last_account_merges_serial_id"
|
||||||
|
",last_history_requests_serial_id"
|
||||||
|
",last_reserve_open_serial_id"
|
||||||
|
" FROM auditor_progress_reserve"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_progress_select_reserve",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
43
src/auditordb/pg_get_auditor_progress_reserve.h
Normal file
43
src/auditordb/pg_get_auditor_progress_reserve.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_auditor_progress_reserve.h
|
||||||
|
* @brief implementation of the get_auditor_progress_reserve function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_AUDITOR_PROGRESS_RESERVE_H
|
||||||
|
#define PG_GET_AUDITOR_PROGRESS_RESERVE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about the progress of the auditor.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param[out] ppr set to where the auditor is in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_auditor_progress_reserve (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ProgressPointReserve *ppr);
|
||||||
|
|
||||||
|
#endif
|
89
src/auditordb/pg_get_balance_summary.c
Normal file
89
src/auditordb/pg_get_balance_summary.c
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_balance_summary.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_balance_summary.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_balance_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_GlobalCoinBalance *dfb)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance",
|
||||||
|
&dfb->total_escrowed),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("deposit_fee_balance",
|
||||||
|
&dfb->deposit_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("melt_fee_balance",
|
||||||
|
&dfb->melt_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("refund_fee_balance",
|
||||||
|
&dfb->refund_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
|
||||||
|
&dfb->purse_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("open_deposit_fee_balance",
|
||||||
|
&dfb->open_deposit_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("risk",
|
||||||
|
&dfb->risk),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("loss",
|
||||||
|
&dfb->loss),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("irregular_loss",
|
||||||
|
&dfb->irregular_loss),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_balance_summary_select",
|
||||||
|
"SELECT"
|
||||||
|
" denom_balance_val"
|
||||||
|
",denom_balance_frac"
|
||||||
|
",deposit_fee_balance_val"
|
||||||
|
",deposit_fee_balance_frac"
|
||||||
|
",melt_fee_balance_val"
|
||||||
|
",melt_fee_balance_frac"
|
||||||
|
",refund_fee_balance_val"
|
||||||
|
",refund_fee_balance_frac"
|
||||||
|
",purse_fee_balance_val"
|
||||||
|
",purse_fee_balance_frac"
|
||||||
|
",open_deposit_fee_balance_val"
|
||||||
|
",open_deposit_fee_balance_frac"
|
||||||
|
",risk_val"
|
||||||
|
",risk_frac"
|
||||||
|
",loss_val"
|
||||||
|
",loss_frac"
|
||||||
|
",irregular_loss_val"
|
||||||
|
",irregular_loss_frac"
|
||||||
|
" FROM auditor_balance_summary"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_balance_summary_select",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
43
src/auditordb/pg_get_balance_summary.h
Normal file
43
src/auditordb/pg_get_balance_summary.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_balance_summary.h
|
||||||
|
* @brief implementation of the get_balance_summary function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_BALANCE_SUMMARY_H
|
||||||
|
#define PG_GET_BALANCE_SUMMARY_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about an exchange's denomination balances.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param[out] dfb where to return the denomination balances
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_balance_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_GlobalCoinBalance *dfb);
|
||||||
|
|
||||||
|
#endif
|
72
src/auditordb/pg_get_denomination_balance.c
Normal file
72
src/auditordb/pg_get_denomination_balance.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_denomination_balance.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_denomination_balance.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_denomination_balance (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_DenominationHashP *denom_pub_hash,
|
||||||
|
struct TALER_AUDITORDB_DenominationCirculationData *dcd)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance",
|
||||||
|
&dcd->denom_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss",
|
||||||
|
&dcd->denom_loss),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk",
|
||||||
|
&dcd->denom_risk),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("recoup_loss",
|
||||||
|
&dcd->recoup_loss),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("num_issued",
|
||||||
|
&dcd->num_issued),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_denomination_pending_select",
|
||||||
|
"SELECT"
|
||||||
|
" denom_balance_val"
|
||||||
|
",denom_balance_frac"
|
||||||
|
",denom_loss_val"
|
||||||
|
",denom_loss_frac"
|
||||||
|
",num_issued"
|
||||||
|
",denom_risk_val"
|
||||||
|
",denom_risk_frac"
|
||||||
|
",recoup_loss_val"
|
||||||
|
",recoup_loss_frac"
|
||||||
|
" FROM auditor_denomination_pending"
|
||||||
|
" WHERE denom_pub_hash=$1");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_denomination_pending_select",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
43
src/auditordb/pg_get_denomination_balance.h
Normal file
43
src/auditordb/pg_get_denomination_balance.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_denomination_balance.h
|
||||||
|
* @brief implementation of the get_denomination_balance function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_DENOMINATION_BALANCE_H
|
||||||
|
#define PG_GET_DENOMINATION_BALANCE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about a denomination key's balances.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param denom_pub_hash hash of the denomination public key
|
||||||
|
* @param[out] dcd circulation data to initialize
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_denomination_balance (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_DenominationHashP *denom_pub_hash,
|
||||||
|
struct TALER_AUDITORDB_DenominationCirculationData *dcd);
|
||||||
|
|
||||||
|
#endif
|
185
src/auditordb/pg_get_deposit_confirmations.c
Normal file
185
src/auditordb/pg_get_deposit_confirmations.c
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_deposit_confirmations.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_deposit_confirmations.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for #deposit_confirmation_cb().
|
||||||
|
*/
|
||||||
|
struct DepositConfirmationContext
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Master public key that is being used.
|
||||||
|
*/
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to call for each deposit confirmation.
|
||||||
|
*/
|
||||||
|
TALER_AUDITORDB_DepositConfirmationCallback cb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for @e cb
|
||||||
|
*/
|
||||||
|
void *cb_cls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin context.
|
||||||
|
*/
|
||||||
|
struct PostgresClosure *pg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query status to return.
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for #postgres_get_deposit_confirmations().
|
||||||
|
* To be called with the results of a SELECT statement
|
||||||
|
* that has returned @a num_results results.
|
||||||
|
*
|
||||||
|
* @param cls closure of type `struct DepositConfirmationContext *`
|
||||||
|
* @param result the postgres result
|
||||||
|
* @param num_results the number of results in @a result
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
deposit_confirmation_cb (void *cls,
|
||||||
|
PGresult *result,
|
||||||
|
unsigned int num_results)
|
||||||
|
{
|
||||||
|
struct DepositConfirmationContext *dcc = cls;
|
||||||
|
struct PostgresClosure *pg = dcc->pg;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < num_results; i++)
|
||||||
|
{
|
||||||
|
uint64_t serial_id;
|
||||||
|
struct TALER_AUDITORDB_DepositConfirmation dc = {
|
||||||
|
.master_public_key = *dcc->master_pub
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("serial_id",
|
||||||
|
&serial_id),
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
|
||||||
|
&dc.h_contract_terms),
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("h_extensions",
|
||||||
|
&dc.h_extensions),
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("h_wire",
|
||||||
|
&dc.h_wire),
|
||||||
|
GNUNET_PQ_result_spec_timestamp ("exchange_timestamp",
|
||||||
|
&dc.exchange_timestamp),
|
||||||
|
GNUNET_PQ_result_spec_timestamp ("refund_deadline",
|
||||||
|
&dc.refund_deadline),
|
||||||
|
GNUNET_PQ_result_spec_timestamp ("wire_deadline",
|
||||||
|
&dc.wire_deadline),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_without_fee",
|
||||||
|
&dc.amount_without_fee),
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
|
||||||
|
&dc.coin_pub),
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("merchant_pub",
|
||||||
|
&dc.merchant),
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("exchange_sig",
|
||||||
|
&dc.exchange_sig),
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("exchange_pub",
|
||||||
|
&dc.exchange_pub),
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("master_sig",
|
||||||
|
&dc.master_sig),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_PQ_extract_result (result,
|
||||||
|
rs,
|
||||||
|
i))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
dcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dcc->qs = i + 1;
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
dcc->cb (dcc->cb_cls,
|
||||||
|
serial_id,
|
||||||
|
&dc))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_deposit_confirmations (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_public_key,
|
||||||
|
uint64_t start_id,
|
||||||
|
TALER_AUDITORDB_DepositConfirmationCallback cb,
|
||||||
|
void *cb_cls)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_public_key),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&start_id),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct DepositConfirmationContext dcc = {
|
||||||
|
.master_pub = master_public_key,
|
||||||
|
.cb = cb,
|
||||||
|
.cb_cls = cb_cls,
|
||||||
|
.pg = pg
|
||||||
|
};
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_deposit_confirmation_select",
|
||||||
|
"SELECT"
|
||||||
|
" serial_id"
|
||||||
|
",h_contract_terms"
|
||||||
|
",h_extensions"
|
||||||
|
",h_wire"
|
||||||
|
",exchange_timestamp"
|
||||||
|
",wire_deadline"
|
||||||
|
",refund_deadline"
|
||||||
|
",amount_without_fee_val"
|
||||||
|
",amount_without_fee_frac"
|
||||||
|
",coin_pub"
|
||||||
|
",merchant_pub"
|
||||||
|
",exchange_sig"
|
||||||
|
",exchange_pub"
|
||||||
|
",master_sig" /* master_sig could be normalized... */
|
||||||
|
" FROM deposit_confirmations"
|
||||||
|
" WHERE master_pub=$1"
|
||||||
|
" AND serial_id>$2");
|
||||||
|
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
|
||||||
|
"auditor_deposit_confirmation_select",
|
||||||
|
params,
|
||||||
|
&deposit_confirmation_cb,
|
||||||
|
&dcc);
|
||||||
|
if (qs > 0)
|
||||||
|
return dcc.qs;
|
||||||
|
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
|
||||||
|
return qs;
|
||||||
|
}
|
48
src/auditordb/pg_get_deposit_confirmations.h
Normal file
48
src/auditordb/pg_get_deposit_confirmations.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_deposit_confirmations.h
|
||||||
|
* @brief implementation of the get_deposit_confirmations function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_DEPOSIT_CONFIRMATIONS_H
|
||||||
|
#define PG_GET_DEPOSIT_CONFIRMATIONS_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about deposit confirmations from the database.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_public_key for which exchange do we want to get deposit confirmations
|
||||||
|
* @param start_id row/serial ID where to start the iteration (0 from
|
||||||
|
* the start, exclusive, i.e. serial_ids must start from 1)
|
||||||
|
* @param cb function to call with results
|
||||||
|
* @param cb_cls closure for @a cb
|
||||||
|
* @return query result status
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_deposit_confirmations (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_public_key,
|
||||||
|
uint64_t start_id,
|
||||||
|
TALER_AUDITORDB_DepositConfirmationCallback cb,
|
||||||
|
void *cb_cls);
|
||||||
|
|
||||||
|
#endif
|
61
src/auditordb/pg_get_predicted_balance.c
Normal file
61
src/auditordb/pg_get_predicted_balance.c
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_predicted_balance.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_predicted_balance.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_predicted_balance (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_Amount *balance,
|
||||||
|
struct TALER_Amount *drained)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("balance",
|
||||||
|
balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("drained",
|
||||||
|
drained),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_predicted_result_select",
|
||||||
|
"SELECT"
|
||||||
|
" balance_val"
|
||||||
|
",balance_frac"
|
||||||
|
",drained_val"
|
||||||
|
",drained_frac"
|
||||||
|
" FROM auditor_predicted_result"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_predicted_result_select",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
44
src/auditordb/pg_get_predicted_balance.h
Normal file
44
src/auditordb/pg_get_predicted_balance.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_predicted_.h
|
||||||
|
* @brief implementation of the get_predicted_ function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_PREDICTED__H
|
||||||
|
#define PG_GET_PREDICTED__H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an exchange's predicted balance.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param[out] balance expected bank account balance of the exchange
|
||||||
|
* @param[out] drained amount drained so far
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_predicted_balance (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_Amount *balance,
|
||||||
|
struct TALER_Amount *drained);
|
||||||
|
|
||||||
|
#endif
|
97
src/auditordb/pg_get_reserve_info.c
Normal file
97
src/auditordb/pg_get_reserve_info.c
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_reserve_info.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_reserve_info.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_reserve_info (void *cls,
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
uint64_t *rowid,
|
||||||
|
struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
|
||||||
|
struct GNUNET_TIME_Timestamp *expiration_date,
|
||||||
|
char **sender_account)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance",
|
||||||
|
&rfb->reserve_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss",
|
||||||
|
&rfb->reserve_loss),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance",
|
||||||
|
&rfb->withdraw_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance",
|
||||||
|
&rfb->close_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
|
||||||
|
&rfb->purse_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance",
|
||||||
|
&rfb->open_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee_balance",
|
||||||
|
&rfb->history_fee_balance),
|
||||||
|
GNUNET_PQ_result_spec_timestamp ("expiration_date",
|
||||||
|
expiration_date),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("auditor_reserves_rowid",
|
||||||
|
rowid),
|
||||||
|
GNUNET_PQ_result_spec_allow_null (
|
||||||
|
GNUNET_PQ_result_spec_string ("origin_account",
|
||||||
|
sender_account),
|
||||||
|
NULL),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
*sender_account = NULL;
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_reserves_select",
|
||||||
|
"SELECT"
|
||||||
|
" reserve_balance_val"
|
||||||
|
",reserve_balance_frac"
|
||||||
|
",reserve_loss_val"
|
||||||
|
",reserve_loss_frac"
|
||||||
|
",withdraw_fee_balance_val"
|
||||||
|
",withdraw_fee_balance_frac"
|
||||||
|
",close_fee_balance_val"
|
||||||
|
",close_fee_balance_frac"
|
||||||
|
",purse_fee_balance_val"
|
||||||
|
",purse_fee_balance_frac"
|
||||||
|
",open_fee_balance_val"
|
||||||
|
",open_fee_balance_frac"
|
||||||
|
",history_fee_balance_val"
|
||||||
|
",history_fee_balance_frac"
|
||||||
|
",expiration_date"
|
||||||
|
",auditor_reserves_rowid"
|
||||||
|
",origin_account"
|
||||||
|
" FROM auditor_reserves"
|
||||||
|
" WHERE reserve_pub=$1 AND master_pub=$2;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_reserves_select",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
51
src/auditordb/pg_get_reserve_info.h
Normal file
51
src/auditordb/pg_get_reserve_info.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_reserve_info.h
|
||||||
|
* @brief implementation of the get_reserve_info function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_RESERVE_INFO_H
|
||||||
|
#define PG_GET_RESERVE_INFO_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about a reserve.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param reserve_pub public key of the reserve
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param[out] rowid which row did we get the information from
|
||||||
|
* @param[out] rfb where to store the reserve balance summary
|
||||||
|
* @param[out] expiration_date expiration date of the reserve
|
||||||
|
* @param[out] sender_account from where did the money in the reserve originally come from
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_reserve_info (void *cls,
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
uint64_t *rowid,
|
||||||
|
struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
|
||||||
|
struct GNUNET_TIME_Timestamp *expiration_date,
|
||||||
|
char **sender_account);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
88
src/auditordb/pg_get_reserve_summary.c
Normal file
88
src/auditordb/pg_get_reserve_summary.c
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_reserve_summary.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_reserve_summary.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get summary information about all reserves.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param[out] rfb balances are returned here
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_reserve_summary (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ReserveFeeBalance *rfb)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance",
|
||||||
|
&rfb->reserve_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss",
|
||||||
|
&rfb->reserve_loss),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance",
|
||||||
|
&rfb->withdraw_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance",
|
||||||
|
&rfb->close_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
|
||||||
|
&rfb->purse_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance",
|
||||||
|
&rfb->open_fee_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee_balance",
|
||||||
|
&rfb->history_fee_balance),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_reserve_balance_select",
|
||||||
|
"SELECT"
|
||||||
|
" reserve_balance_val"
|
||||||
|
",reserve_balance_frac"
|
||||||
|
",reserve_loss_val"
|
||||||
|
",reserve_loss_frac"
|
||||||
|
",withdraw_fee_balance_val"
|
||||||
|
",withdraw_fee_balance_frac"
|
||||||
|
",close_fee_balance_val"
|
||||||
|
",close_fee_balance_frac"
|
||||||
|
",purse_fee_balance_val"
|
||||||
|
",purse_fee_balance_frac"
|
||||||
|
",open_fee_balance_val"
|
||||||
|
",open_fee_balance_frac"
|
||||||
|
",history_fee_balance_val"
|
||||||
|
",history_fee_balance_frac"
|
||||||
|
" FROM auditor_reserve_balance"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_reserve_balance_select",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
43
src/auditordb/pg_get_reserve_summary.h
Normal file
43
src/auditordb/pg_get_reserve_summary.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_reserve_summary.h
|
||||||
|
* @brief implementation of the get_reserve_summary function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_RESERVE_SUMMARY_H
|
||||||
|
#define PG_GET_RESERVE_SUMMARY_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get summary information about all reserves.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param[out] rfb balances are returned here
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_reserve_summary (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
68
src/auditordb/pg_get_wire_auditor_account_progress.c
Normal file
68
src/auditordb/pg_get_wire_auditor_account_progress.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_wire_auditor_account_progress.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_wire_auditor_account_progress.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_wire_auditor_account_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const char *account_name,
|
||||||
|
struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
|
||||||
|
struct TALER_AUDITORDB_BankAccountProgressPoint *bapp)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_string (account_name),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_wire_reserve_in_serial_id",
|
||||||
|
&pp->last_reserve_in_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_wire_wire_out_serial_id",
|
||||||
|
&pp->last_wire_out_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("wire_in_off",
|
||||||
|
&bapp->in_wire_off),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("wire_out_off",
|
||||||
|
&bapp->out_wire_off),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"wire_auditor_account_progress_select",
|
||||||
|
"SELECT"
|
||||||
|
" last_wire_reserve_in_serial_id"
|
||||||
|
",last_wire_wire_out_serial_id"
|
||||||
|
",wire_in_off"
|
||||||
|
",wire_out_off"
|
||||||
|
" FROM wire_auditor_account_progress"
|
||||||
|
" WHERE master_pub=$1 AND account_name=$2;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"wire_auditor_account_progress_select",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
48
src/auditordb/pg_get_wire_auditor_account_progress.h
Normal file
48
src/auditordb/pg_get_wire_auditor_account_progress.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_wire_auditor_account_progress.h
|
||||||
|
* @brief implementation of the get_wire_auditor_account_progress function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
|
||||||
|
#define PG_GET_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about the progress of the auditor.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param account_name name of the wire account we are auditing
|
||||||
|
* @param[out] pp where is the auditor in processing
|
||||||
|
* @param[out] bapp how far are we in the wire transaction histories
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_wire_auditor_account_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const char *account_name,
|
||||||
|
struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
|
||||||
|
struct TALER_AUDITORDB_BankAccountProgressPoint *bapp);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
59
src/auditordb/pg_get_wire_auditor_progress.c
Normal file
59
src/auditordb/pg_get_wire_auditor_progress.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_wire_auditor_progress.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_wire_auditor_progress.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_wire_auditor_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_WireProgressPoint *pp)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_timestamp ("last_timestamp",
|
||||||
|
&pp->last_timestamp),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_reserve_close_uuid",
|
||||||
|
&pp->last_reserve_close_uuid),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"wire_auditor_progress_select",
|
||||||
|
"SELECT"
|
||||||
|
" last_timestamp"
|
||||||
|
",last_reserve_close_uuid"
|
||||||
|
" FROM wire_auditor_progress"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"wire_auditor_progress_select",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
44
src/auditordb/pg_get_wire_auditor_progress.h
Normal file
44
src/auditordb/pg_get_wire_auditor_progress.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_wire_auditor_progress.h
|
||||||
|
* @brief implementation of the get_wire_auditor_progress function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_WIRE_AUDITOR_PROGRESS_H
|
||||||
|
#define PG_GET_WIRE_AUDITOR_PROGRESS_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about the progress of the auditor.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param[out] pp set to where the auditor is in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_wire_auditor_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_WireProgressPoint *pp);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
64
src/auditordb/pg_get_wire_fee_summary.c
Normal file
64
src/auditordb/pg_get_wire_fee_summary.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_wire_fee_summary.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_get_wire_fee_summary.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get summary information about an exchanges wire fee balance.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param[out] wire_fee_balance set amount the exchange gained in wire fees
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_wire_fee_summary (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_Amount *wire_fee_balance)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee_balance",
|
||||||
|
wire_fee_balance),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_wire_fee_balance_select",
|
||||||
|
"SELECT"
|
||||||
|
" wire_fee_balance_val"
|
||||||
|
",wire_fee_balance_frac"
|
||||||
|
" FROM auditor_wire_fee_balance"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||||
|
"auditor_wire_fee_balance_select",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
43
src/auditordb/pg_get_wire_fee_summary.h
Normal file
43
src/auditordb/pg_get_wire_fee_summary.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_get_wire_fee_summary.h
|
||||||
|
* @brief implementation of the get_wire_fee_summary function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_GET_WIRE_FEE_SUMMARY_H
|
||||||
|
#define PG_GET_WIRE_FEE_SUMMARY_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get summary information about an exchanges wire fee balance.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param[out] wire_fee_balance set amount the exchange gained in wire fees
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_get_wire_fee_summary (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_Amount *wire_fee_balance);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
130
src/auditordb/pg_helper.h
Normal file
130
src/auditordb/pg_helper.h
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_helper.h
|
||||||
|
* @brief shared internal definitions for postgres DB plugin
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_HELPER_H
|
||||||
|
#define PG_HELPER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of the "cls" argument given to each of the functions in
|
||||||
|
* our API.
|
||||||
|
*/
|
||||||
|
struct PostgresClosure
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Postgres connection handle.
|
||||||
|
*/
|
||||||
|
struct GNUNET_PQ_Context *conn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the ongoing transaction, used to debug cases where
|
||||||
|
* a transaction is not properly terminated via COMMIT or
|
||||||
|
* ROLLBACK.
|
||||||
|
*/
|
||||||
|
const char *transaction_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our configuration.
|
||||||
|
*/
|
||||||
|
const struct GNUNET_CONFIGURATION_Handle *cfg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How often have we connected to the DB so far?
|
||||||
|
*/
|
||||||
|
unsigned long long prep_gen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which currency should we assume all amounts to be in?
|
||||||
|
*/
|
||||||
|
char *currency;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares SQL statement @a sql under @a name for
|
||||||
|
* connection @a pg once.
|
||||||
|
* Returns with #GNUNET_DB_STATUS_HARD_ERROR on failure.
|
||||||
|
*
|
||||||
|
* @param pg a `struct PostgresClosure`
|
||||||
|
* @param name name to prepare the statement under
|
||||||
|
* @param sql actual SQL text
|
||||||
|
*/
|
||||||
|
#define PREPARE(pg,name,sql) \
|
||||||
|
do { \
|
||||||
|
static struct { \
|
||||||
|
unsigned long long cnt; \
|
||||||
|
struct PostgresClosure *pg; \
|
||||||
|
} preps[2]; /* 2 ctrs for taler-auditor-sync*/ \
|
||||||
|
unsigned int off = 0; \
|
||||||
|
\
|
||||||
|
while ( (NULL != preps[off].pg) && \
|
||||||
|
(pg != preps[off].pg) && \
|
||||||
|
(off < sizeof(preps) / sizeof(*preps)) ) \
|
||||||
|
off++; \
|
||||||
|
GNUNET_assert (off < \
|
||||||
|
sizeof(preps) / sizeof(*preps)); \
|
||||||
|
if (preps[off].cnt < pg->prep_gen) \
|
||||||
|
{ \
|
||||||
|
struct GNUNET_PQ_PreparedStatement ps[] = { \
|
||||||
|
GNUNET_PQ_make_prepare (name, sql), \
|
||||||
|
GNUNET_PQ_PREPARED_STATEMENT_END \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
if (GNUNET_OK != \
|
||||||
|
GNUNET_PQ_prepare_statements (pg->conn, \
|
||||||
|
ps)) \
|
||||||
|
{ \
|
||||||
|
GNUNET_break (0); \
|
||||||
|
return GNUNET_DB_STATUS_HARD_ERROR; \
|
||||||
|
} \
|
||||||
|
preps[off].pg = pg; \
|
||||||
|
preps[off].cnt = pg->prep_gen; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper macro to add the currency from the plugin's state
|
||||||
|
* when fetching amounts from the database.
|
||||||
|
*
|
||||||
|
* @param field name of the database field to fetch amount from
|
||||||
|
* @param[out] amountp pointer to amount to set
|
||||||
|
*/
|
||||||
|
#define TALER_PQ_RESULT_SPEC_AMOUNT(field,amountp) TALER_PQ_result_spec_amount ( \
|
||||||
|
field,pg->currency,amountp)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper macro to add the currency from the plugin's state
|
||||||
|
* when fetching amounts from the database. NBO variant.
|
||||||
|
*
|
||||||
|
* @param field name of the database field to fetch amount from
|
||||||
|
* @param[out] amountp pointer to amount to set
|
||||||
|
*/
|
||||||
|
#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(field, \
|
||||||
|
amountp) TALER_PQ_result_spec_amount_nbo ( \
|
||||||
|
field,pg->currency,amountp)
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
51
src/auditordb/pg_insert_auditor_progress_aggregation.c
Normal file
51
src/auditordb/pg_insert_auditor_progress_aggregation.c
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_aggregation.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_auditor_progress_aggregation.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_aggregation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointAggregation *ppa)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_insert_aggregation",
|
||||||
|
"INSERT INTO auditor_progress_aggregation "
|
||||||
|
"(master_pub"
|
||||||
|
",last_wire_out_serial_id"
|
||||||
|
") VALUES ($1,$2);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_insert_aggregation",
|
||||||
|
params);
|
||||||
|
}
|
45
src/auditordb/pg_insert_auditor_progress_aggregation.h
Normal file
45
src/auditordb/pg_insert_auditor_progress_aggregation.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_aggregation.h
|
||||||
|
* @brief implementation of the insert_auditor_progress_aggregation function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_AUDITOR_PROGRESS_AGGREGATION_H
|
||||||
|
#define PG_INSERT_AUDITOR_PROGRESS_AGGREGATION_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the auditor's progress with an exchange's
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppa where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_aggregation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
65
src/auditordb/pg_insert_auditor_progress_coin.c
Normal file
65
src/auditordb/pg_insert_auditor_progress_coin.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_coin.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_auditor_progress_coin.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_coin (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointCoin *ppc)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_recoup_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_recoup_refresh_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_purse_deposits_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_purse_refunds_serial_id),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_insert_coin",
|
||||||
|
"INSERT INTO auditor_progress_coin "
|
||||||
|
"(master_pub"
|
||||||
|
",last_withdraw_serial_id"
|
||||||
|
",last_deposit_serial_id"
|
||||||
|
",last_melt_serial_id"
|
||||||
|
",last_refund_serial_id"
|
||||||
|
",last_recoup_serial_id"
|
||||||
|
",last_recoup_refresh_serial_id"
|
||||||
|
",last_purse_deposits_serial_id"
|
||||||
|
",last_purse_decision_serial_id"
|
||||||
|
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_insert_coin",
|
||||||
|
params);
|
||||||
|
}
|
44
src/auditordb/pg_insert_auditor_progress_coin.h
Normal file
44
src/auditordb/pg_insert_auditor_progress_coin.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_coin.h
|
||||||
|
* @brief implementation of the insert_auditor_progress_coin function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_AUDITOR_PROGRESS_COIN_H
|
||||||
|
#define PG_INSERT_AUDITOR_PROGRESS_COIN_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the auditor's progress with an exchange's
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppc where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_coin (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointCoin *ppc);
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_deposit_confirmation.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_auditor_progress_deposit_confirmation.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_deposit_confirmation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppdc->last_deposit_confirmation_serial_id),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_insert_deposit_confirmation",
|
||||||
|
"INSERT INTO auditor_progress_deposit_confirmation "
|
||||||
|
"(master_pub"
|
||||||
|
",last_deposit_confirmation_serial_id"
|
||||||
|
") VALUES ($1,$2);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_insert_deposit_confirmation",
|
||||||
|
params);
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_deposit_confirmation.h
|
||||||
|
* @brief implementation of the insert_auditor_progress_deposit_confirmation function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
|
||||||
|
#define PG_INSERT_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the auditor's progress with an exchange's
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppdc where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_deposit_confirmation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc);
|
||||||
|
|
||||||
|
#endif
|
59
src/auditordb/pg_insert_auditor_progress_purse.c
Normal file
59
src/auditordb/pg_insert_auditor_progress_purse.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_purse.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_auditor_progress_purse.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_purse (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointPurse *ppp)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_purse_request_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_purse_decision_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_purse_merge_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_account_merge_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_purse_deposits_serial_id),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_insert_purse",
|
||||||
|
"INSERT INTO auditor_progress_purse "
|
||||||
|
"(master_pub"
|
||||||
|
",last_purse_request_serial_id"
|
||||||
|
",last_purse_decision_serial_id"
|
||||||
|
",last_purse_merges_serial_id"
|
||||||
|
",last_account_merges_serial_id"
|
||||||
|
",last_purse_deposits_serial_id"
|
||||||
|
") VALUES ($1,$2,$3,$4,$5,$6);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_insert_purse",
|
||||||
|
params);
|
||||||
|
}
|
44
src/auditordb/pg_insert_auditor_progress_purse.h
Normal file
44
src/auditordb/pg_insert_auditor_progress_purse.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_purse.h
|
||||||
|
* @brief implementation of the insert_auditor_progress_purse function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_AUDITOR_PROGRESS_PURSE_H
|
||||||
|
#define PG_INSERT_AUDITOR_PROGRESS_PURSE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the auditor's progress with an exchange's
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppp where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_purse (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointPurse *ppp);
|
||||||
|
|
||||||
|
#endif
|
65
src/auditordb/pg_insert_auditor_progress_reserve.c
Normal file
65
src/auditordb/pg_insert_auditor_progress_reserve.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_reserve.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_auditor_progress_reserve.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_reserve (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointReserve *ppr)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_out_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_recoup_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_open_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_close_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_purse_decisions_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_account_merges_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_history_requests_serial_id),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_insert_reserve",
|
||||||
|
"INSERT INTO auditor_progress_reserve "
|
||||||
|
"(master_pub"
|
||||||
|
",last_reserve_in_serial_id"
|
||||||
|
",last_reserve_out_serial_id"
|
||||||
|
",last_reserve_recoup_serial_id"
|
||||||
|
",last_reserve_open_serial_id"
|
||||||
|
",last_reserve_close_serial_id"
|
||||||
|
",last_purse_decision_serial_id"
|
||||||
|
",last_account_merges_serial_id"
|
||||||
|
",last_history_requests_serial_id"
|
||||||
|
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_insert_reserve",
|
||||||
|
params);
|
||||||
|
}
|
43
src/auditordb/pg_insert_auditor_progress_reserve.h
Normal file
43
src/auditordb/pg_insert_auditor_progress_reserve.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_auditor_progress_reserve.h
|
||||||
|
* @brief implementation of the insert_auditor_progress_reserve function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_AUDITOR_PROGRESS_RESERVE_H
|
||||||
|
#define PG_INSERT_AUDITOR_PROGRESS_RESERVE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the auditor's progress with an exchange's
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppr where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_auditor_progress_reserve (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointReserve *ppr);
|
||||||
|
|
||||||
|
#endif
|
77
src/auditordb/pg_insert_balance_summary.c
Normal file
77
src/auditordb/pg_insert_balance_summary.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_balance_summary.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_balance_summary.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_balance_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_GlobalCoinBalance *dfb)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->total_escrowed),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->deposit_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->melt_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->refund_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->purse_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->open_deposit_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->risk),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->loss),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->irregular_loss),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_balance_summary_insert",
|
||||||
|
"INSERT INTO auditor_balance_summary "
|
||||||
|
"(master_pub"
|
||||||
|
",denom_balance_val"
|
||||||
|
",denom_balance_frac"
|
||||||
|
",deposit_fee_balance_val"
|
||||||
|
",deposit_fee_balance_frac"
|
||||||
|
",melt_fee_balance_val"
|
||||||
|
",melt_fee_balance_frac"
|
||||||
|
",refund_fee_balance_val"
|
||||||
|
",refund_fee_balance_frac"
|
||||||
|
",purse_fee_balance_val"
|
||||||
|
",purse_fee_balance_frac"
|
||||||
|
",open_deposit_fee_balance_val"
|
||||||
|
",open_deposit_fee_balance_frac"
|
||||||
|
",risk_val"
|
||||||
|
",risk_frac"
|
||||||
|
",loss_val"
|
||||||
|
",loss_frac"
|
||||||
|
",irregular_loss_val"
|
||||||
|
",irregular_loss_frac"
|
||||||
|
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,"
|
||||||
|
" $11,$12,$13,$14,$15,$16,$17,$18,$19);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_balance_summary_insert",
|
||||||
|
params);
|
||||||
|
}
|
44
src/auditordb/pg_insert_balance_summary.h
Normal file
44
src/auditordb/pg_insert_balance_summary.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_balance_summary.h
|
||||||
|
* @brief implementation of the insert_balance_summary function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_BALANCE_SUMMARY_H
|
||||||
|
#define PG_INSERT_BALANCE_SUMMARY_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about an exchange's denomination balances. There
|
||||||
|
* must not be an existing record for the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param dfb denomination balance data to store
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_balance_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_GlobalCoinBalance *dfb);
|
||||||
|
|
||||||
|
#endif
|
65
src/auditordb/pg_insert_denomination_balance.c
Normal file
65
src/auditordb/pg_insert_denomination_balance.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_denomination_balance.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_denomination_balance.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_denomination_balance (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_DenominationHashP *denom_pub_hash,
|
||||||
|
const struct TALER_AUDITORDB_DenominationCirculationData *dcd)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
|
||||||
|
TALER_PQ_query_param_amount (&dcd->denom_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dcd->denom_loss),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&dcd->num_issued),
|
||||||
|
TALER_PQ_query_param_amount (&dcd->denom_risk),
|
||||||
|
TALER_PQ_query_param_amount (&dcd->recoup_loss),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_denomination_pending_insert",
|
||||||
|
"INSERT INTO auditor_denomination_pending "
|
||||||
|
"(denom_pub_hash"
|
||||||
|
",denom_balance_val"
|
||||||
|
",denom_balance_frac"
|
||||||
|
",denom_loss_val"
|
||||||
|
",denom_loss_frac"
|
||||||
|
",num_issued"
|
||||||
|
",denom_risk_val"
|
||||||
|
",denom_risk_frac"
|
||||||
|
",recoup_loss_val"
|
||||||
|
",recoup_loss_frac"
|
||||||
|
") VALUES ("
|
||||||
|
"$1,$2,$3,$4,$5,$6,$7,$8,$9,$10"
|
||||||
|
");");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_denomination_pending_insert",
|
||||||
|
params);
|
||||||
|
}
|
45
src/auditordb/pg_insert_denomination_balance.h
Normal file
45
src/auditordb/pg_insert_denomination_balance.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_denomination_balance.h
|
||||||
|
* @brief implementation of the insert_denomination_balance function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_DENOMINATION_BALANCE_H
|
||||||
|
#define PG_INSERT_DENOMINATION_BALANCE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about a denomination key's balances. There
|
||||||
|
* must not be an existing record for the denomination key.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param denom_pub_hash hash of the denomination public key
|
||||||
|
* @param dcd circulation data to store
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_denomination_balance (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_DenominationHashP *denom_pub_hash,
|
||||||
|
const struct TALER_AUDITORDB_DenominationCirculationData *dcd);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
73
src/auditordb/pg_insert_deposit_confirmation.c
Normal file
73
src/auditordb/pg_insert_deposit_confirmation.c
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_deposit_confirmation.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_deposit_confirmation.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_deposit_confirmation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_AUDITORDB_DepositConfirmation *dc)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&dc->master_public_key),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&dc->h_contract_terms),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&dc->h_extensions),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&dc->h_wire),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&dc->exchange_timestamp),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&dc->wire_deadline),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&dc->refund_deadline),
|
||||||
|
TALER_PQ_query_param_amount (&dc->amount_without_fee),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&dc->coin_pub),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&dc->merchant),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&dc->exchange_sig),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&dc->exchange_pub),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&dc->master_sig),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_deposit_confirmation_insert",
|
||||||
|
"INSERT INTO deposit_confirmations "
|
||||||
|
"(master_pub"
|
||||||
|
",h_contract_terms"
|
||||||
|
",h_extensions"
|
||||||
|
",h_wire"
|
||||||
|
",exchange_timestamp"
|
||||||
|
",wire_deadline"
|
||||||
|
",refund_deadline"
|
||||||
|
",amount_without_fee_val"
|
||||||
|
",amount_without_fee_frac"
|
||||||
|
",coin_pub"
|
||||||
|
",merchant_pub"
|
||||||
|
",exchange_sig"
|
||||||
|
",exchange_pub"
|
||||||
|
",master_sig" /* master_sig could be normalized... */
|
||||||
|
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_deposit_confirmation_insert",
|
||||||
|
params);
|
||||||
|
}
|
42
src/auditordb/pg_insert_deposit_confirmation.h
Normal file
42
src/auditordb/pg_insert_deposit_confirmation.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_deposit_confirmation.h
|
||||||
|
* @brief implementation of the insert_deposit_confirmation function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_DEPOSIT_CONFIRMATION_H
|
||||||
|
#define PG_INSERT_DEPOSIT_CONFIRMATION_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about a deposit confirmation into the database.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param dc deposit confirmation information to store
|
||||||
|
* @return query result status
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_deposit_confirmation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_AUDITORDB_DepositConfirmation *dc);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
49
src/auditordb/pg_insert_exchange.c
Normal file
49
src/auditordb/pg_insert_exchange.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_exchange.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_exchange.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_exchange (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const char *exchange_url)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_string (exchange_url),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_insert_exchange",
|
||||||
|
"INSERT INTO auditor_exchanges "
|
||||||
|
"(master_pub"
|
||||||
|
",exchange_url"
|
||||||
|
") VALUES ($1,$2);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_insert_exchange",
|
||||||
|
params);
|
||||||
|
}
|
43
src/auditordb/pg_insert_exchange.h
Normal file
43
src/auditordb/pg_insert_exchange.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_exchange.h
|
||||||
|
* @brief implementation of the insert_exchange function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_EXCHANGE_H
|
||||||
|
#define PG_INSERT_EXCHANGE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about an exchange this auditor will be auditing.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param exchange_url public (base) URL of the API of the exchange
|
||||||
|
* @return query result status
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_exchange (void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const char *exchange_url);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
58
src/auditordb/pg_insert_exchange_signkey.c
Normal file
58
src/auditordb/pg_insert_exchange_signkey.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_exchange_signkey.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_exchange_signkey.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_exchange_signkey (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_AUDITORDB_ExchangeSigningKey *sk)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&sk->master_public_key),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&sk->ep_start),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&sk->ep_expire),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&sk->ep_end),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&sk->exchange_pub),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (&sk->master_sig),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_insert_exchange_signkey",
|
||||||
|
"INSERT INTO auditor_exchange_signkeys "
|
||||||
|
"(master_pub"
|
||||||
|
",ep_start"
|
||||||
|
",ep_expire"
|
||||||
|
",ep_end"
|
||||||
|
",exchange_pub"
|
||||||
|
",master_sig"
|
||||||
|
") VALUES ($1,$2,$3,$4,$5,$6);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_insert_exchange_signkey",
|
||||||
|
params);
|
||||||
|
}
|
41
src/auditordb/pg_insert_exchange_signkey.h
Normal file
41
src/auditordb/pg_insert_exchange_signkey.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_exchange_signkey.h
|
||||||
|
* @brief implementation of the insert_exchange_signkey function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_EXCHANGE_SIGNKEY_H
|
||||||
|
#define PG_INSERT_EXCHANGE_SIGNKEY_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about a signing key of the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param sk signing key information to store
|
||||||
|
* @return query result status
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_exchange_signkey (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_AUDITORDB_ExchangeSigningKey *sk);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
62
src/auditordb/pg_insert_historic_denom_revenue.c
Normal file
62
src/auditordb/pg_insert_historic_denom_revenue.c
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_historic_denom_revenue.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_historic_denom_revenue.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_historic_denom_revenue (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_DenominationHashP *denom_pub_hash,
|
||||||
|
struct GNUNET_TIME_Timestamp revenue_timestamp,
|
||||||
|
const struct TALER_Amount *revenue_balance,
|
||||||
|
const struct TALER_Amount *loss_balance)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&revenue_timestamp),
|
||||||
|
TALER_PQ_query_param_amount (revenue_balance),
|
||||||
|
TALER_PQ_query_param_amount (loss_balance),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_historic_denomination_revenue_insert",
|
||||||
|
"INSERT INTO auditor_historic_denomination_revenue"
|
||||||
|
"(master_pub"
|
||||||
|
",denom_pub_hash"
|
||||||
|
",revenue_timestamp"
|
||||||
|
",revenue_balance_val"
|
||||||
|
",revenue_balance_frac"
|
||||||
|
",loss_balance_val"
|
||||||
|
",loss_balance_frac"
|
||||||
|
") VALUES ($1,$2,$3,$4,$5,$6,$7);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_historic_denomination_revenue_insert",
|
||||||
|
params);
|
||||||
|
}
|
52
src/auditordb/pg_insert_historic_denom_revenue.h
Normal file
52
src/auditordb/pg_insert_historic_denom_revenue.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_historic_denom_revenue.h
|
||||||
|
* @brief implementation of the insert_historic_denom_revenue function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_HISTORIC_DENOM_REVENUE_H
|
||||||
|
#define PG_INSERT_HISTORIC_DENOM_REVENUE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about an exchange's historic
|
||||||
|
* revenue about a denomination key.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param denom_pub_hash hash of the denomination key
|
||||||
|
* @param revenue_timestamp when did this profit get realized
|
||||||
|
* @param revenue_balance what was the total profit made from
|
||||||
|
* deposit fees, melting fees, refresh fees
|
||||||
|
* and coins that were never returned?
|
||||||
|
* @param loss_balance total losses suffered by the exchange at the time
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_historic_denom_revenue (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_DenominationHashP *denom_pub_hash,
|
||||||
|
struct GNUNET_TIME_Timestamp revenue_timestamp,
|
||||||
|
const struct TALER_Amount *revenue_balance,
|
||||||
|
const struct TALER_Amount *loss_balance);
|
||||||
|
|
||||||
|
#endif
|
57
src/auditordb/pg_insert_historic_reserve_revenue.c
Normal file
57
src/auditordb/pg_insert_historic_reserve_revenue.c
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_historic_reserve_revenue.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_historic_reserve_revenue.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_historic_reserve_revenue (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct GNUNET_TIME_Timestamp start_time,
|
||||||
|
struct GNUNET_TIME_Timestamp end_time,
|
||||||
|
const struct TALER_Amount *reserve_profits)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&start_time),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&end_time),
|
||||||
|
TALER_PQ_query_param_amount (reserve_profits),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_historic_reserve_summary_insert",
|
||||||
|
"INSERT INTO auditor_historic_reserve_summary"
|
||||||
|
"(master_pub"
|
||||||
|
",start_date"
|
||||||
|
",end_date"
|
||||||
|
",reserve_profits_val"
|
||||||
|
",reserve_profits_frac"
|
||||||
|
") VALUES ($1,$2,$3,$4,$5);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_historic_reserve_summary_insert",
|
||||||
|
params);
|
||||||
|
}
|
47
src/auditordb/pg_insert_historic_reserve_revenue.h
Normal file
47
src/auditordb/pg_insert_historic_reserve_revenue.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_historic_reserve_revenue.h
|
||||||
|
* @brief implementation of the insert_historic_reserve_revenue function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_HISTORIC_RESERVE_REVENUE_H
|
||||||
|
#define PG_INSERT_HISTORIC_RESERVE_REVENUE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about an exchange's historic revenue from reserves.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param start_time beginning of aggregated time interval
|
||||||
|
* @param end_time end of aggregated time interval
|
||||||
|
* @param reserve_profits total profits made
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_historic_reserve_revenue (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct GNUNET_TIME_Timestamp start_time,
|
||||||
|
struct GNUNET_TIME_Timestamp end_time,
|
||||||
|
const struct TALER_Amount *reserve_profits);
|
||||||
|
|
||||||
|
#endif
|
56
src/auditordb/pg_insert_predicted_result.c
Normal file
56
src/auditordb/pg_insert_predicted_result.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_predicted_result.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_predicted_result.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_predicted_result (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_Amount *balance,
|
||||||
|
const struct TALER_Amount *drained)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
TALER_PQ_query_param_amount (balance),
|
||||||
|
TALER_PQ_query_param_amount (drained),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_predicted_result_insert",
|
||||||
|
"INSERT INTO auditor_predicted_result"
|
||||||
|
"(master_pub"
|
||||||
|
",balance_val"
|
||||||
|
",balance_frac"
|
||||||
|
",drained_val"
|
||||||
|
",drained_frac"
|
||||||
|
") VALUES ($1,$2,$3,$4,$5);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_predicted_result_insert",
|
||||||
|
params);
|
||||||
|
}
|
46
src/auditordb/pg_insert_predicted_result.h
Normal file
46
src/auditordb/pg_insert_predicted_result.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_predicted_result.h
|
||||||
|
* @brief implementation of the insert_predicted_result function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_PREDICTED_RESULT_H
|
||||||
|
#define PG_INSERT_PREDICTED_RESULT_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the predicted exchange's bank
|
||||||
|
* account balance.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param balance what the bank account balance of the exchange should show
|
||||||
|
* @param drained amount that was drained in profits
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_predicted_result (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_Amount *balance,
|
||||||
|
const struct TALER_Amount *drained);
|
||||||
|
|
||||||
|
#endif
|
84
src/auditordb/pg_insert_reserve_info.c
Normal file
84
src/auditordb/pg_insert_reserve_info.c
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_reserve_info.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_reserve_info.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_reserve_info (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
|
||||||
|
struct GNUNET_TIME_Timestamp expiration_date,
|
||||||
|
const char *origin_account)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->reserve_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->reserve_loss),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->close_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->purse_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->open_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->history_fee_balance),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&expiration_date),
|
||||||
|
NULL == origin_account
|
||||||
|
? GNUNET_PQ_query_param_null ()
|
||||||
|
: GNUNET_PQ_query_param_string (origin_account),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_reserves_insert",
|
||||||
|
"INSERT INTO auditor_reserves "
|
||||||
|
"(reserve_pub"
|
||||||
|
",master_pub"
|
||||||
|
",reserve_balance_val"
|
||||||
|
",reserve_balance_frac"
|
||||||
|
",reserve_loss_val"
|
||||||
|
",reserve_loss_frac"
|
||||||
|
",withdraw_fee_balance_val"
|
||||||
|
",withdraw_fee_balance_frac"
|
||||||
|
",close_fee_balance_val"
|
||||||
|
",close_fee_balance_frac"
|
||||||
|
",purse_fee_balance_val"
|
||||||
|
",purse_fee_balance_frac"
|
||||||
|
",open_fee_balance_val"
|
||||||
|
",open_fee_balance_frac"
|
||||||
|
",history_fee_balance_val"
|
||||||
|
",history_fee_balance_frac"
|
||||||
|
",expiration_date"
|
||||||
|
",origin_account"
|
||||||
|
|
||||||
|
") VALUES "
|
||||||
|
"($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18);");
|
||||||
|
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_reserves_insert",
|
||||||
|
params);
|
||||||
|
}
|
50
src/auditordb/pg_insert_reserve_info.h
Normal file
50
src/auditordb/pg_insert_reserve_info.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_reserve_info.h
|
||||||
|
* @brief implementation of the insert_reserve_info function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_RESERVE_INFO_H
|
||||||
|
#define PG_INSERT_RESERVE_INFO_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about a reserve. There must not be an
|
||||||
|
* existing record for the reserve.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param reserve_pub public key of the reserve
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param rfb balance amounts for the reserve
|
||||||
|
* @param expiration_date when will the reserve expire
|
||||||
|
* @param origin_account where did the money in the reserve originally come from
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_reserve_info (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
|
||||||
|
struct GNUNET_TIME_Timestamp expiration_date,
|
||||||
|
const char *origin_account);
|
||||||
|
|
||||||
|
#endif
|
75
src/auditordb/pg_insert_reserve_summary.c
Normal file
75
src/auditordb/pg_insert_reserve_summary.c
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_reserve_summary.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_reserve_summary.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_reserve_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->reserve_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->reserve_loss),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->close_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->purse_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->open_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->history_fee_balance),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_reserve_balance_insert",
|
||||||
|
"INSERT INTO auditor_reserve_balance"
|
||||||
|
"(master_pub"
|
||||||
|
",reserve_balance_val"
|
||||||
|
",reserve_balance_frac"
|
||||||
|
",reserve_loss_val"
|
||||||
|
",reserve_loss_frac"
|
||||||
|
",withdraw_fee_balance_val"
|
||||||
|
",withdraw_fee_balance_frac"
|
||||||
|
",close_fee_balance_val"
|
||||||
|
",close_fee_balance_frac"
|
||||||
|
",purse_fee_balance_val"
|
||||||
|
",purse_fee_balance_frac"
|
||||||
|
",open_fee_balance_val"
|
||||||
|
",open_fee_balance_frac"
|
||||||
|
",history_fee_balance_val"
|
||||||
|
",history_fee_balance_frac"
|
||||||
|
") VALUES "
|
||||||
|
"($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)");
|
||||||
|
GNUNET_assert (GNUNET_YES ==
|
||||||
|
TALER_amount_cmp_currency (&rfb->reserve_balance,
|
||||||
|
&rfb->withdraw_fee_balance));
|
||||||
|
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_reserve_balance_insert",
|
||||||
|
params);
|
||||||
|
}
|
45
src/auditordb/pg_insert_reserve_summary.h
Normal file
45
src/auditordb/pg_insert_reserve_summary.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_reserve_summary.h
|
||||||
|
* @brief implementation of the insert_reserve_summary function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_RESERVE_SUMMARY_H
|
||||||
|
#define PG_INSERT_RESERVE_SUMMARY_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about all reserves. There must not be an
|
||||||
|
* existing record for the @a master_pub.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param rfb balances to be stored for the reserve
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_reserve_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
61
src/auditordb/pg_insert_wire_auditor_account_progress.c
Normal file
61
src/auditordb/pg_insert_wire_auditor_account_progress.c
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_wire_auditor_account_progress.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_wire_auditor_account_progress.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_wire_auditor_account_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const char *account_name,
|
||||||
|
const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
|
||||||
|
const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_string (account_name),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&bapp->in_wire_off),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&bapp->out_wire_off),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"wire_auditor_account_progress_insert",
|
||||||
|
"INSERT INTO wire_auditor_account_progress "
|
||||||
|
"(master_pub"
|
||||||
|
",account_name"
|
||||||
|
",last_wire_reserve_in_serial_id"
|
||||||
|
",last_wire_wire_out_serial_id"
|
||||||
|
",wire_in_off"
|
||||||
|
",wire_out_off"
|
||||||
|
") VALUES ($1,$2,$3,$4,$5,$6);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"wire_auditor_account_progress_insert",
|
||||||
|
params);
|
||||||
|
}
|
48
src/auditordb/pg_insert_wire_auditor_account_progress.h
Normal file
48
src/auditordb/pg_insert_wire_auditor_account_progress.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_wire_auditor_account_progress.h
|
||||||
|
* @brief implementation of the insert_wire_auditor_account_progress function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
|
||||||
|
#define PG_INSERT_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the auditor's progress with an exchange's
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param account_name name of the wire account we are auditing
|
||||||
|
* @param pp how far are we in the auditor's tables
|
||||||
|
* @param bapp progress in wire transaction histories
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_wire_auditor_account_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const char *account_name,
|
||||||
|
const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
|
||||||
|
const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp);
|
||||||
|
|
||||||
|
#endif
|
53
src/auditordb/pg_insert_wire_auditor_progress.c
Normal file
53
src/auditordb/pg_insert_wire_auditor_progress.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_wire_auditor_progress.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_wire_auditor_progress.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_wire_auditor_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_WireProgressPoint *pp)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&pp->last_timestamp),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_close_uuid),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"wire_auditor_progress_insert",
|
||||||
|
"INSERT INTO wire_auditor_progress "
|
||||||
|
"(master_pub"
|
||||||
|
",last_timestamp"
|
||||||
|
",last_reserve_close_uuid"
|
||||||
|
") VALUES ($1,$2,$3);");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"wire_auditor_progress_insert",
|
||||||
|
params);
|
||||||
|
}
|
45
src/auditordb/pg_insert_wire_auditor_progress.h
Normal file
45
src/auditordb/pg_insert_wire_auditor_progress.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_wire_auditor_progress.h
|
||||||
|
* @brief implementation of the insert_wire_auditor_progress function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_WIRE_AUDITOR_PROGRESS_H
|
||||||
|
#define PG_INSERT_WIRE_AUDITOR_PROGRESS_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the auditor's progress with an exchange's
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param pp where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_wire_auditor_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_WireProgressPoint *pp);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
52
src/auditordb/pg_insert_wire_fee_summary.c
Normal file
52
src/auditordb/pg_insert_wire_fee_summary.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_wire_fee_summary.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_insert_wire_fee_summary.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_wire_fee_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_Amount *wire_fee_balance)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
TALER_PQ_query_param_amount (wire_fee_balance),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_wire_fee_balance_insert",
|
||||||
|
"INSERT INTO auditor_wire_fee_balance"
|
||||||
|
"(master_pub"
|
||||||
|
",wire_fee_balance_val"
|
||||||
|
",wire_fee_balance_frac"
|
||||||
|
") VALUES ($1,$2,$3)");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_wire_fee_balance_insert",
|
||||||
|
params);
|
||||||
|
}
|
44
src/auditordb/pg_insert_wire_fee_summary.h
Normal file
44
src/auditordb/pg_insert_wire_fee_summary.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_insert_wire_fee_summary.h
|
||||||
|
* @brief implementation of the insert_wire_fee_summary function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_INSERT_WIRE_FEE_SUMMARY_H
|
||||||
|
#define PG_INSERT_WIRE_FEE_SUMMARY_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about exchange's wire fee balance. There must not be an
|
||||||
|
* existing record for the same @a master_pub.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param wire_fee_balance amount the exchange gained in wire fees
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_insert_wire_fee_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_Amount *wire_fee_balance);
|
||||||
|
|
||||||
|
#endif
|
126
src/auditordb/pg_list_exchanges.c
Normal file
126
src/auditordb/pg_list_exchanges.c
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_list_exchanges.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_list_exchanges.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for #exchange_info_cb().
|
||||||
|
*/
|
||||||
|
struct ExchangeInfoContext
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to call for each exchange.
|
||||||
|
*/
|
||||||
|
TALER_AUDITORDB_ExchangeCallback cb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for @e cb
|
||||||
|
*/
|
||||||
|
void *cb_cls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query status to return.
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for #postgres_list_exchanges().
|
||||||
|
* To be called with the results of a SELECT statement
|
||||||
|
* that has returned @a num_results results.
|
||||||
|
*
|
||||||
|
* @param cls closure of type `struct ExchangeInfoContext *`
|
||||||
|
* @param result the postgres result
|
||||||
|
* @param num_results the number of results in @a result
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
exchange_info_cb (void *cls,
|
||||||
|
PGresult *result,
|
||||||
|
unsigned int num_results)
|
||||||
|
{
|
||||||
|
struct ExchangeInfoContext *eic = cls;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < num_results; i++)
|
||||||
|
{
|
||||||
|
struct TALER_MasterPublicKeyP master_pub;
|
||||||
|
char *exchange_url;
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("master_pub", &master_pub),
|
||||||
|
GNUNET_PQ_result_spec_string ("exchange_url", &exchange_url),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_PQ_extract_result (result,
|
||||||
|
rs,
|
||||||
|
i))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
eic->qs = GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
eic->qs = i + 1;
|
||||||
|
eic->cb (eic->cb_cls,
|
||||||
|
&master_pub,
|
||||||
|
exchange_url);
|
||||||
|
GNUNET_free (exchange_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_list_exchanges (void *cls,
|
||||||
|
TALER_AUDITORDB_ExchangeCallback cb,
|
||||||
|
void *cb_cls)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct ExchangeInfoContext eic = {
|
||||||
|
.cb = cb,
|
||||||
|
.cb_cls = cb_cls
|
||||||
|
};
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_list_exchanges",
|
||||||
|
"SELECT"
|
||||||
|
" master_pub"
|
||||||
|
",exchange_url"
|
||||||
|
" FROM auditor_exchanges");
|
||||||
|
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
|
||||||
|
"auditor_list_exchanges",
|
||||||
|
params,
|
||||||
|
&exchange_info_cb,
|
||||||
|
&eic);
|
||||||
|
if (qs > 0)
|
||||||
|
return eic.qs;
|
||||||
|
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
|
||||||
|
return qs;
|
||||||
|
}
|
43
src/auditordb/pg_list_exchanges.h
Normal file
43
src/auditordb/pg_list_exchanges.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_list_exchanges.h
|
||||||
|
* @brief implementation of the list_exchanges function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_LIST_EXCHANGES_H
|
||||||
|
#define PG_LIST_EXCHANGES_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain information about exchanges this auditor is auditing.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param cb function to call with the results
|
||||||
|
* @param cb_cls closure for @a cb
|
||||||
|
* @return query result status
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_list_exchanges (void *cls,
|
||||||
|
TALER_AUDITORDB_ExchangeCallback cb,
|
||||||
|
void *cb_cls);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
151
src/auditordb/pg_select_historic_denom_revenue.c
Normal file
151
src/auditordb/pg_select_historic_denom_revenue.c
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_select_historic_denom_revenue.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_select_historic_denom_revenue.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for #historic_denom_revenue_cb().
|
||||||
|
*/
|
||||||
|
struct HistoricDenomRevenueContext
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Function to call for each result.
|
||||||
|
*/
|
||||||
|
TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for @e cb.
|
||||||
|
*/
|
||||||
|
void *cb_cls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin context.
|
||||||
|
*/
|
||||||
|
struct PostgresClosure *pg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of results processed.
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for #postgres_select_historic_denom_revenue().
|
||||||
|
* To be called with the results of a SELECT statement
|
||||||
|
* that has returned @a num_results results.
|
||||||
|
*
|
||||||
|
* @param cls closure of type `struct HistoricRevenueContext *`
|
||||||
|
* @param result the postgres result
|
||||||
|
* @param num_results the number of results in @a result
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
historic_denom_revenue_cb (void *cls,
|
||||||
|
PGresult *result,
|
||||||
|
unsigned int num_results)
|
||||||
|
{
|
||||||
|
struct HistoricDenomRevenueContext *hrc = cls;
|
||||||
|
struct PostgresClosure *pg = hrc->pg;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < num_results; i++)
|
||||||
|
{
|
||||||
|
struct TALER_DenominationHashP denom_pub_hash;
|
||||||
|
struct GNUNET_TIME_Timestamp revenue_timestamp;
|
||||||
|
struct TALER_Amount revenue_balance;
|
||||||
|
struct TALER_Amount loss;
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
|
||||||
|
&denom_pub_hash),
|
||||||
|
GNUNET_PQ_result_spec_timestamp ("revenue_timestamp",
|
||||||
|
&revenue_timestamp),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("revenue_balance",
|
||||||
|
&revenue_balance),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("loss_balance",
|
||||||
|
&loss),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_PQ_extract_result (result,
|
||||||
|
rs,
|
||||||
|
i))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
hrc->qs = GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hrc->qs = i + 1;
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
hrc->cb (hrc->cb_cls,
|
||||||
|
&denom_pub_hash,
|
||||||
|
revenue_timestamp,
|
||||||
|
&revenue_balance,
|
||||||
|
&loss))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_select_historic_denom_revenue (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb,
|
||||||
|
void *cb_cls)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct HistoricDenomRevenueContext hrc = {
|
||||||
|
.cb = cb,
|
||||||
|
.cb_cls = cb_cls,
|
||||||
|
.pg = pg
|
||||||
|
};
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_historic_denomination_revenue_select",
|
||||||
|
"SELECT"
|
||||||
|
" denom_pub_hash"
|
||||||
|
",revenue_timestamp"
|
||||||
|
",revenue_balance_val"
|
||||||
|
",revenue_balance_frac"
|
||||||
|
",loss_balance_val"
|
||||||
|
",loss_balance_frac"
|
||||||
|
" FROM auditor_historic_denomination_revenue"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
|
||||||
|
"auditor_historic_denomination_revenue_select",
|
||||||
|
params,
|
||||||
|
&historic_denom_revenue_cb,
|
||||||
|
&hrc);
|
||||||
|
if (qs <= 0)
|
||||||
|
return qs;
|
||||||
|
return hrc.qs;
|
||||||
|
}
|
46
src/auditordb/pg_select_historic_denom_revenue.h
Normal file
46
src/auditordb/pg_select_historic_denom_revenue.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_select_historic_denom_revenue.h
|
||||||
|
* @brief implementation of the select_historic_denom_revenue function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_SELECT_HISTORIC_DENOM_REVENUE_H
|
||||||
|
#define PG_SELECT_HISTORIC_DENOM_REVENUE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain all of the historic denomination key revenue
|
||||||
|
* of the given @a master_pub.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param cb function to call with the results
|
||||||
|
* @param cb_cls closure for @a cb
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_select_historic_denom_revenue (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb,
|
||||||
|
void *cb_cls);
|
||||||
|
|
||||||
|
#endif
|
144
src/auditordb/pg_select_historic_reserve_revenue.c
Normal file
144
src/auditordb/pg_select_historic_reserve_revenue.c
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_select_historic_reserve_revenue.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_select_historic_reserve_revenue.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for #historic_reserve_revenue_cb().
|
||||||
|
*/
|
||||||
|
struct HistoricReserveRevenueContext
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Function to call for each result.
|
||||||
|
*/
|
||||||
|
TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for @e cb.
|
||||||
|
*/
|
||||||
|
void *cb_cls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin context.
|
||||||
|
*/
|
||||||
|
struct PostgresClosure *pg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of results processed.
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for #postgres_select_historic_reserve_revenue().
|
||||||
|
* To be called with the results of a SELECT statement
|
||||||
|
* that has returned @a num_results results.
|
||||||
|
*
|
||||||
|
* @param cls closure of type `struct HistoricRevenueContext *`
|
||||||
|
* @param result the postgres result
|
||||||
|
* @param num_results the number of results in @a result
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
historic_reserve_revenue_cb (void *cls,
|
||||||
|
PGresult *result,
|
||||||
|
unsigned int num_results)
|
||||||
|
{
|
||||||
|
struct HistoricReserveRevenueContext *hrc = cls;
|
||||||
|
struct PostgresClosure *pg = hrc->pg;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < num_results; i++)
|
||||||
|
{
|
||||||
|
struct GNUNET_TIME_Timestamp start_date;
|
||||||
|
struct GNUNET_TIME_Timestamp end_date;
|
||||||
|
struct TALER_Amount reserve_profits;
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_timestamp ("start_date",
|
||||||
|
&start_date),
|
||||||
|
GNUNET_PQ_result_spec_timestamp ("end_date",
|
||||||
|
&end_date),
|
||||||
|
TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_profits",
|
||||||
|
&reserve_profits),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_PQ_extract_result (result,
|
||||||
|
rs,
|
||||||
|
i))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
hrc->qs = GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hrc->qs = i + 1;
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
hrc->cb (hrc->cb_cls,
|
||||||
|
start_date,
|
||||||
|
end_date,
|
||||||
|
&reserve_profits))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_select_historic_reserve_revenue (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb,
|
||||||
|
void *cb_cls)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
struct HistoricReserveRevenueContext hrc = {
|
||||||
|
.cb = cb,
|
||||||
|
.cb_cls = cb_cls,
|
||||||
|
.pg = pg
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_historic_reserve_summary_select",
|
||||||
|
"SELECT"
|
||||||
|
" start_date"
|
||||||
|
",end_date"
|
||||||
|
",reserve_profits_val"
|
||||||
|
",reserve_profits_frac"
|
||||||
|
" FROM auditor_historic_reserve_summary"
|
||||||
|
" WHERE master_pub=$1;");
|
||||||
|
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
|
||||||
|
"auditor_historic_reserve_summary_select",
|
||||||
|
params,
|
||||||
|
&historic_reserve_revenue_cb,
|
||||||
|
&hrc);
|
||||||
|
if (0 >= qs)
|
||||||
|
return qs;
|
||||||
|
return hrc.qs;
|
||||||
|
}
|
45
src/auditordb/pg_select_historic_reserve_revenue.h
Normal file
45
src/auditordb/pg_select_historic_reserve_revenue.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_select_historic_reserve_revenue.h
|
||||||
|
* @brief implementation of the select_historic_reserve_revenue function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_SELECT_HISTORIC_RESERVE_REVENUE_H
|
||||||
|
#define PG_SELECT_HISTORIC_RESERVE_REVENUE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return information about an exchange's historic revenue from reserves.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param cb function to call with results
|
||||||
|
* @param cb_cls closure for @a cb
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_select_historic_reserve_revenue (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb,
|
||||||
|
void *cb_cls);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
50
src/auditordb/pg_update_auditor_progress_aggregation.c
Normal file
50
src/auditordb/pg_update_auditor_progress_aggregation.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_aggregation.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_auditor_progress_aggregation.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_aggregation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointAggregation *ppa)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_update_aggregation",
|
||||||
|
"UPDATE auditor_progress_aggregation SET "
|
||||||
|
" last_wire_out_serial_id=$1"
|
||||||
|
" WHERE master_pub=$2");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_update_aggregation",
|
||||||
|
params);
|
||||||
|
}
|
44
src/auditordb/pg_update_auditor_progress_aggregation.h
Normal file
44
src/auditordb/pg_update_auditor_progress_aggregation.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_aggregation.h
|
||||||
|
* @brief implementation of the update_auditor_progress_aggregation function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_AUDITOR_PROGRESS_AGGREGATION_H
|
||||||
|
#define PG_UPDATE_AUDITOR_PROGRESS_AGGREGATION_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about the progress of the auditor. There
|
||||||
|
* must be an existing record for the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppa where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_aggregation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointAggregation *ppa);
|
||||||
|
|
||||||
|
#endif
|
64
src/auditordb/pg_update_auditor_progress_coin.c
Normal file
64
src/auditordb/pg_update_auditor_progress_coin.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_coin.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_auditor_progress_coin.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_coin (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointCoin *ppc)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_recoup_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_recoup_refresh_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_purse_deposits_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppc->last_purse_refunds_serial_id),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_update_coin",
|
||||||
|
"UPDATE auditor_progress_coin SET "
|
||||||
|
" last_withdraw_serial_id=$1"
|
||||||
|
",last_deposit_serial_id=$2"
|
||||||
|
",last_melt_serial_id=$3"
|
||||||
|
",last_refund_serial_id=$4"
|
||||||
|
",last_recoup_serial_id=$5"
|
||||||
|
",last_recoup_refresh_serial_id=$6"
|
||||||
|
",last_purse_deposits_serial_id=$7"
|
||||||
|
",last_purse_decision_serial_id=$8"
|
||||||
|
" WHERE master_pub=$9");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_update_coin",
|
||||||
|
params);
|
||||||
|
}
|
44
src/auditordb/pg_update_auditor_progress_coin.h
Normal file
44
src/auditordb/pg_update_auditor_progress_coin.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_coin.h
|
||||||
|
* @brief implementation of the update_auditor_progress_coin function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_AUDITOR_PROGRESS_COIN_H
|
||||||
|
#define PG_UPDATE_AUDITOR_PROGRESS_COIN_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about the progress of the auditor. There
|
||||||
|
* must be an existing record for the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppc where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_coin (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointCoin *ppc);
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_deposit_confirmation.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_auditor_progress_deposit_confirmation.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_deposit_confirmation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppdc->last_deposit_confirmation_serial_id),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_update_deposit_confirmation",
|
||||||
|
"UPDATE auditor_progress_deposit_confirmation SET "
|
||||||
|
" last_deposit_confirmation_serial_id=$1"
|
||||||
|
" WHERE master_pub=$2");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_update_deposit_confirmation",
|
||||||
|
params);
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_deposit_confirmation.h
|
||||||
|
* @brief implementation of the update_auditor_progress_deposit_confirmation function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
|
||||||
|
#define PG_UPDATE_AUDITOR_PROGRESS_DEPOSIT_CONFIRMATION_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about the progress of the auditor. There
|
||||||
|
* must be an existing record for the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppdc where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_deposit_confirmation (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
58
src/auditordb/pg_update_auditor_progress_purse.c
Normal file
58
src/auditordb/pg_update_auditor_progress_purse.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_purse.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_auditor_progress_purse.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_purse (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointPurse *ppp)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_purse_request_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_purse_decision_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_purse_merge_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_account_merge_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppp->last_purse_deposits_serial_id),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_update_purse",
|
||||||
|
"UPDATE auditor_progress_purse SET "
|
||||||
|
" last_purse_request_serial_id=$1"
|
||||||
|
",last_purse_decision_serial_id=$2"
|
||||||
|
",last_purse_merges_serial_id=$3"
|
||||||
|
",last_account_merges_serial_id=$4"
|
||||||
|
",last_purse_deposits_serial_id=$5"
|
||||||
|
" WHERE master_pub=$6");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_update_purse",
|
||||||
|
params);
|
||||||
|
}
|
44
src/auditordb/pg_update_auditor_progress_purse.h
Normal file
44
src/auditordb/pg_update_auditor_progress_purse.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_purse.h
|
||||||
|
* @brief implementation of the update_auditor_progress_purse function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_AUDITOR_PROGRESS_PURSE_H
|
||||||
|
#define PG_UPDATE_AUDITOR_PROGRESS_PURSE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about the progress of the auditor. There
|
||||||
|
* must be an existing record for the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppp where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_purse (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointPurse *ppp);
|
||||||
|
|
||||||
|
#endif
|
64
src/auditordb/pg_update_auditor_progress_reserve.c
Normal file
64
src/auditordb/pg_update_auditor_progress_reserve.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_reserve.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_auditor_progress_reserve.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_reserve (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointReserve *ppr)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_out_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_recoup_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_open_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_close_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_purse_decisions_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_account_merges_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&ppr->last_history_requests_serial_id),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_progress_update_reserve",
|
||||||
|
"UPDATE auditor_progress_reserve SET "
|
||||||
|
" last_reserve_in_serial_id=$1"
|
||||||
|
",last_reserve_out_serial_id=$2"
|
||||||
|
",last_reserve_recoup_serial_id=$3"
|
||||||
|
",last_reserve_open_serial_id=$4"
|
||||||
|
",last_reserve_close_serial_id=$5"
|
||||||
|
",last_purse_decision_serial_id=$6"
|
||||||
|
",last_account_merges_serial_id=$7"
|
||||||
|
",last_history_requests_serial_id=$8"
|
||||||
|
" WHERE master_pub=$9");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_progress_update_reserve",
|
||||||
|
params);
|
||||||
|
}
|
43
src/auditordb/pg_update_auditor_progress_reserve.h
Normal file
43
src/auditordb/pg_update_auditor_progress_reserve.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_auditor_progress_reserve.h
|
||||||
|
* @brief implementation of the update_auditor_progress_reserve function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_AUDITOR_PROGRESS_RESERVE_H
|
||||||
|
#define PG_UPDATE_AUDITOR_PROGRESS_RESERVE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about the progress of the auditor. There
|
||||||
|
* must be an existing record for the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param ppr where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_auditor_progress_reserve (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ProgressPointReserve *ppr);
|
||||||
|
|
||||||
|
#endif
|
75
src/auditordb/pg_update_balance_summary.c
Normal file
75
src/auditordb/pg_update_balance_summary.c
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_balance_summary.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_balance_summary.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_balance_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_GlobalCoinBalance *dfb)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
TALER_PQ_query_param_amount (&dfb->total_escrowed),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->deposit_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->melt_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->refund_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->purse_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->open_deposit_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->risk),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->loss),
|
||||||
|
TALER_PQ_query_param_amount (&dfb->irregular_loss),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_balance_summary_update",
|
||||||
|
"UPDATE auditor_balance_summary SET"
|
||||||
|
" denom_balance_val=$1"
|
||||||
|
",denom_balance_frac=$2"
|
||||||
|
",deposit_fee_balance_val=$3"
|
||||||
|
",deposit_fee_balance_frac=$4"
|
||||||
|
",melt_fee_balance_val=$5"
|
||||||
|
",melt_fee_balance_frac=$6"
|
||||||
|
",refund_fee_balance_val=$7"
|
||||||
|
",refund_fee_balance_frac=$8"
|
||||||
|
",purse_fee_balance_val=$9"
|
||||||
|
",purse_fee_balance_frac=$10"
|
||||||
|
",open_deposit_fee_balance_val=$11"
|
||||||
|
",open_deposit_fee_balance_frac=$12"
|
||||||
|
",risk_val=$13"
|
||||||
|
",risk_frac=$14"
|
||||||
|
",loss_val=$15"
|
||||||
|
",loss_frac=$16"
|
||||||
|
",irregular_loss_val=$17"
|
||||||
|
",irregular_loss_frac=$18"
|
||||||
|
" WHERE master_pub=$19;");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_balance_summary_update",
|
||||||
|
params);
|
||||||
|
}
|
44
src/auditordb/pg_update_balance_summary.h
Normal file
44
src/auditordb/pg_update_balance_summary.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_balance_summary.h
|
||||||
|
* @brief implementation of the update_balance_summary function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_BALANCE_SUMMARY_H
|
||||||
|
#define PG_UPDATE_BALANCE_SUMMARY_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about an exchange's denomination balances. There
|
||||||
|
* must be an existing record for the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param dfb denomination balance data to store
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_balance_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_GlobalCoinBalance *dfb);
|
||||||
|
|
||||||
|
#endif
|
62
src/auditordb/pg_update_denomination_balance.c
Normal file
62
src/auditordb/pg_update_denomination_balance.c
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_denomination_balance.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_denomination_balance.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_denomination_balance (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_DenominationHashP *denom_pub_hash,
|
||||||
|
const struct TALER_AUDITORDB_DenominationCirculationData *dcd)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
TALER_PQ_query_param_amount (&dcd->denom_balance),
|
||||||
|
TALER_PQ_query_param_amount (&dcd->denom_loss),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&dcd->num_issued),
|
||||||
|
TALER_PQ_query_param_amount (&dcd->denom_risk),
|
||||||
|
TALER_PQ_query_param_amount (&dcd->recoup_loss),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_denomination_pending_update",
|
||||||
|
"UPDATE auditor_denomination_pending SET"
|
||||||
|
" denom_balance_val=$1"
|
||||||
|
",denom_balance_frac=$2"
|
||||||
|
",denom_loss_val=$3"
|
||||||
|
",denom_loss_frac=$4"
|
||||||
|
",num_issued=$5"
|
||||||
|
",denom_risk_val=$6"
|
||||||
|
",denom_risk_frac=$7"
|
||||||
|
",recoup_loss_val=$8"
|
||||||
|
",recoup_loss_frac=$9"
|
||||||
|
" WHERE denom_pub_hash=$10");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_denomination_pending_update",
|
||||||
|
params);
|
||||||
|
}
|
45
src/auditordb/pg_update_denomination_balance.h
Normal file
45
src/auditordb/pg_update_denomination_balance.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_denomination_balance.h
|
||||||
|
* @brief implementation of the update_denomination_balance function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_DENOMINATION_BALANCE_H
|
||||||
|
#define PG_UPDATE_DENOMINATION_BALANCE_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about a denomination key's balances. There
|
||||||
|
* must be an existing record for the denomination key.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param denom_pub_hash hash of the denomination public key
|
||||||
|
* @param dcd circulation data to store
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_denomination_balance (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_DenominationHashP *denom_pub_hash,
|
||||||
|
const struct TALER_AUDITORDB_DenominationCirculationData *dcd);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
55
src/auditordb/pg_update_predicted_result.c
Normal file
55
src/auditordb/pg_update_predicted_result.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_predicted_result.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_predicted_result.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_predicted_result (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_Amount *balance,
|
||||||
|
const struct TALER_Amount *drained)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
TALER_PQ_query_param_amount (balance),
|
||||||
|
TALER_PQ_query_param_amount (drained),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_predicted_result_update",
|
||||||
|
"UPDATE auditor_predicted_result SET"
|
||||||
|
" balance_val=$1"
|
||||||
|
",balance_frac=$2"
|
||||||
|
",drained_val=$3"
|
||||||
|
",drained_frac=$4"
|
||||||
|
" WHERE master_pub=$5;");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_predicted_result_update",
|
||||||
|
params);
|
||||||
|
}
|
46
src/auditordb/pg_update_predicted_result.h
Normal file
46
src/auditordb/pg_update_predicted_result.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_predicted_result.h
|
||||||
|
* @brief implementation of the update_predicted_result function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_PREDICTED_RESULT_H
|
||||||
|
#define PG_UPDATE_PREDICTED_RESULT_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about an exchange's predicted balance. There
|
||||||
|
* must be an existing record for the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param balance what the bank account balance of the exchange should show
|
||||||
|
* @param drained amount that was drained in profits
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_predicted_result (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_Amount *balance,
|
||||||
|
const struct TALER_Amount *drained);
|
||||||
|
|
||||||
|
#endif
|
72
src/auditordb/pg_update_reserve_info.c
Normal file
72
src/auditordb/pg_update_reserve_info.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_reserve_info.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_reserve_info.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_reserve_info (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
|
||||||
|
struct GNUNET_TIME_Timestamp expiration_date)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
TALER_PQ_query_param_amount (&rfb->reserve_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->reserve_loss),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->purse_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->open_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->history_fee_balance),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&expiration_date),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_reserves_update",
|
||||||
|
"UPDATE auditor_reserves SET"
|
||||||
|
" reserve_balance_val=$1"
|
||||||
|
",reserve_balance_frac=$2"
|
||||||
|
",reserve_loss_val=$3"
|
||||||
|
",reserve_loss_frac=$4"
|
||||||
|
",withdraw_fee_balance_val=$5"
|
||||||
|
",withdraw_fee_balance_frac=$6"
|
||||||
|
",purse_fee_balance_val=$7"
|
||||||
|
",purse_fee_balance_frac=$8"
|
||||||
|
",open_fee_balance_val=$9"
|
||||||
|
",open_fee_balance_frac=$10"
|
||||||
|
",history_fee_balance_val=$11"
|
||||||
|
",history_fee_balance_frac=$12"
|
||||||
|
",expiration_date=$13"
|
||||||
|
" WHERE reserve_pub=$14"
|
||||||
|
" AND master_pub=$15;");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_reserves_update",
|
||||||
|
params);
|
||||||
|
}
|
48
src/auditordb/pg_update_reserve_info.h
Normal file
48
src/auditordb/pg_update_reserve_info.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_reserve_info.h
|
||||||
|
* @brief implementation of the update_reserve_info function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_RESERVE_INFO_H
|
||||||
|
#define PG_UPDATE_RESERVE_INFO_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about a reserve. Destructively updates an
|
||||||
|
* existing record, which must already exist.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param reserve_pub public key of the reserve
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param rfb amounts for the reserve
|
||||||
|
* @param expiration_date expiration date of the reserve
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_reserve_info (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
|
||||||
|
struct GNUNET_TIME_Timestamp expiration_date);
|
||||||
|
|
||||||
|
#endif
|
69
src/auditordb/pg_update_reserve_summary.c
Normal file
69
src/auditordb/pg_update_reserve_summary.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_reserve_summary.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_reserve_summary.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_reserve_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
TALER_PQ_query_param_amount (&rfb->reserve_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->reserve_loss),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->close_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->purse_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->open_fee_balance),
|
||||||
|
TALER_PQ_query_param_amount (&rfb->history_fee_balance),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"auditor_reserve_balance_update",
|
||||||
|
"UPDATE auditor_reserve_balance SET"
|
||||||
|
" reserve_balance_val=$1"
|
||||||
|
",reserve_balance_frac=$2"
|
||||||
|
",reserve_loss_val=$3"
|
||||||
|
",reserve_loss_frac=$4"
|
||||||
|
",withdraw_fee_balance_val=$5"
|
||||||
|
",withdraw_fee_balance_frac=$6"
|
||||||
|
",close_fee_balance_val=$7"
|
||||||
|
",close_fee_balance_frac=$8"
|
||||||
|
",purse_fee_balance_val=$9"
|
||||||
|
",purse_fee_balance_frac=$10"
|
||||||
|
",open_fee_balance_val=$11"
|
||||||
|
",open_fee_balance_frac=$12"
|
||||||
|
",history_fee_balance_val=$13"
|
||||||
|
",history_fee_balance_frac=$14"
|
||||||
|
" WHERE master_pub=$15;");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"auditor_reserve_balance_update",
|
||||||
|
params);
|
||||||
|
}
|
45
src/auditordb/pg_update_reserve_summary.h
Normal file
45
src/auditordb/pg_update_reserve_summary.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_reserve_summary.h
|
||||||
|
* @brief implementation of the update_reserve_summary function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_RESERVE_SUMMARY_H
|
||||||
|
#define PG_UPDATE_RESERVE_SUMMARY_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about all reserves. Destructively updates an
|
||||||
|
* existing record, which must already exist.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master public key of the exchange
|
||||||
|
* @param rfb balances to be stored for the reserve
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_reserve_summary (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_ReserveFeeBalance *rfb);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
59
src/auditordb/pg_update_wire_auditor_account_progress.c
Normal file
59
src/auditordb/pg_update_wire_auditor_account_progress.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_wire_auditor_account_progress.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_wire_auditor_account_progress.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_wire_auditor_account_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const char *account_name,
|
||||||
|
const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
|
||||||
|
const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&bapp->in_wire_off),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&bapp->out_wire_off),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_string (account_name),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"wire_auditor_account_progress_update",
|
||||||
|
"UPDATE wire_auditor_account_progress SET "
|
||||||
|
" last_wire_reserve_in_serial_id=$1"
|
||||||
|
",last_wire_wire_out_serial_id=$2"
|
||||||
|
",wire_in_off=$3"
|
||||||
|
",wire_out_off=$4"
|
||||||
|
" WHERE master_pub=$5 AND account_name=$6");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"wire_auditor_account_progress_update",
|
||||||
|
params);
|
||||||
|
}
|
49
src/auditordb/pg_update_wire_auditor_account_progress.h
Normal file
49
src/auditordb/pg_update_wire_auditor_account_progress.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_wire_auditor_account_progress.h
|
||||||
|
* @brief implementation of the update_wire_auditor_account_progress function
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#ifndef PG_UPDATE_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
|
||||||
|
#define PG_UPDATE_WIRE_AUDITOR_ACCOUNT_PROGRESS_H
|
||||||
|
|
||||||
|
#include "taler_util.h"
|
||||||
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_auditordb_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about the progress of the auditor. There
|
||||||
|
* must be an existing record for the exchange.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param master_pub master key of the exchange
|
||||||
|
* @param account_name name of the wire account we are auditing
|
||||||
|
* @param pp where is the auditor in processing
|
||||||
|
* @param bapp progress in wire transaction histories
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_wire_auditor_account_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const char *account_name,
|
||||||
|
const struct TALER_AUDITORDB_WireAccountProgressPoint *pp,
|
||||||
|
const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
52
src/auditordb/pg_update_wire_auditor_progress.c
Normal file
52
src/auditordb/pg_update_wire_auditor_progress.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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/>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @file pg_update_wire_auditor_progress.c
|
||||||
|
* @brief Low-level (statement-level) Postgres database access for the exchange
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler_pq_lib.h"
|
||||||
|
#include "pg_update_wire_auditor_progress.h"
|
||||||
|
#include "pg_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
TAH_PG_update_wire_auditor_progress (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_WireProgressPoint *pp)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_timestamp (&pp->last_timestamp),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_close_uuid),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
PREPARE (pg,
|
||||||
|
"wire_auditor_progress_update",
|
||||||
|
"UPDATE wire_auditor_progress SET "
|
||||||
|
" last_timestamp=$1"
|
||||||
|
",last_reserve_close_uuid=$2"
|
||||||
|
" WHERE master_pub=$3");
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"wire_auditor_progress_update",
|
||||||
|
params);
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user