aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-20 02:45:33 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-20 02:45:33 +0100
commit3fde028650e220157f208fa8399d32cc1b0eebde (patch)
tree2dbc393a8f279abbf6fb629f15511a85e9176178
parenta38fa32484286d2895dca10d3f53d3c7599d2f3b (diff)
fix auditor progress point issue
-rw-r--r--src/auditor/taler-auditor.c26
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c23
-rw-r--r--src/include/taler_auditordb_plugin.h7
3 files changed, 40 insertions, 16 deletions
diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c
index 971f6e51f..54e6180b8 100644
--- a/src/auditor/taler-auditor.c
+++ b/src/auditor/taler-auditor.c
@@ -25,7 +25,6 @@
* given in the 'wire_out' table. This needs to be checked separately!
*
* KNOWN BUGS:
- * - resolve HACK! -- need extra serial_id in 'pp' as we go over reserve_out twice!
* - risk is not calculated correctly
* - calculate, store and report aggregation fee balance!
* - error handling if denomination keys are used that are not known to the
@@ -1000,7 +999,7 @@ analyze_reserves (void *cls)
rc.reserves = GNUNET_CONTAINER_multihashmap_create (512,
GNUNET_NO);
- if (GNUNET_OK !=
+ if (GNUNET_SYSERR ==
edb->select_reserves_in_above_serial_id (edb->cls,
esession,
pp.last_reserve_in_serial_id,
@@ -1010,7 +1009,7 @@ analyze_reserves (void *cls)
GNUNET_break (0);
return GNUNET_SYSERR;
}
- if (GNUNET_OK !=
+ if (GNUNET_SYSERR ==
edb->select_reserves_out_above_serial_id (edb->cls,
esession,
pp.last_reserve_out_serial_id,
@@ -2051,6 +2050,9 @@ withdraw_cb (void *cls,
const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki;
struct TALER_Amount value;
+ GNUNET_assert (rowid >= pp.last_withdraw_serial_id); /* should be monotonically increasing */
+ pp.last_withdraw_serial_id = rowid + 1;
+
if (GNUNET_OK !=
get_denomination_info (denom_pub,
&dki,
@@ -2128,6 +2130,9 @@ refresh_session_cb (void *cls,
struct TALER_Amount amount_without_fee;
struct TALER_Amount tmp;
+ GNUNET_assert (rowid >= pp.last_melt_serial_id); /* should be monotonically increasing */
+ pp.last_melt_serial_id = rowid + 1;
+
if (GNUNET_OK !=
get_denomination_info (denom_pub,
&dki,
@@ -2376,6 +2381,9 @@ deposit_cb (void *cls,
struct TALER_DepositRequestPS dr;
struct TALER_Amount tmp;
+ GNUNET_assert (rowid >= pp.last_deposit_serial_id); /* should be monotonically increasing */
+ pp.last_deposit_serial_id = rowid + 1;
+
if (GNUNET_OK !=
get_denomination_info (denom_pub,
&dki,
@@ -2496,6 +2504,9 @@ refund_cb (void *cls,
struct TALER_Amount amount_without_fee;
struct TALER_Amount refund_fee;
+ GNUNET_assert (rowid >= pp.last_refund_serial_id); /* should be monotonically increasing */
+ pp.last_refund_serial_id = rowid + 1;
+
if (GNUNET_OK !=
get_denomination_info (denom_pub,
&dki,
@@ -2589,7 +2600,6 @@ analyze_coins (void *cls)
struct CoinContext cc;
int dret;
- pp.last_reserve_out_serial_id = 0; // HACK! FIXME!
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Analyzing coins\n");
/* setup 'cc' */
@@ -2632,7 +2642,7 @@ analyze_coins (void *cls)
if (GNUNET_SYSERR ==
edb->select_reserves_out_above_serial_id (edb->cls,
esession,
- pp.last_reserve_out_serial_id,
+ pp.last_withdraw_serial_id,
&withdraw_cb,
&cc))
{
@@ -2761,9 +2771,10 @@ incremental_processing (Analysis analysis,
else
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
- _("Resuming audit at %llu/%llu/%llu/%llu/%llu/%llu\n"),
+ _("Resuming audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n"),
(unsigned long long) pp.last_reserve_in_serial_id,
(unsigned long long) pp.last_reserve_out_serial_id,
+ (unsigned long long) pp.last_withdraw_serial_id,
(unsigned long long) pp.last_deposit_serial_id,
(unsigned long long) pp.last_melt_serial_id,
(unsigned long long) pp.last_refund_serial_id,
@@ -2792,9 +2803,10 @@ incremental_processing (Analysis analysis,
return GNUNET_SYSERR;
}
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
- _("Concluded audit step at %llu/%llu/%llu/%llu/%llu/%llu\n\n"),
+ _("Concluded audit step at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n\n"),
(unsigned long long) pp.last_reserve_in_serial_id,
(unsigned long long) pp.last_reserve_out_serial_id,
+ (unsigned long long) pp.last_withdraw_serial_id,
(unsigned long long) pp.last_deposit_serial_id,
(unsigned long long) pp.last_melt_serial_id,
(unsigned long long) pp.last_refund_serial_id,
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index 74dff9285..2a63eebda 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -299,6 +299,7 @@ postgres_create_tables (void *cls)
"(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)"
",last_reserve_in_serial_id INT8 NOT NULL"
",last_reserve_out_serial_id INT8 NOT NULL"
+ ",last_withdraw_serial_id INT8 NOT NULL"
",last_deposit_serial_id INT8 NOT NULL"
",last_melt_serial_id INT8 NOT NULL"
",last_refund_serial_id INT8 NOT NULL"
@@ -562,30 +563,33 @@ postgres_prepare (PGconn *db_conn)
"(master_pub"
",last_reserve_in_serial_id"
",last_reserve_out_serial_id"
+ ",last_withdraw_serial_id"
",last_deposit_serial_id"
",last_melt_serial_id"
",last_refund_serial_id"
",last_wire_out_serial_id"
- ") VALUES ($1,$2,$3,$4,$5,$6,$7);",
- 7, NULL);
+ ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);",
+ 8, NULL);
/* Used in #postgres_update_auditor_progress() */
PREPARE ("auditor_progress_update",
"UPDATE auditor_progress SET "
" last_reserve_in_serial_id=$1"
",last_reserve_out_serial_id=$2"
- ",last_deposit_serial_id=$3"
- ",last_melt_serial_id=$4"
- ",last_refund_serial_id=$5"
- ",last_wire_out_serial_id=$6"
- " WHERE master_pub=$7",
- 7, NULL);
+ ",last_withdraw_serial_id=$3"
+ ",last_deposit_serial_id=$4"
+ ",last_melt_serial_id=$5"
+ ",last_refund_serial_id=$6"
+ ",last_wire_out_serial_id=$7"
+ " WHERE master_pub=$8",
+ 8, NULL);
/* Used in #postgres_get_auditor_progress() */
PREPARE ("auditor_progress_select",
"SELECT"
" last_reserve_in_serial_id"
",last_reserve_out_serial_id"
+ ",last_withdraw_serial_id"
",last_deposit_serial_id"
",last_melt_serial_id"
",last_refund_serial_id"
@@ -1264,6 +1268,7 @@ postgres_insert_auditor_progress (void *cls,
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_out_serial_id),
+ GNUNET_PQ_query_param_uint64 (&pp->last_withdraw_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_deposit_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_melt_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_refund_serial_id),
@@ -1309,6 +1314,7 @@ postgres_update_auditor_progress (void *cls,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_out_serial_id),
+ GNUNET_PQ_query_param_uint64 (&pp->last_withdraw_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_deposit_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_melt_serial_id),
GNUNET_PQ_query_param_uint64 (&pp->last_refund_serial_id),
@@ -1359,6 +1365,7 @@ postgres_get_auditor_progress (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("last_reserve_in_serial_id", &pp->last_reserve_in_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_reserve_out_serial_id", &pp->last_reserve_out_serial_id),
+ GNUNET_PQ_result_spec_uint64 ("last_withdraw_serial_id", &pp->last_withdraw_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_deposit_serial_id", &pp->last_deposit_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_melt_serial_id", &pp->last_melt_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_refund_serial_id", &pp->last_refund_serial_id),
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
index 1c6360feb..68d0cb51e 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -117,11 +117,16 @@ struct TALER_AUDITORDB_ProgressPoint
uint64_t last_reserve_in_serial_id;
/**
- * last_reserve_out_serial_id serial ID of the last withdraw the auditor processed
+ * last_reserve_out_serial_id serial ID of the last reserve_out the auditor processed
*/
uint64_t last_reserve_out_serial_id;
/**
+ * last_reserve_out_serial_id serial ID of the last withdraw the auditor processed
+ */
+ uint64_t last_withdraw_serial_id;
+
+ /**
* last_deposit_serial_id serial ID of the last deposit the auditor processed
*/
uint64_t last_deposit_serial_id;