aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-09-15 00:51:36 +0200
committerChristian Grothoff <christian@grothoff.org>2024-09-15 00:51:36 +0200
commit6c7d87da66d0fef808496ad0cea944e6f3fa0c93 (patch)
treec2baffb3b7043c80e629bb65ddac536ffb83075b
parentd0a419ba5c7ef0f5631df939e7fc40ea91dc8e20 (diff)
work on test-auditor, found magic suppression bug
-rw-r--r--src/auditor/taler-auditor-httpd_emergency-by-count-get.c75
-rw-r--r--src/auditor/taler-auditor-httpd_emergency-get.c73
-rw-r--r--src/auditor/taler-auditor-httpd_fee-time-inconsistency-get.c70
-rw-r--r--src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c65
-rwxr-xr-xsrc/auditor/test-auditor.sh38
-rw-r--r--src/auditordb/pg_get_emergency.c64
-rw-r--r--src/auditordb/pg_get_emergency_by_count.c59
-rw-r--r--src/auditordb/pg_get_fee_time_inconsistency.c8
-rw-r--r--src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c53
-rw-r--r--src/include/taler_auditordb_plugin.h14
10 files changed, 249 insertions, 270 deletions
diff --git a/src/auditor/taler-auditor-httpd_emergency-by-count-get.c b/src/auditor/taler-auditor-httpd_emergency-by-count-get.c
index b91dbacc3..d39636cea 100644
--- a/src/auditor/taler-auditor-httpd_emergency-by-count-get.c
+++ b/src/auditor/taler-auditor-httpd_emergency-by-count-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>
@@ -27,39 +25,43 @@
#include "taler-auditor-httpd_emergency-by-count-get.h"
/**
-* Add emergency-by-count 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 emergency-by-count to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
+ */
static enum GNUNET_GenericReturnValue
process_emergency_by_count (
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_EmergenciesByCount *dc)
{
json_t *list = cls;
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_uint64 ("row_id", serial_id),
- GNUNET_JSON_pack_data_auto ("denompub_h", &dc->denompub_h),
- GNUNET_JSON_pack_int64 ("num_issued", dc->num_issued),
- GNUNET_JSON_pack_int64 ("num_known", dc->num_known),
- TALER_JSON_pack_amount ("risk", &dc->risk),
- TALER_JSON_pack_time_abs_human ("start", dc->start),
- TALER_JSON_pack_time_abs_human ("deposit_end", dc->deposit_end),
- TALER_JSON_pack_amount ("value", &dc->value)
-
+ GNUNET_JSON_pack_uint64 ("row_id",
+ dc->row_id),
+ GNUNET_JSON_pack_data_auto ("denompub_h",
+ &dc->denompub_h),
+ GNUNET_JSON_pack_int64 ("num_issued",
+ dc->num_issued),
+ GNUNET_JSON_pack_int64 ("num_known",
+ dc->num_known),
+ TALER_JSON_pack_amount ("risk",
+ &dc->risk),
+ TALER_JSON_pack_time_abs_human ("start",
+ dc->start),
+ TALER_JSON_pack_time_abs_human ("deposit_end",
+ dc->deposit_end),
+ TALER_JSON_pack_amount ("value",
+ &dc->value),
+ GNUNET_JSON_pack_bool ("suppressed",
+ dc->suppressed)
);
GNUNET_break (0 ==
json_array_append_new (list,
obj));
-
-
return GNUNET_OK;
}
@@ -75,6 +77,9 @@ TAH_EMERGENCY_BY_COUNT_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+ bool return_suppressed = false;
(void) rh;
(void) connection_cls;
@@ -89,34 +94,29 @@ TAH_EMERGENCY_BY_COUNT_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;
- const char *ret_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "return_suppressed");
- if (ret_s != NULL && strcmp (ret_s, "true") == 0)
{
- return_suppressed = true;
+ const char *ret_s
+ = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "return_suppressed");
+ if (ret_s != NULL && strcmp (ret_s, "true") == 0)
+ {
+ return_suppressed = true;
+ }
}
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_emergency_by_count (
TAH_plugin->cls,
limit,
@@ -124,7 +124,6 @@ TAH_EMERGENCY_BY_COUNT_handler_get (
return_suppressed,
&process_emergency_by_count,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
diff --git a/src/auditor/taler-auditor-httpd_emergency-get.c b/src/auditor/taler-auditor-httpd_emergency-get.c
index 699d90400..089de70ef 100644
--- a/src/auditor/taler-auditor-httpd_emergency-get.c
+++ b/src/auditor/taler-auditor-httpd_emergency-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>
@@ -28,42 +26,41 @@
/**
-* Add emergency 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 emergency to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
+ */
static enum GNUNET_GenericReturnValue
process_emergency (
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_Emergency *dc)
{
json_t *list = cls;
json_t *obj;
-
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_int64 ("row_id", serial_id),
-
- GNUNET_JSON_pack_data_auto ("denompub_h", &dc->denompub_h),
-
- TALER_JSON_pack_amount ("denom_risk", &dc->denom_risk),
- TALER_JSON_pack_amount ("denom_loss", &dc->denom_loss),
-
- TALER_JSON_pack_time_abs_human ("deposit_start", dc->deposit_start),
- TALER_JSON_pack_time_abs_human ("deposit_end", dc->deposit_end),
-
- TALER_JSON_pack_amount ("value", &dc->value)
+ GNUNET_JSON_pack_uint64 ("row_id",
+ &dc->row_id),
+ GNUNET_JSON_pack_data_auto ("denompub_h",
+ &dc->denompub_h),
+ TALER_JSON_pack_amount ("denom_risk",
+ &dc->denom_risk),
+ TALER_JSON_pack_amount ("denom_loss",
+ &dc->denom_loss),
+ TALER_JSON_pack_time_abs_human ("deposit_start",
+ dc->deposit_start),
+ TALER_JSON_pack_time_abs_human ("deposit_end",
+ dc->deposit_end),
+ TALER_JSON_pack_amount ("value",
+ &dc->value),
+ GNUNET_JSON_pack_bool ("suppressed",
+ &dc->suppressed)
);
GNUNET_break (0 ==
json_array_append_new (list,
obj));
-
-
return GNUNET_OK;
}
@@ -79,6 +76,9 @@ TAH_EMERGENCY_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+ bool return_suppressed = false;
(void) rh;
(void) connection_cls;
@@ -93,27 +93,29 @@ TAH_EMERGENCY_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);
+ {
+ const char *ret_s
+ = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "return_suppressed");
+ if (ret_s != NULL && strcmp (ret_s, "true") == 0)
+ {
+ return_suppressed = true;
+ }
+ }
- bool return_suppressed = false;
-
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_emergency (
TAH_plugin->cls,
limit,
@@ -121,7 +123,6 @@ TAH_EMERGENCY_handler_get (
return_suppressed,
&process_emergency,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
diff --git a/src/auditor/taler-auditor-httpd_fee-time-inconsistency-get.c b/src/auditor/taler-auditor-httpd_fee-time-inconsistency-get.c
index 26b8e489d..742370eb7 100644
--- a/src/auditor/taler-auditor-httpd_fee-time-inconsistency-get.c
+++ b/src/auditor/taler-auditor-httpd_fee-time-inconsistency-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,38 +24,37 @@
#include "taler-auditor-httpd.h"
#include "taler-auditor-httpd_fee-time-inconsistency-get.h"
+
/**
-* Add fee-time-inconsistency 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 fee-time-inconsistency to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
+ */
static enum GNUNET_GenericReturnValue
process_fee_time_inconsistency (
void *cls,
- uint64_t serial_id,
- const struct
- TALER_AUDITORDB_FeeTimeInconsistency
- *dc)
+ const struct TALER_AUDITORDB_FeeTimeInconsistency *dc)
{
json_t *list = cls;
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_string ("type", dc->type),
- TALER_JSON_pack_time_abs_human ("time", dc->time),
- GNUNET_JSON_pack_string ("diagnostic", dc->diagnostic)
-
-
+ GNUNET_JSON_pack_uint64 ("row_id",
+ dc->row_id),
+ GNUNET_JSON_pack_uint64 ("problem_row_id",
+ dc->problem_row_id),
+ GNUNET_JSON_pack_string ("type",
+ dc->type),
+ TALER_JSON_pack_time_abs_human ("time",
+ dc->time),
+ GNUNET_JSON_pack_string ("diagnostic",
+ dc->diagnostic)
);
GNUNET_break (0 ==
json_array_append_new (list,
obj));
-
-
return GNUNET_OK;
}
@@ -73,6 +70,9 @@ TAH_FEE_TIME_INCONSISTENCY_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+ bool return_suppressed = false;
(void) rh;
(void) connection_cls;
@@ -87,34 +87,29 @@ TAH_FEE_TIME_INCONSISTENCY_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;
- const char *ret_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "return_suppressed");
- if (ret_s != NULL && strcmp (ret_s, "true") == 0)
{
- return_suppressed = true;
+ const char *ret_s
+ = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "return_suppressed");
+ if (ret_s != NULL && strcmp (ret_s, "true") == 0)
+ {
+ return_suppressed = true;
+ }
}
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_fee_time_inconsistency (
TAH_plugin->cls,
limit,
@@ -122,7 +117,6 @@ TAH_FEE_TIME_INCONSISTENCY_handler_get (
return_suppressed,
&process_fee_time_inconsistency,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
@@ -137,6 +131,6 @@ TAH_FEE_TIME_INCONSISTENCY_handler_get (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("fee-time-inconsistency",
+ GNUNET_JSON_pack_array_steal ("fee_time_inconsistency",
ja));
}
diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c
index 87025b434..5f3d66c63 100644
--- a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c
+++ b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-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,36 +24,37 @@
#include "taler-auditor-httpd.h"
#include "taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.h"
+
/**
-* Add reserve-balance-insufficient-inconsistency 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 reserve-balance-insufficient-inconsistency to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
+ */
static enum GNUNET_GenericReturnValue
process_reserve_balance_insufficient_inconsistency (
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency *dc)
{
json_t *list = cls;
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_uint64 ("row_id", serial_id),
- GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub),
- GNUNET_JSON_pack_bool ("inconsistency_gain", dc->inconsistency_gain),
- TALER_JSON_pack_amount ("inconsistency_amount", &dc->inconsistency_amount)
-
+ GNUNET_JSON_pack_uint64 ("row_id",
+ dc->row_id),
+ GNUNET_JSON_pack_data_auto ("reserve_pub",
+ &dc->reserve_pub),
+ GNUNET_JSON_pack_bool ("inconsistency_gain",
+ dc->inconsistency_gain),
+ TALER_JSON_pack_amount ("inconsistency_amount",
+ &dc->inconsistency_amount),
+ GNUNET_JSON_pack_bool ("suppressed",
+ dc->suppressed)
);
GNUNET_break (0 ==
json_array_append_new (list,
obj));
-
-
return GNUNET_OK;
}
@@ -71,6 +70,9 @@ TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+ bool return_suppressed = false;
(void) rh;
(void) connection_cls;
@@ -85,33 +87,29 @@ TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_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;
- const char *ret_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "return_suppressed");
- if (ret_s != NULL && strcmp (ret_s, "true") == 0)
{
- return_suppressed = true;
+ const char *ret_s
+ = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "return_suppressed");
+ if (ret_s != NULL && strcmp (ret_s, "true") == 0)
+ {
+ return_suppressed = true;
+ }
}
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_reserve_balance_insufficient_inconsistency (
TAH_plugin->cls,
limit,
@@ -119,7 +117,6 @@ TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_get (
return_suppressed,
&process_reserve_balance_insufficient_inconsistency,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
@@ -134,6 +131,6 @@ TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_get (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("reserve-balance-insufficient-inconsistency",
+ GNUNET_JSON_pack_array_steal ("reserve_balance_insufficient_inconsistency",
ja));
}
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index e08acbd08..b773e59bc 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -1502,29 +1502,23 @@ function test_18() {
run_audit
check_auditor_running
+ echo -n "Testing bad reserve balance summary reporting ... "
+ # note: we check "suppressed" to only check the *existence* here.
+ check_report \
+ "reserve-balance-summary-wrong-inconsistency" \
+ "suppressed" "false"
echo -n "Testing emergency detection... "
- call_endpoint "reserve-balance-summary-wrong-inconsistency"
- jq -e .reserve_balance_summary_wrong_inconsistency[0] \
- < "${MY_TMP_DIR}/reserve-balance-summary-wrong-inconsistency.json" \
- > /dev/null \
- || exit_fail "Reserve balance inconsistency not detected"
- call_endpoint "emergency"
- jq -e .emergency[0] \
- < "${MY_TMP_DIR}/emergency.json" \
- > /dev/null \
- || exit_fail "Emergency not detected"
- call_endpoint "emergency-by-count"
- jq -e .emergency_by_count[0] \
- < "${MY_TMP_DIR}/emergency-by-count.json" \
- > /dev/null \
- || exit_fail "Emergency by count not detected"
- call_endpoint "amount-arithmetic-inconsistency"
- jq -e .amount_arithmetic_inconsistency[0] \
- < "${MY_TMP_DIR}/amount-arithmetic-inconsistency.json" \
- > /dev/null \
- || exit_fail "Escrow balance calculation impossibility not detected"
- echo "PASS"
-
+ check_report \
+ "emergency" \
+ "suppressed" "false"
+ echo -n "Testing emergency detection by count... "
+ check_report \
+ "emergency-by-count"
+ "suppressed" "false"
+ echo -n "Testing escrow balance calculation impossibility... "
+ check_report \
+ "amount-arithmetic-inconsistency" \
+ "suppressed" "false"
echo -n "Testing loss calculation by count... "
check_not_balance \
"coins_emergencies_loss_by_count" \
diff --git a/src/auditordb/pg_get_emergency.c b/src/auditordb/pg_get_emergency.c
index a1e615ab2..0371e372d 100644
--- a/src/auditordb/pg_get_emergency.c
+++ b/src/auditordb/pg_get_emergency.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_emergency.h"
/**
@@ -70,18 +67,24 @@ emergency_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
- uint64_t serial_id;
-
struct TALER_AUDITORDB_Emergency dc;
-
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id),
- GNUNET_PQ_result_spec_auto_from_type ("denompub_h", &dc.denompub_h),
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk", &dc.denom_risk),
- TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss", &dc.denom_loss),
- GNUNET_PQ_result_spec_absolute_time ("deposit_start", &dc.deposit_start),
- GNUNET_PQ_result_spec_absolute_time ("deposit_end", &dc.deposit_end),
- TALER_PQ_RESULT_SPEC_AMOUNT ("value", &dc.value),
+ GNUNET_PQ_result_spec_uint64 ("row_id",
+ &dc.row_id),
+ GNUNET_PQ_result_spec_auto_from_type ("denompub_h",
+ &dc.denompub_h),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk",
+ &dc.denom_risk),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss",
+ &dc.denom_loss),
+ GNUNET_PQ_result_spec_absolute_time ("deposit_start",
+ &dc.deposit_start),
+ GNUNET_PQ_result_spec_absolute_time ("deposit_end",
+ &dc.deposit_end),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("value",
+ &dc.value),
+ GNUNET_PQ_result_spec_bool ("suppressed",
+ &dc.suppressed),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -95,11 +98,8 @@ emergency_cb (void *cls,
dcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return;
}
-
dcc->qs = i + 1;
-
rval = dcc->cb (dcc->cb_cls,
- serial_id,
&dc);
GNUNET_PQ_cleanup_result (rs);
if (GNUNET_OK != rval)
@@ -113,16 +113,15 @@ TAH_PG_get_emergency (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed, // maybe not needed
+ bool return_suppressed,
TALER_AUDITORDB_EmergencyCallback 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
};
@@ -143,10 +142,12 @@ TAH_PG_get_emergency (
",deposit_start"
",deposit_end"
",value"
+ ",suppressed"
" FROM auditor_emergency"
" WHERE (row_id < $1)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id DESC"
- " LIMIT $2"
+ " LIMIT $3"
);
PREPARE (pg,
"auditor_emergency_get_asc",
@@ -158,21 +159,24 @@ TAH_PG_get_emergency (
",deposit_start"
",deposit_end"
",value"
+ ",suppressed"
" FROM auditor_emergency"
" WHERE (row_id > $1)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id ASC"
- " LIMIT $2"
+ " LIMIT $3"
);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- (limit > 0) ?
- "auditor_emergency_get_asc" :
- "auditor_emergency_get_desc",
- params,
- &emergency_cb,
- &dcc);
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_emergency_get_asc"
+ : "auditor_emergency_get_desc",
+ params,
+ &emergency_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
return qs;
-} \ No newline at end of file
+}
diff --git a/src/auditordb/pg_get_emergency_by_count.c b/src/auditordb/pg_get_emergency_by_count.c
index eecc6594e..60d434b9b 100644
--- a/src/auditordb/pg_get_emergency_by_count.c
+++ b/src/auditordb/pg_get_emergency_by_count.c
@@ -13,16 +13,14 @@
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_emergency_by_count.h"
+
/**
* Closure for #emergency_cb().
*/
@@ -70,17 +68,26 @@ emergency_by_count_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
- uint64_t serial_id;
struct TALER_AUDITORDB_EmergenciesByCount dc;
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id),
- GNUNET_PQ_result_spec_auto_from_type ("denompub_h", &dc.denompub_h),
- GNUNET_PQ_result_spec_uint64 ("num_issued", &dc.num_issued),
- GNUNET_PQ_result_spec_uint64 ("num_known", &dc.num_known),
- TALER_PQ_RESULT_SPEC_AMOUNT ("risk", &dc.risk),
- GNUNET_PQ_result_spec_absolute_time ("start", &dc.start),
- GNUNET_PQ_result_spec_absolute_time ("deposit_end", &dc.deposit_end),
- TALER_PQ_RESULT_SPEC_AMOUNT ("value", &dc.value),
+ GNUNET_PQ_result_spec_uint64 ("row_id",
+ &dc.row_id),
+ GNUNET_PQ_result_spec_auto_from_type ("denompub_h",
+ &dc.denompub_h),
+ GNUNET_PQ_result_spec_uint64 ("num_issued",
+ &dc.num_issued),
+ GNUNET_PQ_result_spec_uint64 ("num_known",
+ &dc.num_known),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("risk",
+ &dc.risk),
+ GNUNET_PQ_result_spec_absolute_time ("start",
+ &dc.start),
+ GNUNET_PQ_result_spec_absolute_time ("deposit_end",
+ &dc.deposit_end),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("value",
+ &dc.value),
+ GNUNET_PQ_result_spec_bool ("suppressed",
+ &dc.suppressed),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -96,7 +103,6 @@ emergency_by_count_cb (void *cls,
}
dcc->qs = i + 1;
rval = dcc->cb (dcc->cb_cls,
- serial_id,
&dc);
GNUNET_PQ_cleanup_result (rs);
if (GNUNET_OK != rval)
@@ -110,12 +116,12 @@ TAH_PG_get_emergency_by_count (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed, // maybe not needed
+ bool return_suppressed,
TALER_AUDITORDB_EmergenciesByCountCallback 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),
@@ -140,9 +146,10 @@ TAH_PG_get_emergency_by_count (
",start"
",deposit_end"
",value"
+ ",suppressed"
" FROM auditor_emergency_by_count"
" WHERE (row_id < $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id DESC"
" LIMIT $3"
);
@@ -157,21 +164,21 @@ TAH_PG_get_emergency_by_count (
",start"
",deposit_end"
",value"
+ ",suppressed"
" FROM auditor_emergency_by_count"
" WHERE (row_id > $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id ASC"
" LIMIT $3"
);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- (limit > 0)
- ?
- "auditor_emergency_by_count_get_asc"
- :
- "auditor_emergency_by_count_get_desc",
- params,
- &emergency_by_count_cb,
- &dcc);
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_emergency_by_count_get_asc"
+ : "auditor_emergency_by_count_get_desc",
+ params,
+ &emergency_by_count_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
diff --git a/src/auditordb/pg_get_fee_time_inconsistency.c b/src/auditordb/pg_get_fee_time_inconsistency.c
index 51753fac9..f7e4f171d 100644
--- a/src/auditordb/pg_get_fee_time_inconsistency.c
+++ b/src/auditordb/pg_get_fee_time_inconsistency.c
@@ -66,11 +66,10 @@ fee_time_inconsistency_cb (void *cls,
struct FeeTimeInconsistencyContext *dcc = cls;
for (unsigned int i = 0; i < num_results; i++)
{
- uint64_t serial_id;
struct TALER_AUDITORDB_FeeTimeInconsistency dc;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("row_id",
- &serial_id),
+ &dc.row_id),
GNUNET_PQ_result_spec_uint64 ("problem_row_id",
&dc.problem_row_id),
GNUNET_PQ_result_spec_string ("fee_type",
@@ -94,7 +93,6 @@ fee_time_inconsistency_cb (void *cls,
}
dcc->qs = i + 1;
rval = dcc->cb (dcc->cb_cls,
- serial_id,
&dc);
GNUNET_PQ_cleanup_result (rs);
if (GNUNET_OK != rval)
@@ -137,7 +135,7 @@ TAH_PG_get_fee_time_inconsistency (
",diagnostic"
" FROM auditor_fee_time_inconsistency"
" WHERE (row_id < $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id DESC"
" LIMIT $3"
);
@@ -151,7 +149,7 @@ TAH_PG_get_fee_time_inconsistency (
",diagnostic"
" FROM auditor_fee_time_inconsistency"
" WHERE (row_id > $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id ASC"
" LIMIT $3"
);
diff --git a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c
index 97f2f523b..65bbe964e 100644
--- a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c
+++ b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c
@@ -13,16 +13,14 @@
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_reserve_balance_insufficient_inconsistency.h"
+
/**
* Closure for #reserve_balance_insufficient_inconsistency_cb().
*/
@@ -70,18 +68,18 @@ reserve_balance_insufficient_inconsistency_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
- uint64_t serial_id;
-
struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency dc;
-
struct GNUNET_PQ_ResultSpec rs[] = {
-
- GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id),
- GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &dc.reserve_pub),
- GNUNET_PQ_result_spec_bool ("inconsistency_gain", &dc.inconsistency_gain),
+ GNUNET_PQ_result_spec_uint64 ("row_id",
+ &dc.row_id),
+ GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
+ &dc.reserve_pub),
+ GNUNET_PQ_result_spec_bool ("inconsistency_gain",
+ &dc.inconsistency_gain),
TALER_PQ_RESULT_SPEC_AMOUNT ("inconsistency_amount",
&dc.inconsistency_amount),
-
+ GNUNET_PQ_result_spec_bool ("suppressed",
+ &dc.suppressed),
GNUNET_PQ_result_spec_end
};
enum GNUNET_GenericReturnValue rval;
@@ -95,11 +93,8 @@ reserve_balance_insufficient_inconsistency_cb (void *cls,
dcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return;
}
-
dcc->qs = i + 1;
-
rval = dcc->cb (dcc->cb_cls,
- serial_id,
&dc);
GNUNET_PQ_cleanup_result (rs);
if (GNUNET_OK != rval)
@@ -113,14 +108,12 @@ TAH_PG_get_reserve_balance_insufficient_inconsistency (
void *cls,
int64_t limit,
uint64_t offset,
- bool return_suppressed, // maybe not needed
+ bool return_suppressed,
TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback 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),
@@ -141,9 +134,10 @@ TAH_PG_get_reserve_balance_insufficient_inconsistency (
",reserve_pub"
",inconsistency_gain"
",inconsistency_amount"
+ ",suppressed"
" FROM auditor_reserve_balance_insufficient_inconsistency"
" WHERE (row_id < $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id DESC"
" LIMIT $3"
);
@@ -154,22 +148,21 @@ TAH_PG_get_reserve_balance_insufficient_inconsistency (
",reserve_pub"
",inconsistency_gain"
",inconsistency_amount"
+ ",suppressed"
" FROM auditor_reserve_balance_insufficient_inconsistency"
" WHERE (row_id > $1)"
- " AND ($2 OR suppressed is false)"
+ " AND ($2 OR NOT suppressed)"
" ORDER BY row_id ASC"
" LIMIT $3"
);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- (limit > 0) ?
- "auditor_reserve_balance_insufficient_inconsistency_get_asc"
- :
- "auditor_reserve_balance_insufficient_inconsistency_get_desc",
- params,
- &
- reserve_balance_insufficient_inconsistency_cb,
- &dcc);
-
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "auditor_reserve_balance_insufficient_inconsistency_get_asc"
+ : "auditor_reserve_balance_insufficient_inconsistency_get_desc",
+ params,
+ &reserve_balance_insufficient_inconsistency_cb,
+ &dcc);
if (qs > 0)
return dcc.qs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
index 026351964..ad2eae980 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -286,6 +286,7 @@ struct TALER_AUDITORDB_Emergency
struct GNUNET_TIME_Absolute deposit_start;
struct GNUNET_TIME_Absolute deposit_end;
struct TALER_Amount value;
+ bool suppressed;
};
/**
@@ -301,6 +302,7 @@ struct TALER_AUDITORDB_EmergenciesByCount
struct GNUNET_TIME_Absolute start;
struct GNUNET_TIME_Absolute deposit_end;
struct TALER_Amount value;
+ bool suppressed;
};
/**
@@ -366,6 +368,7 @@ struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency
struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub;
bool inconsistency_gain;
struct TALER_Amount inconsistency_amount;
+ bool suppressed;
};
/**
@@ -483,7 +486,6 @@ typedef enum GNUNET_GenericReturnValue
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_EmergencyCallback)(
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_Emergency *dc);
/**
@@ -498,7 +500,6 @@ typedef enum GNUNET_GenericReturnValue
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_EmergenciesByCountCallback)(
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_EmergenciesByCount *dc);
@@ -527,7 +528,6 @@ typedef enum GNUNET_GenericReturnValue
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_FeeTimeInconsistencyCallback)(
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_FeeTimeInconsistency *dc);
/**
@@ -566,14 +566,12 @@ typedef enum GNUNET_GenericReturnValue
* the auditor's database.
*
* @param cls closure
- * @param serial_id location of the @a dc in the database
* @param dc the structure itself
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
*/
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback)(
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency *dc);
typedef enum GNUNET_GenericReturnValue
@@ -944,12 +942,6 @@ typedef enum GNUNET_GenericReturnValue
const struct TALER_AUDITORDB_RowMinorInconsistencies *dc);
-typedef enum GNUNET_GenericReturnValue
-(*TALER_AUDITORDB_FeeTimeInconsistencyCallback)(
- void *cls,
- uint64_t serial_id,
- const struct TALER_AUDITORDB_FeeTimeInconsistency *dc);
-
/**
* @brief The plugin API, returned from the plugin's "init" function.
* The argument given to "init" is simply a configuration handle.