aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.c64
-rw-r--r--src/auditor/taler-auditor-httpd_historic-reserve-summary-get.c77
-rw-r--r--src/auditor/taler-helper-auditor-aggregation.c410
-rw-r--r--src/auditor/taler-helper-auditor-reserves.c396
-rw-r--r--src/include/taler_auditordb_plugin.h9
5 files changed, 262 insertions, 694 deletions
diff --git a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.c b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.c
index 30d772a1b..544b97398 100644
--- a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.c
+++ b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.c
@@ -39,19 +39,25 @@ static enum GNUNET_GenericReturnValue
process_historic_denomination_revenue (
void *cls,
uint64_t serial_id,
- const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc)
+ 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)
{
json_t *list = cls;
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_data_auto ("denom_pub_hash", &dc->denom_pub_hash),
- TALER_JSON_pack_time_abs_human ("revenue_timestamp", dc->revenue_timestamp),
- TALER_JSON_pack_amount ("revenue_balance", &dc->revenue_balance),
- TALER_JSON_pack_amount ("loss_balance", &dc->loss_balance)
-
-
+ GNUNET_JSON_pack_uint64 ("serial_id",
+ serial_id),
+ GNUNET_JSON_pack_data_auto ("denom_pub_hash",
+ denom_pub_hash),
+ TALER_JSON_pack_time_abs_human ("revenue_timestamp",
+ revenue_timestamp.abs_time),
+ TALER_JSON_pack_amount ("revenue_balance",
+ revenue_balance),
+ TALER_JSON_pack_amount ("loss_balance",
+ loss_balance)
);
GNUNET_break (0 ==
json_array_append_new (list,
@@ -72,6 +78,8 @@ TAH_HISTORIC_DENOMINATION_REVENUE_handler_get (
const char *const args[])
{
json_t *ja;
+ int64_t limit = -20;
+ uint64_t offset;
enum GNUNET_DB_QueryStatus qs;
(void) rh;
@@ -82,54 +90,46 @@ TAH_HISTORIC_DENOMINATION_REVENUE_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;
-
- qs = TAH_plugin->get_historic_denomination_revenue (
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
+ qs = TAH_plugin->select_historic_denom_revenue (
TAH_plugin->cls,
limit,
offset,
- return_suppressed,
&process_historic_denomination_revenue,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
json_decref (ja);
TALER_LOG_WARNING (
"Failed to handle GET /historic-denomination-revenue");
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "historic-denomination-revenue");
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "select_historic_denom_revenue");
}
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("historic-denomination-revenue",
- ja));
+ GNUNET_JSON_pack_array_steal (
+ "historic-denomination-revenue",
+ ja));
}
diff --git a/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.c b/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.c
index 29a4465f9..0c56464c9 100644
--- a/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.c
+++ b/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.c
@@ -27,36 +27,40 @@
#include "taler-auditor-httpd_historic-reserve-summary-get.h"
/**
-* Add historic-reserve-summary 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 historic-reserve-summary 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 start_time beginning of aggregated time interval
+ * @param end_time end of aggregated time interval
+ * @param reserve_profits total profits made
+ *
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
*/
static enum GNUNET_GenericReturnValue
process_historic_reserve_summary (
void *cls,
uint64_t serial_id,
- const struct TALER_AUDITORDB_HistoricReserveSummary *dc)
+ struct GNUNET_TIME_Timestamp start_time,
+ struct GNUNET_TIME_Timestamp end_time,
+ const struct TALER_Amount *reserve_profits)
{
json_t *list = cls;
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_int64 ("row_id", serial_id),
- TALER_JSON_pack_time_abs_human ("start_date", dc->start_date),
- TALER_JSON_pack_time_abs_human ("end_date", dc->end_date),
- TALER_JSON_pack_amount ("reserve_profits", &dc->reserve_profits)
-
-
+ GNUNET_JSON_pack_int64 ("row_id",
+ serial_id),
+ TALER_JSON_pack_time_abs_human ("start_date",
+ start_time.abs_time),
+ TALER_JSON_pack_time_abs_human ("end_date",
+ end_time.abs_time),
+ TALER_JSON_pack_amount ("reserve_profits",
+ reserve_profits)
);
GNUNET_break (0 ==
json_array_append_new (list,
obj));
-
-
return GNUNET_OK;
}
@@ -72,6 +76,8 @@ TAH_HISTORIC_RESERVE_SUMMARY_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
(void) rh;
(void) connection_cls;
@@ -81,37 +87,28 @@ TAH_HISTORIC_RESERVE_SUMMARY_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;
-
- qs = TAH_plugin->get_historic_reserve_summary (
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
+ qs = TAH_plugin->select_historic_reserve_revenue (
TAH_plugin->cls,
limit,
offset,
- return_suppressed,
&process_historic_reserve_summary,
ja);
@@ -121,14 +118,16 @@ TAH_HISTORIC_RESERVE_SUMMARY_handler_get (
json_decref (ja);
TALER_LOG_WARNING (
"Failed to handle GET /historic-reserve-summary");
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "historic-reserve-summary");
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "select_historic_reserve_revenue");
}
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("historic-reserve-summary",
- ja));
+ GNUNET_JSON_pack_array_steal (
+ "historic-reserve-summary",
+ ja));
}
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c
index 8f62bbea4..8f757fada 100644
--- a/src/auditor/taler-helper-auditor-aggregation.c
+++ b/src/auditor/taler-helper-auditor-aggregation.c
@@ -22,7 +22,6 @@
#include <gnunet/gnunet_util_lib.h>
#include "taler_auditordb_plugin.h"
#include "taler_exchangedb_lib.h"
-#include "taler_json_lib.h"
#include "taler_bank_service.h"
#include "taler_signatures.h"
#include "taler_dbevents.h"
@@ -52,72 +51,41 @@ static TALER_ARL_DEF_PP (aggregation_last_wire_out_serial_id);
static TALER_ARL_DEF_AB (aggregation_total_wire_fee_revenue);
/**
- * Array of reports about row inconsistencies.
- */
-static json_t *report_row_inconsistencies;
-
-/**
- * Array of reports about irregular wire out entries.
- */
-static json_t *report_wire_out_inconsistencies;
-
-/**
* Total delta between calculated and stored wire out transfers,
* for positive deltas.
*/
-static struct TALER_Amount total_wire_out_delta_plus;
+static TALER_ARL_DEF_AB (aggregation_total_wire_out_delta_plus);
/**
* Total delta between calculated and stored wire out transfers
* for negative deltas.
*/
-static struct TALER_Amount total_wire_out_delta_minus;
-
-/**
- * Array of reports about inconsistencies about coins.
- */
-static json_t *report_coin_inconsistencies;
+static TALER_ARL_DEF_AB (aggregation_total_wire_out_delta_minus);
/**
* Profits the exchange made by bad amount calculations on coins.
*/
-static struct TALER_Amount total_coin_delta_plus;
+static TALER_ARL_DEF_AB (aggregation_total_coin_delta_plus);
/**
* Losses the exchange made by bad amount calculations on coins.
*/
-static struct TALER_Amount total_coin_delta_minus;
-
-/**
- * Report about amount calculation differences (causing profit
- * or loss at the exchange).
- */
-static json_t *report_amount_arithmetic_inconsistencies;
-
-/**
- * Array of reports about wire fees being ambiguous in terms of validity periods.
- */
-static json_t *report_fee_time_inconsistencies;
+static TALER_ARL_DEF_AB (aggregation_total_coin_delta_minus);
/**
* Profits the exchange made by bad amount calculations.
*/
-static struct TALER_Amount total_arithmetic_delta_plus;
+static TALER_ARL_DEF_AB (aggregation_total_arithmetic_delta_plus);
/**
* Losses the exchange made by bad amount calculations.
*/
-static struct TALER_Amount total_arithmetic_delta_minus;
-
-/**
- * Array of reports about coin operations with bad signatures.
- */
-static json_t *report_bad_sig_losses;
+static TALER_ARL_DEF_AB (aggregation_total_arithmetic_delta_minus);
/**
* Total amount lost by operations for which signatures were invalid.
*/
-static struct TALER_Amount total_bad_sig_loss;
+static TALER_ARL_DEF_AB (aggregation_total_bad_sig_loss);
/**
* Should we run checks that only work for exchange-internal audits?
@@ -199,8 +167,8 @@ report_amount_arithmetic_inconsistency (
if (0 != profitable)
{
target = (1 == profitable)
- ? &total_arithmetic_delta_plus
- : &total_arithmetic_delta_minus;
+ ? &TALER_ARL_USE_AB (aggregation_total_arithmetic_delta_plus)
+ : &TALER_ARL_USE_AB (aggregation_total_arithmetic_delta_minus);
TALER_ARL_amount_add (target,
target,
&delta);
@@ -272,8 +240,8 @@ report_coin_arithmetic_inconsistency (
if (0 != profitable)
{
target = (1 == profitable)
- ? &total_coin_delta_plus
- : &total_coin_delta_minus;
+ ? &TALER_ARL_USE_AB (aggregation_total_coin_delta_plus)
+ : &TALER_ARL_USE_AB (aggregation_total_coin_delta_minus);
TALER_ARL_amount_add (target,
target,
&delta);
@@ -905,8 +873,8 @@ wire_transfer_information_cb (
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
// FIXME: error handling
}
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (aggregation_total_bad_sig_loss),
+ &TALER_ARL_USE_AB (aggregation_total_bad_sig_loss),
coin_value);
TALER_denom_sig_free (&coin.denom_sig);
TALER_ARL_edb->free_coin_transaction_list (TALER_ARL_edb->cls,
@@ -1251,8 +1219,8 @@ check_wire_out_cb (void *cls,
&final_amount);
/* Sum up aggregation fees (we simply include the rounding gains) */
- TALER_ARL_amount_add (&TAC_aggregation_total_wire_fee_revenue,
- &TAC_aggregation_total_wire_fee_revenue,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (aggregation_total_wire_fee_revenue),
+ &TALER_ARL_USE_AB (aggregation_total_wire_fee_revenue),
&exchange_gain);
/* Check that calculated amount matches actual amount */
@@ -1268,8 +1236,10 @@ check_wire_out_cb (void *cls,
TALER_ARL_amount_subtract (&delta,
amount,
&final_amount);
- TALER_ARL_amount_add (&total_wire_out_delta_plus,
- &total_wire_out_delta_plus,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (
+ aggregation_total_wire_out_delta_plus),
+ &TALER_ARL_USE_AB (
+ aggregation_total_wire_out_delta_plus),
&delta);
}
else
@@ -1278,8 +1248,10 @@ check_wire_out_cb (void *cls,
TALER_ARL_amount_subtract (&delta,
&final_amount,
amount);
- TALER_ARL_amount_add (&total_wire_out_delta_minus,
- &total_wire_out_delta_minus,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (
+ aggregation_total_wire_out_delta_minus),
+ &TALER_ARL_USE_AB (
+ aggregation_total_wire_out_delta_minus),
&delta);
}
@@ -1326,8 +1298,6 @@ analyze_aggregations (void *cls)
enum GNUNET_DB_QueryStatus qsx;
enum GNUNET_DB_QueryStatus qs;
enum GNUNET_DB_QueryStatus qsp;
- char progress_exists = 1;
- char balance_exists = 1;
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1348,10 +1318,6 @@ analyze_aggregations (void *cls)
}
else
{
- if (TALER_ARL_USE_PP (aggregation_last_wire_out_serial_id) == 0)
- {
- progress_exists = 0;
- }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming aggregation audit at %llu\n",
(unsigned long long) TALER_ARL_USE_PP (
@@ -1364,23 +1330,55 @@ analyze_aggregations (void *cls)
qsx = TALER_ARL_adb->get_balance (
TALER_ARL_adb->cls,
TALER_ARL_GET_AB (aggregation_total_wire_fee_revenue),
+ TALER_ARL_GET_AB (aggregation_total_arithmetic_delta_plus),
+ TALER_ARL_GET_AB (aggregation_total_arithmetic_delta_minus),
+ TALER_ARL_GET_AB (aggregation_total_bad_sig_loss),
+ TALER_ARL_GET_AB (aggregation_total_wire_out_delta_plus),
+ TALER_ARL_GET_AB (aggregation_total_wire_out_delta_minus),
+ TALER_ARL_GET_AB (aggregation_total_coin_delta_plus),
NULL);
if (0 > qsx)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
return qsx;
}
-
- if (GNUNET_NO == TALER_amount_is_valid (&TALER_ARL_USE_AB (
- aggregation_total_wire_fee_revenue))
- )
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx)
{
GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &TALER_ARL_USE_AB (
- aggregation_total_wire_fee_revenue))
- );
- balance_exists = 0;
+ TALER_amount_set_zero (
+ TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ aggregation_total_wire_fee_revenue)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (
+ TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ aggregation_total_arithmetic_delta_plus)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (
+ TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ aggregation_total_arithmetic_delta_minus)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (
+ TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ aggregation_total_bad_sig_loss)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (
+ TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ aggregation_total_wire_out_delta_plus)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (
+ TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ aggregation_total_wire_out_delta_minus)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (
+ TALER_ARL_currency,
+ &TALER_ARL_USE_AB (
+ aggregation_total_coin_delta_plus)));
}
ac.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
@@ -1411,116 +1409,52 @@ analyze_aggregations (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == ac.qs);
return ac.qs;
}
- struct TALER_AUDITORDB_Balances b;
- b.balance_key = "aggregator_total_arithmetic_delta_plus";
- b.balance_value = total_arithmetic_delta_plus;
- ac.qs = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
- if (0 >= ac.qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- b.balance_key = "aggregator_total_arithmetic_delta_minus";
- b.balance_value = total_arithmetic_delta_minus;
- ac.qs = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
- if (0 >= ac.qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- b.balance_key = "aggregator_total_bad_sig_loss";
- b.balance_value = total_bad_sig_loss;
- ac.qs = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
- if (0 >= ac.qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- b.balance_key = "aggregator_total_wire_out_delta_plus";
- b.balance_value = total_wire_out_delta_plus;
- ac.qs = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
- if (0 >= ac.qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- b.balance_key = "aggregator_total_wire_out_delta_minus";
- b.balance_value = total_wire_out_delta_minus;
- ac.qs = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
- if (0 >= ac.qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- b.balance_key = "aggregator_total_coin_delta_minus";
- b.balance_value = total_coin_delta_minus;
- ac.qs = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
- if (0 >= ac.qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- b.balance_key = "aggregator_total_coin_delta_plus";
- b.balance_value = total_coin_delta_plus;
- ac.qs = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
- if (0 >= ac.qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
-
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx && balance_exists == 0)
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx)
{
- ac.qs = TALER_ARL_adb->insert_balance (
+ qs = TALER_ARL_adb->insert_balance (
TALER_ARL_adb->cls,
TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
+ TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_plus),
+ TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_minus),
+ TALER_ARL_SET_AB (aggregation_total_bad_sig_loss),
+ TALER_ARL_SET_AB (aggregation_total_wire_out_delta_plus),
+ TALER_ARL_SET_AB (aggregation_total_wire_out_delta_minus),
+ TALER_ARL_SET_AB (aggregation_total_coin_delta_plus),
NULL);
}
- else if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx && balance_exists == 1)
+ else
{
- ac.qs = TALER_ARL_adb->update_balance (
+ GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx);
+ qs = TALER_ARL_adb->update_balance (
TALER_ARL_adb->cls,
TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
+ TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_plus),
+ TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_minus),
+ TALER_ARL_SET_AB (aggregation_total_bad_sig_loss),
+ TALER_ARL_SET_AB (aggregation_total_wire_out_delta_plus),
+ TALER_ARL_SET_AB (aggregation_total_wire_out_delta_minus),
+ TALER_ARL_SET_AB (aggregation_total_coin_delta_plus),
NULL);
}
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == ac.qs)
+ if (0 >= qs)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Failed to update auditor DB, not recording progress\n");
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+ return qs;
+ }
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != ac.qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == ac.qs);
- return ac.qs;
- }
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp && progress_exists == 1)
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
{
- qs = TALER_ARL_adb->update_auditor_progress (
+ qs = TALER_ARL_adb->insert_auditor_progress (
TALER_ARL_adb->cls,
TALER_ARL_SET_PP (aggregation_last_wire_out_serial_id),
NULL);
}
else
{
- qs = TALER_ARL_adb->insert_auditor_progress (
+ GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp);
+ qs = TALER_ARL_adb->update_auditor_progress (
TALER_ARL_adb->cls,
TALER_ARL_SET_PP (aggregation_last_wire_out_serial_id),
NULL);
@@ -1554,58 +1488,11 @@ db_notify (void *cls,
const void *extra,
size_t extra_size)
{
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Received notification to wake aggregation helper\n");
-
(void) cls;
(void) extra;
(void) extra_size;
-
-
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &TALER_ARL_USE_AB (
- aggregation_total_wire_fee_revenue)));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_wire_out_delta_plus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_wire_out_delta_minus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_arithmetic_delta_plus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_arithmetic_delta_minus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_coin_delta_plus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_coin_delta_minus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_bad_sig_loss));
- GNUNET_assert (NULL !=
- (report_row_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_wire_out_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_coin_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_amount_arithmetic_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_bad_sig_losses
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_fee_time_inconsistencies
- = json_array ()));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Received notification to wake aggregation helper\n");
if (GNUNET_OK !=
TALER_ARL_setup_sessions_and_run (&analyze_aggregations,
NULL))
@@ -1614,9 +1501,7 @@ db_notify (void *cls,
"Audit failed\n");
TALER_ARL_done (NULL);
global_ret = EXIT_FAILURE;
-
}
-
}
@@ -1702,126 +1587,19 @@ run (void *cls,
return;
}
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running helper in test mode\n");
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting audit\n");
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &TALER_ARL_USE_AB (
- aggregation_total_wire_fee_revenue)));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_wire_out_delta_plus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_wire_out_delta_minus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_arithmetic_delta_plus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_arithmetic_delta_minus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_coin_delta_plus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_coin_delta_minus));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &total_bad_sig_loss));
- GNUNET_assert (NULL !=
- (report_row_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_wire_out_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_coin_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_amount_arithmetic_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_bad_sig_losses
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_fee_time_inconsistencies
- = json_array ()));
if (GNUNET_OK !=
TALER_ARL_setup_sessions_and_run (&analyze_aggregations,
NULL))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Audit failed\n");
- TALER_ARL_done (NULL);
global_ret = EXIT_FAILURE;
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Audit complete\n");
- TALER_ARL_done (GNUNET_JSON_PACK (
- /* blocks #1 */
- GNUNET_JSON_pack_array_steal (
- "wire_out_inconsistencies",
- report_wire_out_inconsistencies),
- /* Tested in test-auditor.sh #23 */
- TALER_JSON_pack_amount (
- "total_wire_out_delta_plus",
- &total_wire_out_delta_plus),
- /* Tested in test-auditor.sh #23 */
- TALER_JSON_pack_amount (
- "total_wire_out_delta_minus",
- &total_wire_out_delta_minus),
- /* Tested in test-auditor.sh #28/32 */
- GNUNET_JSON_pack_array_steal ("bad_sig_losses",
- report_bad_sig_losses),
- /* Tested in test-auditor.sh #28/32 */
- TALER_JSON_pack_amount ("total_bad_sig_loss",
- &total_bad_sig_loss),
- /* block #2 */
- /* Tested in test-auditor.sh #15 */
- GNUNET_JSON_pack_array_steal (
- "row_inconsistencies",
- report_row_inconsistencies),
- GNUNET_JSON_pack_array_steal (
- "coin_inconsistencies",
- report_coin_inconsistencies),
- TALER_JSON_pack_amount ("total_coin_delta_plus",
- &total_coin_delta_plus),
- TALER_JSON_pack_amount ("total_coin_delta_minus",
- &total_coin_delta_minus),
- GNUNET_JSON_pack_array_steal (
- "amount_arithmetic_inconsistencies",
- report_amount_arithmetic_inconsistencies),
- /* block #3 */
- TALER_JSON_pack_amount (
- "total_arithmetic_delta_plus",
- &total_arithmetic_delta_plus),
- TALER_JSON_pack_amount (
- "total_arithmetic_delta_minus",
- &total_arithmetic_delta_minus),
- TALER_JSON_pack_amount (
- "aggregation_total_wire_fee_revenue",
- &TALER_ARL_USE_AB (aggregation_total_wire_fee_revenue)),
- GNUNET_JSON_pack_uint64 (
- "start_ppa_wire_out_serial_id",
- 0 /* defunct */),
- GNUNET_JSON_pack_uint64 (
- "end_ppa_wire_out_serial_id",
- TALER_ARL_USE_PP (aggregation_last_wire_out_serial_id)),
- /* block #4 */
- TALER_JSON_pack_time_abs_human (
- "auditor_start_time",
- start_time),
- TALER_JSON_pack_time_abs_human (
- "auditor_end_time",
- GNUNET_TIME_absolute_get ()),
- GNUNET_JSON_pack_array_steal (
- "wire_fee_time_inconsistencies",
- report_fee_time_inconsistencies)));
}
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c
index 97fddc5b3..9b7caf698 100644
--- a/src/auditor/taler-helper-auditor-reserves.c
+++ b/src/auditor/taler-helper-auditor-reserves.c
@@ -22,7 +22,6 @@
#include <gnunet/gnunet_util_lib.h>
#include "taler_auditordb_plugin.h"
#include "taler_exchangedb_lib.h"
-#include "taler_json_lib.h"
#include "taler_bank_service.h"
#include "taler_signatures.h"
#include "report-lib.h"
@@ -75,82 +74,39 @@ static TALER_ARL_DEF_AB (reserves_purse_fee_revenue);
static TALER_ARL_DEF_AB (reserves_open_fee_revenue);
static TALER_ARL_DEF_AB (reserves_history_fee_revenue);
-
-/**
- * Array of reports about row inconsistencies.
- */
-static json_t *report_row_inconsistencies;
-
-/**
- * Array of reports about the denomination key not being
- * valid at the time of withdrawal.
- */
-static json_t *denomination_key_validity_withdraw_inconsistencies;
-
-/**
- * Array of reports about reserve balance insufficient inconsistencies.
- */
-static json_t *report_reserve_balance_insufficient_inconsistencies;
-
/**
- * Array of reports about purse balance insufficient inconsistencies.
+ * Total amount lost by operations for which signatures were invalid.
*/
-static json_t *report_purse_balance_insufficient_inconsistencies;
+static TALER_ARL_DEF_AB (reserves_total_bad_sig_loss);
/**
- * Array of reports about reserve balance summary wrong in database.
+ * Total amount affected by reserves not having been closed on time.
*/
-static json_t *report_reserve_balance_summary_wrong_inconsistencies;
+static TALER_ARL_DEF_AB (total_balance_reserve_not_closed);
/**
* Total delta between expected and stored reserve balance summaries,
* for positive deltas. Used only when internal checks are
* enabled.
*/
-static struct TALER_Amount total_balance_summary_delta_plus;
+static TALER_ARL_DEF_AB (total_balance_summary_delta_plus);
/**
* Total delta between expected and stored reserve balance summaries,
* for negative deltas. Used only when internal checks are
* enabled.
*/
-static struct TALER_Amount total_balance_summary_delta_minus;
-
-/**
- * Array of reports about reserve's not being closed inconsistencies.
- */
-static json_t *report_reserve_not_closed_inconsistencies;
-
-/**
- * Total amount affected by reserves not having been closed on time.
- */
-static struct TALER_Amount total_balance_reserve_not_closed;
-
-/**
- * Report about amount calculation differences (causing profit
- * or loss at the exchange).
- */
-static json_t *report_amount_arithmetic_inconsistencies;
+static TALER_ARL_DEF_AB (total_balance_summary_delta_minus);
/**
* Profits the exchange made by bad amount calculations.
*/
-static struct TALER_Amount total_arithmetic_delta_plus;
+static TALER_ARL_DEF_AB (reserves_total_arithmetic_delta_plus);
/**
* Losses the exchange made by bad amount calculations.
*/
-static struct TALER_Amount total_arithmetic_delta_minus;
-
-/**
- * Array of reports about coin operations with bad signatures.
- */
-static json_t *report_bad_sig_losses;
-
-/**
- * Total amount lost by operations for which signatures were invalid.
- */
-static struct TALER_Amount total_bad_sig_loss;
+static TALER_ARL_DEF_AB (reserves_total_arithmetic_delta_minus);
/**
* Should we run checks that only work for exchange-internal audits?
@@ -237,8 +193,8 @@ report_amount_arithmetic_inconsistency (
if (0 != profitable)
{
target = (1 == profitable)
- ? &total_arithmetic_delta_plus
- : &total_arithmetic_delta_minus;
+ ? &TALER_ARL_USE_AB (reserves_total_arithmetic_delta_plus)
+ : &TALER_ARL_USE_AB (reserves_total_arithmetic_delta_minus);
TALER_ARL_amount_add (target,
target,
&delta);
@@ -667,8 +623,8 @@ handle_reserve_out (void *cls,
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
// FIXME: error handling!
}
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
+ &TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
amount_with_fee);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -779,8 +735,8 @@ handle_recoup_by_reserve (
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
// FIXME: error handling!
}
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
+ &TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
amount);
}
@@ -854,8 +810,8 @@ handle_recoup_by_reserve (
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
}
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
+ &TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
amount);
}
@@ -1001,8 +957,8 @@ handle_reserve_open (
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
// FIXME: error handling!
}
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
+ &TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
reserve_payment);
return GNUNET_OK;
}
@@ -1153,8 +1109,8 @@ handle_reserve_closed (
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
// FIXME: error handling!
}
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
+ &TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
amount_with_fee);
}
}
@@ -1286,8 +1242,8 @@ handle_account_merged (
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
// FIXME: error handling!
}
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
+ &TALER_ARL_USE_AB (reserves_total_bad_sig_loss),
purse_fee);
return GNUNET_OK;
}
@@ -1480,8 +1436,10 @@ verify_reserve_balance (void *cls,
TALER_ARL_amount_subtract (&delta,
&rs->curr_balance.reserve_balance,
&reserve.balance);
- TALER_ARL_amount_add (&total_balance_summary_delta_plus,
- &total_balance_summary_delta_plus,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (
+ total_balance_summary_delta_plus),
+ &TALER_ARL_USE_AB (
+ total_balance_summary_delta_plus),
&delta);
}
else
@@ -1490,8 +1448,10 @@ verify_reserve_balance (void *cls,
TALER_ARL_amount_subtract (&delta,
&reserve.balance,
&rs->curr_balance.reserve_balance);
- TALER_ARL_amount_add (&total_balance_summary_delta_minus,
- &total_balance_summary_delta_minus,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (
+ total_balance_summary_delta_minus),
+ &TALER_ARL_USE_AB (
+ total_balance_summary_delta_minus),
&delta);
}
@@ -1562,8 +1522,10 @@ verify_reserve_balance (void *cls,
};
/* remaining balance (according to us) exceeds closing fee */
- TALER_ARL_amount_add (&total_balance_reserve_not_closed,
- &total_balance_reserve_not_closed,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (
+ total_balance_reserve_not_closed),
+ &TALER_ARL_USE_AB (
+ total_balance_reserve_not_closed),
&rnci.balance);
qs = TALER_ARL_adb->insert_reserve_not_closed_inconsistency (
TALER_ARL_adb->cls,
@@ -1582,14 +1544,13 @@ verify_reserve_balance (void *cls,
// TODO: fix correctly and not just comment out
// nbalance is set to invalid and there is never a check happening when working further with nbalance,
// why so and why adding those balances here? or what's the usecase of setting nbalance to zero?
- /*TALER_ARL_amount_add (&total_balance_reserve_not_closed,
- &total_balance_reserve_not_closed,
+ /*
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB(total_balance_reserve_not_closed),
+ &TALER_ARL_USE_AB(total_balance_reserve_not_closed),
&nbalance);*/
struct TALER_AUDITORDB_ReserveNotClosedInconsistency rncid = {
.reserve_pub = rs->reserve_pub,
- .balance = (nbalance.value)
- ? total_balance_reserve_not_closed
- : nbalance,
+ .balance = nbalance,
.expiration_time = rs->a_expiration_date.abs_time,
.diagnostic = "could not determine closing fee"
};
@@ -1737,7 +1698,6 @@ analyze_reserves (void *cls)
enum GNUNET_DB_QueryStatus qsx;
enum GNUNET_DB_QueryStatus qs;
enum GNUNET_DB_QueryStatus qsp;
- enum GNUNET_DB_QueryStatus qsb;
char progress_exists = 1;
char balance_exists = 1;
@@ -1800,14 +1760,20 @@ analyze_reserves (void *cls)
TALER_ARL_GET_AB (reserves_purse_fee_revenue),
TALER_ARL_GET_AB (reserves_open_fee_revenue),
TALER_ARL_GET_AB (reserves_history_fee_revenue),
+ TALER_ARL_GET_AB (reserves_total_bad_sig_loss),
+ TALER_ARL_GET_AB (total_balance_reserve_not_closed),
+ TALER_ARL_GET_AB (reserves_total_arithmetic_delta_plus),
+ TALER_ARL_GET_AB (reserves_total_arithmetic_delta_minus),
+ TALER_ARL_GET_AB (total_balance_summary_delta_minus),
NULL);
if (qsx < 0)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
return qsx;
}
- if (GNUNET_NO == TALER_amount_is_valid (&TALER_ARL_USE_AB (
- reserves_reserve_total_balance)))
+ if (GNUNET_NO ==
+ TALER_amount_is_valid (&TALER_ARL_USE_AB (
+ reserves_reserve_total_balance)))
{
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
@@ -1903,7 +1869,8 @@ analyze_reserves (void *cls)
GNUNET_CONTAINER_multihashmap_destroy (rc.revoked);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != rc.qs)
return qs;
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx && balance_exists == 0)
+ if ( (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) &&
+ (! balance_exists) )
{
qs = TALER_ARL_adb->insert_balance (
TALER_ARL_adb->cls,
@@ -1914,61 +1881,12 @@ analyze_reserves (void *cls)
TALER_ARL_SET_AB (reserves_purse_fee_revenue),
TALER_ARL_SET_AB (reserves_open_fee_revenue),
TALER_ARL_SET_AB (reserves_history_fee_revenue),
+ TALER_ARL_SET_AB (reserves_total_bad_sig_loss),
+ TALER_ARL_SET_AB (total_balance_reserve_not_closed),
+ TALER_ARL_SET_AB (reserves_total_arithmetic_delta_plus),
+ TALER_ARL_SET_AB (reserves_total_arithmetic_delta_minus),
+ TALER_ARL_SET_AB (total_balance_summary_delta_minus),
NULL);
- // TODO make it right
- struct TALER_AUDITORDB_Balances b;
- b.balance_key = "reserves_total_bad_sig_loss";
- b.balance_value = total_bad_sig_loss;
- qsb = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
- if (0 >= qsb)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- struct TALER_AUDITORDB_Balances b2;
- b2.balance_key = "total_balance_reserve_not_closed";
- b2.balance_value = total_balance_reserve_not_closed;
- qsb = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b2
- );
- if (0 >= qsb)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- struct TALER_AUDITORDB_Balances b3;
- b3.balance_key = "total_balance_summary_delta_minus";
- b3.balance_value = total_balance_summary_delta_minus;
- qsb = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b3
- );
- if (0 >= qsb)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- b.balance_key = "reserves_total_arithmetic_delta_plus";
- b.balance_value = total_arithmetic_delta_plus;
- qs = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
- if (0 >= qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
- }
- b.balance_key = "reserves_total_arithmetic_delta_minus";
- b.balance_value = total_arithmetic_delta_minus;
- qs = TALER_ARL_adb->insert_balances (
- TALER_ARL_adb->cls,
- &b
- );
if (0 >= qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
@@ -1986,6 +1904,11 @@ analyze_reserves (void *cls)
TALER_ARL_SET_AB (reserves_purse_fee_revenue),
TALER_ARL_SET_AB (reserves_open_fee_revenue),
TALER_ARL_SET_AB (reserves_history_fee_revenue),
+ TALER_ARL_SET_AB (reserves_total_bad_sig_loss),
+ TALER_ARL_SET_AB (total_balance_reserve_not_closed),
+ TALER_ARL_SET_AB (reserves_total_arithmetic_delta_plus),
+ TALER_ARL_SET_AB (reserves_total_arithmetic_delta_minus),
+ TALER_ARL_SET_AB (total_balance_summary_delta_minus),
NULL);
}
if (0 >= qs)
@@ -1993,7 +1916,8 @@ analyze_reserves (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
return qs;
}
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp && progress_exists == 1)
+ if ( (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) &&
+ progress_exists)
qs = TALER_ARL_adb->update_auditor_progress (
TALER_ARL_adb->cls,
TALER_ARL_SET_PP (reserves_reserve_in_serial_id),
@@ -2066,7 +1990,6 @@ db_notify (void *cls,
(void) extra;
(void) extra_size;
-
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
&TALER_ARL_USE_AB (
@@ -2098,54 +2021,37 @@ db_notify (void *cls,
// REVIEW:
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_balance_summary_delta_plus));
+ &TALER_ARL_USE_AB (
+ total_balance_summary_delta_plus)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_balance_summary_delta_minus));
+ &TALER_ARL_USE_AB (
+ total_balance_summary_delta_minus)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_arithmetic_delta_plus));
+ &TALER_ARL_USE_AB (
+ reserves_total_arithmetic_delta_plus))
+ );
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_arithmetic_delta_minus));
+ &TALER_ARL_USE_AB (
+ reserves_total_arithmetic_delta_minus)
+ ));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_balance_reserve_not_closed));
+ &TALER_ARL_USE_AB (
+ total_balance_reserve_not_closed)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_bad_sig_loss));
-
- GNUNET_assert (NULL !=
- (report_row_inconsistencies = json_array ()));
- GNUNET_assert (NULL !=
- (denomination_key_validity_withdraw_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_reserve_balance_summary_wrong_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_reserve_balance_insufficient_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_purse_balance_insufficient_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_reserve_not_closed_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_amount_arithmetic_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_bad_sig_losses = json_array ()));
+ &TALER_ARL_USE_AB (
+ reserves_total_bad_sig_loss)));
+
if (GNUNET_OK !=
TALER_ARL_setup_sessions_and_run (&analyze_reserves,
NULL))
{
-
-
global_ret = EXIT_FAILURE;
}
-
}
@@ -2288,45 +2194,31 @@ run (void *cls,
// REVIEW:
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_balance_summary_delta_plus));
+ &TALER_ARL_USE_AB (
+ total_balance_summary_delta_plus)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_balance_summary_delta_minus));
+ &TALER_ARL_USE_AB (
+ total_balance_summary_delta_minus)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_arithmetic_delta_plus));
+ &TALER_ARL_USE_AB (
+ reserves_total_arithmetic_delta_plus))
+ );
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_arithmetic_delta_minus));
+ &TALER_ARL_USE_AB (
+ reserves_total_arithmetic_delta_minus)
+ ));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_balance_reserve_not_closed));
+ &TALER_ARL_USE_AB (
+ total_balance_reserve_not_closed)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_bad_sig_loss));
-
- GNUNET_assert (NULL !=
- (report_row_inconsistencies = json_array ()));
- GNUNET_assert (NULL !=
- (denomination_key_validity_withdraw_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_reserve_balance_summary_wrong_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_reserve_balance_insufficient_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_purse_balance_insufficient_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_reserve_not_closed_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_amount_arithmetic_inconsistencies
- = json_array ()));
- GNUNET_assert (NULL !=
- (report_bad_sig_losses = json_array ()));
+ &TALER_ARL_USE_AB (
+ reserves_total_bad_sig_loss)));
+
if (GNUNET_OK !=
TALER_ARL_setup_sessions_and_run (&analyze_reserves,
NULL))
@@ -2339,114 +2231,6 @@ run (void *cls,
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Audit complete\n");
- TALER_ARL_done (
- GNUNET_JSON_PACK (
- /* Tested in test-auditor.sh #3 */
- GNUNET_JSON_pack_array_steal (
- "reserve_balance_summary_wrong_inconsistencies",
- report_reserve_balance_summary_wrong_inconsistencies),
- TALER_JSON_pack_amount ("total_balance_summary_delta_plus",
- &total_balance_summary_delta_plus),
- TALER_JSON_pack_amount ("total_balance_summary_delta_minus",
- &total_balance_summary_delta_minus),
- /* Tested in test-auditor.sh #21 */
- TALER_JSON_pack_amount ("total_balance_reserve_not_closed",
- &total_balance_reserve_not_closed),
- /* Tested in test-auditor.sh #7 */
- TALER_JSON_pack_amount ("total_bad_sig_loss",
- &total_bad_sig_loss),
- TALER_JSON_pack_amount ("total_arithmetic_delta_plus",
- &total_arithmetic_delta_plus),
- TALER_JSON_pack_amount ("total_arithmetic_delta_minus",
- &total_arithmetic_delta_minus),
-
- /* Global 'balances' */
- TALER_JSON_pack_amount ("total_escrow_balance",
- &TALER_ARL_USE_AB (
- reserves_reserve_total_balance)),
- /* Tested in test-auditor.sh #3 */
- TALER_JSON_pack_amount ("total_irregular_loss",
- &TALER_ARL_USE_AB (reserves_reserve_loss)),
- TALER_JSON_pack_amount ("total_withdraw_fee_income",
- &TALER_ARL_USE_AB (
- reserves_withdraw_fee_revenue)),
- TALER_JSON_pack_amount ("total_close_fee_income",
- &TALER_ARL_USE_AB (reserves_close_fee_revenue)),
- TALER_JSON_pack_amount ("total_purse_fee_income",
- &TALER_ARL_USE_AB (reserves_purse_fee_revenue)),
- TALER_JSON_pack_amount ("total_open_fee_income",
- &TALER_ARL_USE_AB (reserves_open_fee_revenue)),
- TALER_JSON_pack_amount ("total_history_fee_income",
- &TALER_ARL_USE_AB (reserves_history_fee_revenue)),
-
- /* Detailed report tables */
- GNUNET_JSON_pack_array_steal (
- "reserve_balance_insufficient_inconsistencies",
- report_reserve_balance_insufficient_inconsistencies),
- GNUNET_JSON_pack_array_steal (
- "purse_balance_insufficient_inconsistencies",
- report_purse_balance_insufficient_inconsistencies),
- /* Tested in test-auditor.sh #21 */
- GNUNET_JSON_pack_array_steal ("reserve_not_closed_inconsistencies",
- report_reserve_not_closed_inconsistencies),
- /* Tested in test-auditor.sh #7 */
- GNUNET_JSON_pack_array_steal ("bad_sig_losses",
- report_bad_sig_losses),
- /* Tested in test-revocation.sh #4 */
- GNUNET_JSON_pack_array_steal ("row_inconsistencies",
- report_row_inconsistencies),
- /* Tested in test-auditor.sh #23 */
- GNUNET_JSON_pack_array_steal (
- "denomination_key_validity_withdraw_inconsistencies",
- denomination_key_validity_withdraw_inconsistencies),
- GNUNET_JSON_pack_array_steal ("amount_arithmetic_inconsistencies",
- report_amount_arithmetic_inconsistencies),
-
- /* Information about audited range ... */
- TALER_JSON_pack_time_abs_human ("auditor_start_time",
- start_time),
- TALER_JSON_pack_time_abs_human ("auditor_end_time",
- GNUNET_TIME_absolute_get ()),
- GNUNET_JSON_pack_uint64 ("start_ppr_reserve_in_serial_id",
- 0 /* no longer supported */),
- GNUNET_JSON_pack_uint64 ("start_ppr_reserve_out_serial_id",
- 0 /* no longer supported */),
- GNUNET_JSON_pack_uint64 ("start_ppr_reserve_recoup_serial_id",
- 0 /* no longer supported */),
- GNUNET_JSON_pack_uint64 ("start_ppr_reserve_open_serial_id",
- 0 /* no longer supported */),
- GNUNET_JSON_pack_uint64 ("start_ppr_reserve_close_serial_id",
- 0 /* no longer supported */),
- GNUNET_JSON_pack_uint64 ("start_ppr_purse_decisions_serial_id",
- 0 /* no longer supported */),
- GNUNET_JSON_pack_uint64 ("start_ppr_account_merges_serial_id",
- 0 /* no longer supported */),
- GNUNET_JSON_pack_uint64 ("start_ppr_history_requests_serial_id",
- 0 /* no longer supported */),
- GNUNET_JSON_pack_uint64 ("end_ppr_reserve_in_serial_id",
- TALER_ARL_USE_PP (
- reserves_reserve_in_serial_id)),
- GNUNET_JSON_pack_uint64 ("end_ppr_reserve_out_serial_id",
- TALER_ARL_USE_PP (
- reserves_reserve_out_serial_id)),
- GNUNET_JSON_pack_uint64 ("end_ppr_reserve_recoup_serial_id",
- TALER_ARL_USE_PP (
- reserves_reserve_recoup_serial_id)),
- GNUNET_JSON_pack_uint64 ("end_ppr_reserve_open_serial_id",
- TALER_ARL_USE_PP (
- reserves_reserve_open_serial_id)),
- GNUNET_JSON_pack_uint64 ("end_ppr_reserve_close_serial_id",
- TALER_ARL_USE_PP (
- reserves_reserve_close_serial_id)),
- GNUNET_JSON_pack_uint64 ("end_ppr_purse_decisions_serial_id",
- TALER_ARL_USE_PP (
- reserves_purse_decisions_serial_id)),
- GNUNET_JSON_pack_uint64 ("end_ppr_account_merges_serial_id",
- TALER_ARL_USE_PP (
- reserves_account_merges_serial_id)),
- GNUNET_JSON_pack_uint64 ("end_ppr_history_requests_serial_id",
- TALER_ARL_USE_PP (
- reserves_history_requests_serial_id))));
}
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
index 203802e97..3a5ef2210 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -48,6 +48,7 @@
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_HistoricDenominationRevenueDataCallback)(
void *cls,
+ uint64_t serial_id,
const struct TALER_DenominationHashP *denom_pub_hash,
struct GNUNET_TIME_Timestamp revenue_timestamp,
const struct TALER_Amount *revenue_balance,
@@ -58,6 +59,7 @@ typedef enum GNUNET_GenericReturnValue
* Function called with the results of select_historic_reserve_revenue()
*
* @param cls closure
+ * @param serial_id row ID in the history table
* @param start_time beginning of aggregated time interval
* @param end_time end of aggregated time interval
* @param reserve_profits total profits made
@@ -70,6 +72,7 @@ typedef enum GNUNET_GenericReturnValue
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_HistoricReserveRevenueDataCallback)(
void *cls,
+ uint64_t serial_id,
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_Amount *reserve_profits);
@@ -1247,7 +1250,7 @@ struct TALER_AUDITORDB_Plugin
* Get information about deposit confirmations from the database.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param start_id row/serial ID where to start the iteration (0 from
+ * @param offset row/serial ID where to start the iteration (0 from
* the start, exclusive, i.e. serial_ids must start from 1)
* @param return_suppressed should suppressed rows be returned anyway?
* @param cb function to call with results
@@ -2232,6 +2235,8 @@ struct TALER_AUDITORDB_Plugin
enum GNUNET_DB_QueryStatus
(*select_historic_denom_revenue)(
void *cls,
+ int64_t limit,
+ uint64_t offset,
TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb,
void *cb_cls);
@@ -2264,6 +2269,8 @@ struct TALER_AUDITORDB_Plugin
enum GNUNET_DB_QueryStatus
(*select_historic_reserve_revenue)(
void *cls,
+ int64_t limit,
+ uint64_t offset,
TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb,
void *cb_cls);