summaryrefslogtreecommitdiff
path: root/src/auditordb/pg_get_coin_inconsistency.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditordb/pg_get_coin_inconsistency.c')
-rw-r--r--src/auditordb/pg_get_coin_inconsistency.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/auditordb/pg_get_coin_inconsistency.c b/src/auditordb/pg_get_coin_inconsistency.c
index 949136ca3..0e6c45a18 100644
--- a/src/auditordb/pg_get_coin_inconsistency.c
+++ b/src/auditordb/pg_get_coin_inconsistency.c
@@ -106,19 +106,21 @@ coin_inconsistency_cb (void *cls,
enum GNUNET_DB_QueryStatus
TAH_PG_get_coin_inconsistency (
void *cls,
- uint64_t start_id,
- bool return_suppressed, // maybe not needed
+ int64_t limit,
+ uint64_t offset,
+ bool return_suppressed, // maybe not needed
TALER_AUDITORDB_CoinInconsistencyCallback cb,
void *cb_cls)
{
printf ("checkpoint pg_0\n");
struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&start_id),
- // GNUNET_PQ_query_param_bool (return_suppressed),
- GNUNET_PQ_query_param_end
- };
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_uint64 (&offset),
+ GNUNET_PQ_query_param_bool (return_suppressed),
+ GNUNET_PQ_query_param_int64 (&limit),
+ GNUNET_PQ_query_param_end
+ };
struct CoinInconsistencyContext dcc = {
.cb = cb,
.cb_cls = cb_cls,
@@ -129,7 +131,7 @@ TAH_PG_get_coin_inconsistency (
printf ("checkpoint pg_1\n");
PREPARE (pg,
- "auditor_coin_inconsistency_select",
+ "auditor_coin_inconsistency_select_desc",
"SELECT"
" row_id"
",operation"
@@ -138,10 +140,28 @@ TAH_PG_get_coin_inconsistency (
",coin_pub"
",profitable"
" FROM auditor_coin_inconsistency"
- " WHERE row_id>$1"
+ " WHERE (row_id < $1)"
+ " AND ($2 OR suppressed is false)"
+ " ORDER BY row_id DESC"
+ " LIMIT $3"
);
+ PREPARE (pg,
+ "auditor_coin_inconsistency_select_asc",
+ "SELECT"
+ " row_id"
+ ",operation"
+ ",exchange_amount"
+ ",auditor_amount"
+ ",coin_pub"
+ ",profitable"
+ " FROM auditor_coin_inconsistency"
+ " WHERE (row_id > $1)"
+ " AND ($2 OR suppressed is false)"
+ " ORDER BY row_id ASC"
+ " LIMIT $3"
+ );
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- "auditor_coin_inconsistency_select",
+ (limit > 0) ? "auditor_coin_inconsistency_select_asc" : "auditor_coin_inconsistency_select_desc",
params,
&coin_inconsistency_cb,
&dcc);