aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-08-23 22:59:29 +0200
committerChristian Grothoff <christian@grothoff.org>2024-08-23 22:59:29 +0200
commitca4b2e51ba0f732ea4b10a1fc2db1e24d2e27a34 (patch)
tree328f593016b42de6d80323051d02a5197ebe0a7b
parent61e8d2fbfa1a546aa0af13cacaa05c34ce80a931 (diff)
downloadexchange-ca4b2e51ba0f732ea4b10a1fc2db1e24d2e27a34.tar.xz
misc bugfixes, DCE
-rw-r--r--src/auditor/taler-auditor-httpd_denomination-pending-get.c50
-rw-r--r--src/auditor/taler-auditor-httpd_purses-get.c27
-rw-r--r--src/auditor/taler-auditor-httpd_reserves-get.c38
-rw-r--r--src/auditordb/0002-auditor_denomination_pending.sql4
-rw-r--r--src/auditordb/Makefile.am2
-rw-r--r--src/auditordb/pg_del_purses.c42
-rw-r--r--src/auditordb/pg_del_purses.h36
-rw-r--r--src/auditordb/pg_del_reserves.c42
-rw-r--r--src/auditordb/pg_del_reserves.h36
-rw-r--r--src/auditordb/pg_get_auditor_closure_lags.c44
-rw-r--r--src/auditordb/pg_get_balances.c62
-rw-r--r--src/auditordb/pg_get_balances.h16
-rw-r--r--src/auditordb/pg_get_denomination_pending.c48
-rw-r--r--src/auditordb/pg_get_denomination_pending.h8
-rw-r--r--src/auditordb/pg_get_purses.c30
-rw-r--r--src/auditordb/pg_get_purses.h8
-rw-r--r--src/auditordb/pg_get_reserves.c45
-rw-r--r--src/auditordb/pg_get_reserves.h8
-rw-r--r--src/auditordb/pg_get_wire_out_inconsistency.c9
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c8
-rw-r--r--src/include/taler_auditordb_plugin.h30
21 files changed, 185 insertions, 408 deletions
diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-get.c b/src/auditor/taler-auditor-httpd_denomination-pending-get.c
index 381e89d4a..b00437e54 100644
--- a/src/auditor/taler-auditor-httpd_denomination-pending-get.c
+++ b/src/auditor/taler-auditor-httpd_denomination-pending-get.c
@@ -13,8 +13,6 @@
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/>
*/
-
-
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_json_lib.h>
@@ -44,21 +42,22 @@ process_denomination_pending (
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_data_auto ("denom_pub_hash", &dc->denom_pub_hash),
- TALER_JSON_pack_amount ("denom_balance", &dc->denom_balance),
- TALER_JSON_pack_amount ("denom_loss", &dc->denom_loss),
- GNUNET_JSON_pack_int64 ("num_issued", dc->num_issued),
- TALER_JSON_pack_amount ("denom_risk", &dc->denom_risk),
- TALER_JSON_pack_amount ("recoup_loss", &dc->recoup_loss)
-
-
+ GNUNET_JSON_pack_data_auto ("denom_pub_hash",
+ &dc->denom_pub_hash),
+ TALER_JSON_pack_amount ("denom_balance",
+ &dc->denom_balance),
+ TALER_JSON_pack_amount ("denom_loss",
+ &dc->denom_loss),
+ GNUNET_JSON_pack_int64 ("num_issued",
+ dc->num_issued),
+ TALER_JSON_pack_amount ("denom_risk",
+ &dc->denom_risk),
+ TALER_JSON_pack_amount ("recoup_loss",
+ &dc->recoup_loss)
);
GNUNET_break (0 ==
json_array_append_new (list,
obj));
-
-
return GNUNET_OK;
}
@@ -74,6 +73,8 @@ TAH_DENOMINATION_PENDING_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
(void) rh;
(void) connection_cls;
@@ -88,32 +89,22 @@ TAH_DENOMINATION_PENDING_handler_get (
TALER_EC_GENERIC_DB_SETUP_FAILED,
NULL);
}
- ja = json_array ();
- GNUNET_break (NULL != ja);
-
- int64_t limit = -20;
- uint64_t offset;
-
TALER_MHD_parse_request_snumber (connection,
"limit",
&limit);
-
if (limit < 0)
offset = INT64_MAX;
else
offset = 0;
-
TALER_MHD_parse_request_number (connection,
"offset",
&offset);
-
- bool return_suppressed = false;
-
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_denomination_pending (
TAH_plugin->cls,
limit,
offset,
- return_suppressed,
&process_denomination_pending,
ja);
@@ -123,10 +114,11 @@ TAH_DENOMINATION_PENDING_handler_get (
json_decref (ja);
TALER_LOG_WARNING (
"Failed to handle GET /denomination-pending");
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "denomination-pending");
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "get_denomination_pending");
}
return TALER_MHD_REPLY_JSON_PACK (
connection,
diff --git a/src/auditor/taler-auditor-httpd_purses-get.c b/src/auditor/taler-auditor-httpd_purses-get.c
index a581f62d3..579521b73 100644
--- a/src/auditor/taler-auditor-httpd_purses-get.c
+++ b/src/auditor/taler-auditor-httpd_purses-get.c
@@ -73,6 +73,8 @@ TAH_PURSES_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
(void) rh;
(void) connection_cls;
@@ -82,41 +84,30 @@ TAH_PURSES_handler_get (
TAH_plugin->preflight (TAH_plugin->cls))
{
GNUNET_break (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_SETUP_FAILED,
- NULL);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_SETUP_FAILED,
+ NULL);
}
- ja = json_array ();
- GNUNET_break (NULL != ja);
-
- int64_t limit = -20;
- uint64_t offset;
-
TALER_MHD_parse_request_snumber (connection,
"limit",
&limit);
-
if (limit < 0)
offset = INT64_MAX;
else
offset = 0;
-
TALER_MHD_parse_request_number (connection,
"offset",
&offset);
-
- bool return_suppressed = false;
-
-
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_purses (
TAH_plugin->cls,
limit,
offset,
- return_suppressed,
&process_purses,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
diff --git a/src/auditor/taler-auditor-httpd_reserves-get.c b/src/auditor/taler-auditor-httpd_reserves-get.c
index 6f6a3be2c..901557475 100644
--- a/src/auditor/taler-auditor-httpd_reserves-get.c
+++ b/src/auditor/taler-auditor-httpd_reserves-get.c
@@ -13,8 +13,6 @@
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/>
*/
-
-
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_json_lib.h>
@@ -26,14 +24,15 @@
#include "taler-auditor-httpd.h"
#include "taler-auditor-httpd_reserves-get.h"
+
/**
-* Add reserves to the list.
-*
-* @param[in,out] cls a `json_t *` array to extend
-* @param serial_id location of the @a dc in the database
-* @param dc struct of inconsistencies
-* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
-*/
+ * Add reserves to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param serial_id location of the @a dc in the database
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
+ */
static enum GNUNET_GenericReturnValue
process_reserves (
void *cls,
@@ -44,7 +43,6 @@ process_reserves (
json_t *obj;
obj = GNUNET_JSON_PACK (
-
GNUNET_JSON_pack_int64 ("auditor_reserves_rowid",
dc->auditor_reserves_rowid),
GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub),
@@ -57,14 +55,10 @@ process_reserves (
TALER_JSON_pack_amount ("history_fee_balance", &dc->history_fee_balance),
TALER_JSON_pack_time_abs_human ("expiration_date", dc->expiration_date),
GNUNET_JSON_pack_string ("origin_account", dc->origin_account)
-
-
);
GNUNET_break (0 ==
json_array_append_new (list,
obj));
-
-
return GNUNET_OK;
}
@@ -80,6 +74,8 @@ TAH_RESERVES_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
(void) rh;
(void) connection_cls;
@@ -94,12 +90,6 @@ TAH_RESERVES_handler_get (
TALER_EC_GENERIC_DB_SETUP_FAILED,
NULL);
}
- ja = json_array ();
- GNUNET_break (NULL != ja);
-
- int64_t limit = -20;
- uint64_t offset;
-
TALER_MHD_parse_request_snumber (connection,
"limit",
&limit);
@@ -108,21 +98,17 @@ TAH_RESERVES_handler_get (
offset = INT64_MAX;
else
offset = 0;
-
TALER_MHD_parse_request_number (connection,
"offset",
&offset);
-
- bool return_suppressed = false;
-
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_reserves (
TAH_plugin->cls,
limit,
offset,
- return_suppressed,
&process_reserves,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
diff --git a/src/auditordb/0002-auditor_denomination_pending.sql b/src/auditordb/0002-auditor_denomination_pending.sql
index 00ed18145..2b1ee99a5 100644
--- a/src/auditordb/0002-auditor_denomination_pending.sql
+++ b/src/auditordb/0002-auditor_denomination_pending.sql
@@ -15,8 +15,8 @@
--
CREATE TABLE auditor_denomination_pending
- (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE,
- denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)
+ (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
+ ,denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)
,denom_balance taler_amount NOT NULL
,denom_loss taler_amount NOT NULL
,num_issued BIGINT NOT NULL
diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am
index de6a7cd99..3f43a5492 100644
--- a/src/auditordb/Makefile.am
+++ b/src/auditordb/Makefile.am
@@ -152,9 +152,7 @@ pg_insert_misattribution_in_inconsistency.c pg_insert_misattribution_in_inconsis
pg_update_misattribution_in_inconsistency.c pg_update_misattribution_in_inconsistency.h \
pg_update_balance.c pg_update_balance.h \
pg_get_reserves.c pg_get_reserves.h \
-pg_del_reserves.c pg_del_reserves.h \
pg_get_purses.c pg_get_purses.h \
-pg_del_purses.c pg_del_purses.h \
pg_insert_historic_denom_revenue.c pg_insert_historic_denom_revenue.h \
pg_get_denomination_pending.c pg_get_denomination_pending.h \
pg_del_denomination_pending.c pg_del_denomination_pending.h \
diff --git a/src/auditordb/pg_del_purses.c b/src/auditordb/pg_del_purses.c
deleted file mode 100644
index aeeaac88a..000000000
--- a/src/auditordb/pg_del_purses.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2024 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/>
- */
-
-
-#include "pg_del_purses.h"
-
-#include "taler_pq_lib.h"
-#include "pg_helper.h"
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_del_purses (
- void *cls,
- uint64_t row_id)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&row_id),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_delete_purses",
- "DELETE"
- " FROM auditor_purses"
- " WHERE row_id=$1;");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_delete_purses",
- params);
-}
diff --git a/src/auditordb/pg_del_purses.h b/src/auditordb/pg_del_purses.h
deleted file mode 100644
index e4f4566ad..000000000
--- a/src/auditordb/pg_del_purses.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2024 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/>
- */
-
-
-#ifndef SRC_PG_DEL_PURSES_H
-#define SRC_PG_DEL_PURSES_H
-
-#include "taler_util.h"
-#include "taler_auditordb_plugin.h"
-
-/**
- * Delete a row from the bad sig losses table.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param row_id row to delete
- * @return query transaction status
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_del_purses (
- void *cls,
- uint64_t row_id);
-
-#endif // SRC_PG_DEL_PURSES_H
diff --git a/src/auditordb/pg_del_reserves.c b/src/auditordb/pg_del_reserves.c
deleted file mode 100644
index 731cec48f..000000000
--- a/src/auditordb/pg_del_reserves.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2024 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/>
- */
-
-
-#include "pg_del_reserves.h"
-
-#include "taler_pq_lib.h"
-#include "pg_helper.h"
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_del_reserves (
- void *cls,
- uint64_t row_id)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&row_id),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_delete_reserves",
- "DELETE"
- " FROM auditor_reserves"
- " WHERE row_id=$1;");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_delete_reserves",
- params);
-}
diff --git a/src/auditordb/pg_del_reserves.h b/src/auditordb/pg_del_reserves.h
deleted file mode 100644
index 3e3136a69..000000000
--- a/src/auditordb/pg_del_reserves.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2024 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/>
- */
-
-
-#ifndef SRC_PG_DEL_RESERVES_H
-#define SRC_PG_DEL_RESERVES_H
-
-#include "taler_util.h"
-#include "taler_auditordb_plugin.h"
-
-/**
- * Delete a row from the bad sig losses table.
- *
- * @param cls the @e cls of this struct with the plugin-specific state
- * @param row_id row to delete
- * @return query transaction status
- */
-enum GNUNET_DB_QueryStatus
-TAH_PG_del_reserves (
- void *cls,
- uint64_t row_id);
-
-#endif // SRC_PG_DEL_RESERVES_H
diff --git a/src/auditordb/pg_get_auditor_closure_lags.c b/src/auditordb/pg_get_auditor_closure_lags.c
index e13fe1319..e92a7cb5b 100644
--- a/src/auditordb/pg_get_auditor_closure_lags.c
+++ b/src/auditordb/pg_get_auditor_closure_lags.c
@@ -19,7 +19,6 @@
#include "taler_dbevents.h"
#include "taler_pq_lib.h"
#include "pg_helper.h"
-
#include "pg_get_auditor_closure_lags.h"
@@ -68,16 +67,18 @@ closure_lags_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
uint64_t serial_id;
-
struct TALER_AUDITORDB_ClosureLags dc;
-
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id),
- TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &dc.amount),
- GNUNET_PQ_result_spec_absolute_time ("deadline", &dc.deadline),
- GNUNET_PQ_result_spec_auto_from_type ("wtid", &dc.wtid),
- GNUNET_PQ_result_spec_string ("account", &dc.account),
-
+ GNUNET_PQ_result_spec_uint64 ("row_id",
+ &serial_id),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
+ &dc.amount),
+ GNUNET_PQ_result_spec_absolute_time ("deadline",
+ &dc.deadline),
+ GNUNET_PQ_result_spec_auto_from_type ("wtid",
+ &dc.wtid),
+ GNUNET_PQ_result_spec_string ("account",
+ &dc.account),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -91,9 +92,7 @@ closure_lags_cb (void *cls,
dcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return;
}
-
dcc->qs = i + 1;
-
rval = dcc->cb (dcc->cb_cls,
serial_id,
&dc);
@@ -109,21 +108,18 @@ TAH_PG_get_auditor_closure_lags (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed, // maybe not needed
+ bool return_suppressed,
TALER_AUDITORDB_ClosureLagsCallback cb,
void *cb_cls)
{
-
- uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
-
struct PostgresClosure *pg = cls;
+ uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&offset),
GNUNET_PQ_query_param_bool (return_suppressed),
GNUNET_PQ_query_param_uint64 (&plimit),
GNUNET_PQ_query_param_end
};
-
struct ClosureLagsContext dcc = {
.cb = cb,
.cb_cls = cb_cls,
@@ -159,14 +155,14 @@ TAH_PG_get_auditor_closure_lags (
" ORDER BY row_id ASC"
" LIMIT $3"
);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- (limit > 0) ?
- "auditor_auditor_closure_lags_get_asc"
- :
- "auditor_auditor_closure_lags_get_desc",
- params,
- &closure_lags_cb,
- &dcc);
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_closure_lags_get_asc"
+ : "auditor_closure_lags_get_desc",
+ params,
+ &closure_lags_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
diff --git a/src/auditordb/pg_get_balances.c b/src/auditordb/pg_get_balances.c
index 8f8f2d682..da729bf38 100644
--- a/src/auditordb/pg_get_balances.c
+++ b/src/auditordb/pg_get_balances.c
@@ -13,14 +13,11 @@
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/>
*/
-
-
#include "platform.h"
#include "taler_error_codes.h"
#include "taler_dbevents.h"
#include "taler_pq_lib.h"
#include "pg_helper.h"
-
#include "pg_get_balances.h"
@@ -69,17 +66,14 @@ balances_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
uint64_t serial_id;
-
struct TALER_AUDITORDB_Balances dc;
-
struct GNUNET_PQ_ResultSpec rs[] = {
-
- GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id),
-
- GNUNET_PQ_result_spec_string ("balance_key", &dc.balance_key),
- TALER_PQ_RESULT_SPEC_AMOUNT ("balance_value", &dc.balance_value),
-
-
+ GNUNET_PQ_result_spec_uint64 ("row_id",
+ &serial_id),
+ GNUNET_PQ_result_spec_string ("balance_key",
+ &dc.balance_key),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("balance_value",
+ &dc.balance_value),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -93,9 +87,7 @@ balances_cb (void *cls,
dcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return;
}
-
dcc->qs = i + 1;
-
rval = dcc->cb (dcc->cb_cls,
serial_id,
&dc);
@@ -111,30 +103,14 @@ TAH_PG_get_balances (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed,
const char *balance_key,
TALER_AUDITORDB_BalancesCallback cb,
void *cb_cls)
{
-
-
- /*if true, does not filter for a specific balance*/
- bool any_balance = true;
- const char *bk;
-
- if (balance_key != NULL)
- {
- any_balance = false;
- bk = balance_key;
- }
- else
- {
- bk = "";
- }
-
- uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
-
struct PostgresClosure *pg = cls;
+ bool any_balance = (NULL == balance_key);
+ uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
+ const char *bk = (any_balance) ? "" : balance_key;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&offset),
GNUNET_PQ_query_param_uint64 (&plimit),
@@ -157,7 +133,7 @@ TAH_PG_get_balances (
" balance_value"
" FROM auditor_balances"
" WHERE (row_id < $1)"
- " AND ($3 OR balance_key = $4)"
+ " AND ($3 OR balance_key = $4)"
" ORDER BY row_id DESC"
" LIMIT $2"
);
@@ -169,18 +145,18 @@ TAH_PG_get_balances (
" balance_value"
" FROM auditor_balances"
" WHERE (row_id > $1)"
- " AND ($3 OR balance_key = $4)"
+ " AND ($3 OR balance_key = $4)"
" ORDER BY row_id ASC"
" LIMIT $2"
);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- (limit > 0)
- ? "auditor_balances_get_asc"
- : "auditor_balances_get_desc",
- params,
- &balances_cb,
- &dcc);
-
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_balances_get_asc"
+ : "auditor_balances_get_desc",
+ params,
+ &balances_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
diff --git a/src/auditordb/pg_get_balances.h b/src/auditordb/pg_get_balances.h
index e2883ad8f..e4dc8911d 100644
--- a/src/auditordb/pg_get_balances.h
+++ b/src/auditordb/pg_get_balances.h
@@ -13,24 +13,21 @@
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/>
*/
-
-
-#ifndef SRC_PG_GET_BALANCES_H
-#define SRC_PG_GET_BALANCES_H
+#ifndef PG_GET_BALANCES_H
+#define PG_GET_BALANCES_H
#include "taler_util.h"
#include "taler_json_lib.h"
#include "taler_auditordb_plugin.h"
-
/**
* Get information about balances from the database.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param limit number of records to return, negative for descending
- * @param offset table row to start from, exclusive, direction determined by @a limit
- * @param return_suppressed should suppressed rows be returned anyway?
- * @param balance_key key to look for
+ * @param limit number of balances to return at most,
+ * negative value to descend from @a offset
+ * @param offset 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
@@ -40,7 +37,6 @@ TAH_PG_get_balances (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed,
const char *balance_key,
TALER_AUDITORDB_BalancesCallback cb,
void *cb_cls);
diff --git a/src/auditordb/pg_get_denomination_pending.c b/src/auditordb/pg_get_denomination_pending.c
index 02ef99fe2..09276962c 100644
--- a/src/auditordb/pg_get_denomination_pending.c
+++ b/src/auditordb/pg_get_denomination_pending.c
@@ -13,14 +13,11 @@
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/>
*/
-
-
#include "platform.h"
#include "taler_error_codes.h"
#include "taler_dbevents.h"
#include "taler_pq_lib.h"
#include "pg_helper.h"
-
#include "pg_get_denomination_pending.h"
@@ -71,14 +68,20 @@ denomination_pending_cb (void *cls,
uint64_t serial_id;
struct TALER_AUDITORDB_DenominationPending dc;
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id),
+ GNUNET_PQ_result_spec_uint64 ("row_id",
+ &serial_id),
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
&dc.denom_pub_hash),
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance", &dc.denom_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss", &dc.denom_loss),
- GNUNET_PQ_result_spec_uint64 ("num_issued", &dc.num_issued),
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk", &dc.denom_risk),
- TALER_PQ_RESULT_SPEC_AMOUNT ("recoup_loss", &dc.recoup_loss),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance",
+ &dc.denom_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss",
+ &dc.denom_loss),
+ GNUNET_PQ_result_spec_uint64 ("num_issued",
+ &dc.num_issued),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk",
+ &dc.denom_risk),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("recoup_loss",
+ &dc.recoup_loss),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -108,14 +111,11 @@ TAH_PG_get_denomination_pending (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed, // maybe not needed
TALER_AUDITORDB_DenominationPendingCallback cb,
void *cb_cls)
{
-
- uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
-
struct PostgresClosure *pg = cls;
+ uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&offset),
GNUNET_PQ_query_param_uint64 (&plimit),
@@ -141,7 +141,7 @@ TAH_PG_get_denomination_pending (
" FROM auditor_denomination_pending"
" WHERE (row_id < $1)"
" ORDER BY row_id DESC"
- " LIMIT $3"
+ " LIMIT $2"
);
PREPARE (pg,
"auditor_denomination_pending_get_asc",
@@ -156,18 +156,16 @@ TAH_PG_get_denomination_pending (
" FROM auditor_denomination_pending"
" WHERE (row_id > $1)"
" ORDER BY row_id ASC"
- " LIMIT $3"
+ " LIMIT $2"
);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- (limit > 0)
- ?
- "auditor_denomination_pending_get_asc"
- :
- "auditor_denomination_pending_get_desc",
- params,
- &denomination_pending_cb,
- &dcc);
-
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_denomination_pending_get_asc"
+ : "auditor_denomination_pending_get_desc",
+ params,
+ &denomination_pending_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
diff --git a/src/auditordb/pg_get_denomination_pending.h b/src/auditordb/pg_get_denomination_pending.h
index 478c3248c..f951a2c1b 100644
--- a/src/auditordb/pg_get_denomination_pending.h
+++ b/src/auditordb/pg_get_denomination_pending.h
@@ -13,10 +13,8 @@
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/>
*/
-
-
-#ifndef SRC_PG_GET_DENOMINATION_PENDING_H
-#define SRC_PG_GET_DENOMINATION_PENDING_H
+#ifndef PG_GET_DENOMINATION_PENDING_H
+#define PG_GET_DENOMINATION_PENDING_H
#include "taler_util.h"
#include "taler_json_lib.h"
@@ -28,7 +26,6 @@
* @param cls the @e cls of this struct with the plugin-specific state
* @param limit number of records to return, negative for descending
* @param offset table row to start from, exclusive, direction determined by @a limit
- * @param return_suppressed should suppressed rows be returned anyway?
* @param cb function to call with results
* @param cb_cls closure for @a cb
* @return query result status
@@ -38,7 +35,6 @@ TAH_PG_get_denomination_pending (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed,
TALER_AUDITORDB_DenominationPendingCallback cb,
void *cb_cls);
diff --git a/src/auditordb/pg_get_purses.c b/src/auditordb/pg_get_purses.c
index b415d9aad..922e5c2a1 100644
--- a/src/auditordb/pg_get_purses.c
+++ b/src/auditordb/pg_get_purses.c
@@ -106,12 +106,11 @@ TAH_PG_get_purses (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed, // maybe not needed
TALER_AUDITORDB_PursesCallback cb,
void *cb_cls)
{
- uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
struct PostgresClosure *pg = cls;
+ uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&offset),
GNUNET_PQ_query_param_uint64 (&plimit),
@@ -133,9 +132,9 @@ TAH_PG_get_purses (
" target,"
" expiration_date"
" FROM auditor_purses"
- " WHERE (row_id < $1)"
- " ORDER BY row_id DESC"
- " LIMIT $3"
+ " WHERE (auditor_purses_rowid < $1)"
+ " ORDER BY auditor_purses_rowid DESC"
+ " LIMIT $2"
);
PREPARE (pg,
"auditor_purses_get_asc",
@@ -146,17 +145,18 @@ TAH_PG_get_purses (
" target,"
" expiration_date"
" FROM auditor_purses"
- " WHERE (row_id > $1)"
- " ORDER BY row_id ASC"
- " LIMIT $3"
+ " WHERE (auditor_purses_rowid > $1)"
+ " ORDER BY auditor_purses_rowid ASC"
+ " LIMIT $2"
);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- (limit > 0)
- ? "auditor_purses_get_asc"
- : "auditor_purses_get_desc",
- params,
- &purses_cb,
- &dcc);
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_purses_get_asc"
+ : "auditor_purses_get_desc",
+ params,
+ &purses_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
diff --git a/src/auditordb/pg_get_purses.h b/src/auditordb/pg_get_purses.h
index 5ee19bf2e..6f6d6659c 100644
--- a/src/auditordb/pg_get_purses.h
+++ b/src/auditordb/pg_get_purses.h
@@ -13,10 +13,8 @@
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/>
*/
-
-
-#ifndef SRC_PG_GET_PURSES_H
-#define SRC_PG_GET_PURSES_H
+#ifndef PG_GET_PURSES_H
+#define PG_GET_PURSES_H
#include "taler_util.h"
#include "taler_json_lib.h"
@@ -28,7 +26,6 @@
* @param cls the @e cls of this struct with the plugin-specific state
* @param limit number of records to return, negative for descending
* @param offset table row to start from, exclusive, direction determined by @a limit
- * @param return_suppressed should suppressed rows be returned anyway?
* @param cb function to call with results
* @param cb_cls closure for @a cb
* @return query result status
@@ -38,7 +35,6 @@ TAH_PG_get_purses (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed,
TALER_AUDITORDB_PursesCallback cb,
void *cb_cls);
diff --git a/src/auditordb/pg_get_reserves.c b/src/auditordb/pg_get_reserves.c
index 32247c4ec..222fec908 100644
--- a/src/auditordb/pg_get_reserves.c
+++ b/src/auditordb/pg_get_reserves.c
@@ -69,19 +69,26 @@ reserves_cb (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("auditor_reserves_rowid",
&dc.auditor_reserves_rowid),
- GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &dc.reserve_pub),
- TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance", &dc.reserve_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss", &dc.reserve_loss),
+ GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
+ &dc.reserve_pub),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance",
+ &dc.reserve_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss",
+ &dc.reserve_loss),
TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance",
&dc.withdraw_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance", &dc.close_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance", &dc.purse_fee_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance", &dc.open_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance",
+ &dc.close_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
+ &dc.purse_fee_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance",
+ &dc.open_fee_balance),
TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee_balance",
&dc.history_fee_balance),
GNUNET_PQ_result_spec_absolute_time ("expiration_date",
&dc.expiration_date),
- GNUNET_PQ_result_spec_string ("origin_account", &dc.origin_account),
+ GNUNET_PQ_result_spec_string ("origin_account",
+ &dc.origin_account),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -111,7 +118,6 @@ TAH_PG_get_reserves (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed, // maybe not needed
TALER_AUDITORDB_ReservesCallback cb,
void *cb_cls)
{
@@ -145,8 +151,8 @@ TAH_PG_get_reserves (
" origin_account"
" FROM auditor_reserves"
" WHERE (auditor_reserves_rowid < $1)"
- " ORDER BY row_id DESC"
- " LIMIT $3"
+ " ORDER BY auditor_reserves_rowid DESC"
+ " LIMIT $2"
);
PREPARE (pg,
"auditor_reserves_get_asc",
@@ -164,16 +170,17 @@ TAH_PG_get_reserves (
" origin_account"
" FROM auditor_reserves"
" WHERE (auditor_reserves_rowid > $1)"
- " ORDER BY row_id ASC"
- " LIMIT $3"
+ " ORDER BY auditor_reserves_rowid ASC"
+ " LIMIT $2"
);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- (limit > 0)
- ? "auditor_reserves_get_asc"
- : "auditor_reserves_get_desc",
- params,
- &reserves_cb,
- &dcc);
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_reserves_get_asc"
+ : "auditor_reserves_get_desc",
+ params,
+ &reserves_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
diff --git a/src/auditordb/pg_get_reserves.h b/src/auditordb/pg_get_reserves.h
index 6c07233b3..f6fe0776e 100644
--- a/src/auditordb/pg_get_reserves.h
+++ b/src/auditordb/pg_get_reserves.h
@@ -13,10 +13,8 @@
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/>
*/
-
-
-#ifndef SRC_PG_GET_RESERVES_H
-#define SRC_PG_GET_RESERVES_H
+#ifndef PG_GET_RESERVES_H
+#define PG_GET_RESERVES_H
#include "taler_util.h"
#include "taler_json_lib.h"
@@ -28,7 +26,6 @@
* @param cls the @e cls of this struct with the plugin-specific state
* @param limit number of records to return, negative for descending
* @param offset table row to start from, exclusive, direction determined by @a limit
- * @param return_suppressed should suppressed rows be returned anyway?
* @param cb function to call with results
* @param cb_cls closure for @a cb
* @return query result status
@@ -38,7 +35,6 @@ TAH_PG_get_reserves (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed,
TALER_AUDITORDB_ReservesCallback cb,
void *cb_cls);
diff --git a/src/auditordb/pg_get_wire_out_inconsistency.c b/src/auditordb/pg_get_wire_out_inconsistency.c
index b875f6051..4e9ca905f 100644
--- a/src/auditordb/pg_get_wire_out_inconsistency.c
+++ b/src/auditordb/pg_get_wire_out_inconsistency.c
@@ -13,14 +13,11 @@
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/>
*/
-
-
#include "platform.h"
#include "taler_error_codes.h"
#include "taler_dbevents.h"
#include "taler_pq_lib.h"
#include "pg_helper.h"
-
#include "pg_get_wire_out_inconsistency.h"
@@ -76,7 +73,7 @@ wire_out_inconsistency_cb (void *cls,
&dc.destination_account),
GNUNET_PQ_result_spec_string ("diagnostic",
&dc.diagnostic),
- GNUNET_PQ_result_spec_uint64 ("wire_out_row_id",
+ GNUNET_PQ_result_spec_uint64 ("wire_out_serial_id",
&dc.wire_out_row_id),
TALER_PQ_RESULT_SPEC_AMOUNT ("expected",
&dc.expected),
@@ -137,7 +134,7 @@ TAH_PG_get_wire_out_inconsistency (
" row_id"
",destination_account"
",diagnostic"
- ",wire_out_row_id"
+ ",wire_out_serial_id"
",expected"
",claimed"
",suppressed"
@@ -153,7 +150,7 @@ TAH_PG_get_wire_out_inconsistency (
" row_id"
",destination_account"
",diagnostic"
- ",wire_out_row_id"
+ ",wire_out_serial_id"
",expected"
",claimed"
",suppressed"
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index 5dc8251c9..5c55e65e6 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -30,6 +30,7 @@
#include "pg_del_reserve_info.h"
#include "pg_get_auditor_progress.h"
#include "pg_get_balance.h"
+#include "pg_get_balances.h"
#include "pg_get_denomination_balance.h"
#include "pg_get_deposit_confirmations.h"
#include "pg_get_purse_info.h"
@@ -141,10 +142,7 @@
#include "pg_update_misattribution_in_inconsistency.h"
#include "pg_get_reserves.h"
-#include "pg_del_reserves.h"
-
#include "pg_get_purses.h"
-#include "pg_del_purses.h"
#include "pg_get_denomination_pending.h"
#include "pg_del_denomination_pending.h"
@@ -588,6 +586,7 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
= &TAH_PG_get_auditor_progress;
plugin->get_balance = &TAH_PG_get_balance;
+ plugin->get_balances = &TAH_PG_get_balances;
plugin->insert_auditor_progress
= &TAH_PG_insert_auditor_progress;
@@ -777,10 +776,7 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
plugin->update_misattribution_in_inconsistency =
&TAH_PG_update_misattribution_in_inconsistency;
- plugin->delete_reserves = &TAH_PG_del_reserves;
plugin->get_reserves = &TAH_PG_get_reserves;
-
- plugin->delete_purses = &TAH_PG_del_purses;
plugin->get_purses = &TAH_PG_get_purses;
plugin->delete_denomination_pending = &TAH_PG_del_denomination_pending;
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
index 1b5dd0318..2b21c6dee 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -1221,6 +1221,27 @@ struct TALER_AUDITORDB_Plugin
/**
+ * Get information about balances from the database.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param limit number of balances to return at most,
+ * negative value to descend from @a offset
+ * @param offset 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
+ (*get_balances) (
+ void *cls,
+ int64_t limit,
+ uint64_t offset,
+ const char *balance_key,
+ TALER_AUDITORDB_BalancesCallback cb,
+ void *cb_cls);
+
+ /**
* Insert information about a signing key of the exchange.
*
* @param cls the @e cls of this struct with the plugin-specific state
@@ -1733,22 +1754,14 @@ struct TALER_AUDITORDB_Plugin
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed,
TALER_AUDITORDB_ReservesCallback cb,
void *cb_cls);
-
- enum GNUNET_DB_QueryStatus
- (*delete_reserves)(
- void *cls,
- uint64_t row_id);
-
enum GNUNET_DB_QueryStatus
(*get_purses)(
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed,
TALER_AUDITORDB_PursesCallback cb,
void *cb_cls);
@@ -1763,7 +1776,6 @@ struct TALER_AUDITORDB_Plugin
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed,
TALER_AUDITORDB_DenominationPendingCallback cb,
void *cb_cls);