gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] branch master updated (88cdaf7 -> 272f113)


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated (88cdaf7 -> 272f113)
Date: Mon, 16 Oct 2017 17:57:39 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository exchange.

    from 88cdaf7  adding missing table in the drop method
     new 2cddf52  work on #4963 for taler-auditor
     new 4a84520  resolve #4963
     new 272f113  add exchangedb function for #4961

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog                                   |   3 +
 src/auditor/Makefile.am                     |   1 +
 src/auditor/taler-auditor.c                 | 240 ++++++++++++++++++++--------
 src/auditor/taler-wire-auditor.c            |  68 ++++++--
 src/exchangedb/plugin_exchangedb_postgres.c | 153 ++++++++++++++++++
 src/include/taler_exchangedb_plugin.h       |  46 ++++++
 6 files changed, 431 insertions(+), 80 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 33b105c..441cc80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Mon Oct 16 12:10:35 CEST 2017
+       Realize JSON-based report formats from auditor (#4963). -CG
+
 Sun Sep 17 16:46:13 CEST 2017
        Implement /keys cherry picking (#4840). -CG
 
diff --git a/src/auditor/Makefile.am b/src/auditor/Makefile.am
index 5beab8b..439db7f 100644
--- a/src/auditor/Makefile.am
+++ b/src/auditor/Makefile.am
@@ -26,6 +26,7 @@ taler_auditor_LDADD = \
   $(top_builddir)/src/exchangedb/libtalerexchangedb.la \
   $(top_builddir)/src/auditordb/libtalerauditordb.la \
   -ljansson \
+  -lgnunetjson \
   -lgnunetutil
 
 taler_wire_auditor_SOURCES = \
diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c
index 367b13a..3e4eca1 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:
- * - calculate, store and report aggregation fee balance!
  * - error handling if denomination keys are used that are not known to the
  *   auditor is, eh, awful / non-existent. We just throw the DB's constraint
  *   violation back at the user. Great UX.
@@ -114,11 +113,74 @@ static struct TALER_MasterPublicKeyP master_pub;
  */
 static struct TALER_AUDITORDB_ProgressPoint pp;
 
+/**
+ * Array of reports about denomination keys with an
+ * emergency (more deposited than withdrawn)
+ */
+static json_t *report_emergencies;
+
+/**
+ * Array of reports about row inconsitencies.
+ */
+static json_t *report_row_inconsistencies;
+
+/**
+ * Array of reports about minor row inconcistencies.
+ */
+static json_t *report_row_minor_inconsistencies;
+
+/**
+ * Array of reports about reserve inconsitencies.
+ */
+static json_t *report_reserve_inconsistencies;
+
+/**
+ * Array of reports about irregular wire out entries.
+ */
+static json_t *report_wire_out_inconsistencies;
+
+/**
+ * Array of reports about inconsistencies about coins.
+ */
+static json_t *report_coin_inconsistencies;
+
+/**
+ * Report about expected reserve balances.
+ */
+static json_t *report_reserve_balances;
+
+/**
+ * Report about aggregate wire transfer fee profits.
+ */
+static json_t *report_aggregation_fee_balances;
+
+/**
+ * Report about denomination fee balances.
+ */
+static json_t *report_denomination_balances;
+
 
 /* ***************************** Report logic **************************** */
 
 
 /**
+ * Add @a object to the report @a array.  Fail hard if this fails.
+ *
+ * @param array report array to append @a object to
+ * @param object object to append, should be check that it is not NULL
+ */ 
+static void
+report (json_t *array,
+       json_t *object)
+{
+  GNUNET_assert (NULL != object);
+  GNUNET_assert (0 ==
+                json_array_append_new (array,
+                                       object));
+}
+
+
+/**
  * Called in case we detect an emergency situation where the exchange
  * is paying out a larger amount on a denomination than we issued in
  * that denomination.  This means that the exchange's private keys
@@ -131,14 +193,10 @@ static struct TALER_AUDITORDB_ProgressPoint pp;
 static void
 report_emergency (const struct TALER_EXCHANGEDB_DenominationKeyInformationP 
*dki)
 {
-  char *dhks;
-
-  dhks = GNUNET_STRINGS_data_to_string_alloc (&dki->properties.denom_hash,
-                                              sizeof (struct GNUNET_HashCode));
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Emergency detected. Exchange must revoke key using 
`taler-auditor -r %s`\n",
-              dhks);
-  GNUNET_free (dhks);
+  report (report_emergencies,
+         json_pack ("{s:o}",
+                    "denompub_hash",
+                    GNUNET_JSON_from_data_auto (&dki->properties.denom_hash)));
 }
 
 
@@ -154,12 +212,11 @@ report_row_inconsistency (const char *table,
                           uint64_t rowid,
                           const char *diagnostic)
 {
-  // TODO (#4963): implement proper reporting logic writing to file.
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Database inconsistency detected in table %s at row %llu: %s\n",
-              table,
-              (unsigned long long) rowid,
-              diagnostic);
+  report (report_row_inconsistencies,
+         json_pack ("{s:s, s:I, s:s}",
+                    "table", table,
+                    "row", (json_int_t) rowid,
+                    "diagnostic", diagnostic));
 }
 
 
@@ -176,12 +233,11 @@ report_row_minor_inconsistency (const char *table,
                                 uint64_t rowid,
                                 const char *diagnostic)
 {
-  // TODO (#4963): implement proper reporting logic writing to file.
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Minor inconsistency detected in table %s at row %llu: %s\n",
-              table,
-              (unsigned long long) rowid,
-              diagnostic);
+  report (report_row_minor_inconsistencies,
+         json_pack ("{s:s, s:I, s:s}",
+                    "table", table,
+                    "row", (json_int_t) rowid,
+                    "diagnostic", diagnostic));
 }
 
 
@@ -199,11 +255,16 @@ report_reserve_inconsistency (const struct 
TALER_ReservePublicKeyP *reserve_pub,
                               const struct TALER_Amount *observed,
                               const char *diagnostic)
 {
-  // TODO (#4963): implement proper reporting logic writing to file, include 
amounts.
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Reserve inconsistency detected affecting reserve %s: %s\n",
-              TALER_B2S (reserve_pub),
-              diagnostic);
+  report (report_reserve_inconsistencies,
+         json_pack ("{s:o, s:o, s:o, s:s}",
+                    "reserve_pub",
+                    GNUNET_JSON_from_data_auto (reserve_pub),
+                    "expected",
+                    TALER_JSON_from_amount (expected),
+                    "observed",
+                    TALER_JSON_from_amount (observed),
+                    "diagnostic",
+                    diagnostic));
 }
 
 
@@ -223,10 +284,18 @@ report_wire_out_inconsistency (const json_t *destination,
                                const struct TALER_Amount *observed,
                                const char *diagnostic)
 {
-  // TODO (#4963): implement proper reporting logic writing to file, include 
amounts.
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Wire out inconsistency detected: %s\n",
-              diagnostic);
+  report (report_wire_out_inconsistencies,
+         json_pack ("{s:O, s:I, s:o, s:o, s:s}",
+                    "destination_account",
+                    destination,
+                    "rowid",
+                    (json_int_t) rowid,
+                    "expected",
+                    TALER_JSON_from_amount (expected),
+                    "observed",
+                    TALER_JSON_from_amount (observed),
+                    "diagnostic",
+                    diagnostic));
 }
 
 
@@ -244,10 +313,16 @@ report_coin_inconsistency (const struct 
TALER_CoinSpendPublicKeyP *coin_pub,
                            const struct TALER_Amount *observed,
                            const char *diagnostic)
 {
-  // TODO (#4963): implement proper reporting logic writing to file, include 
amounts.
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Coin inconsistency detected: %s\n",
-              diagnostic);
+  report (report_coin_inconsistencies,
+         json_pack ("{s:o, s:o, s:o, s:s}",
+                    "coin_pub",
+                    GNUNET_JSON_from_data_auto (coin_pub),
+                    "expected",
+                    TALER_JSON_from_amount (expected),
+                    "observed",
+                    TALER_JSON_from_amount (observed),
+                    "diagnostic",
+                    diagnostic));
 }
 
 
@@ -271,13 +346,12 @@ static void
 report_reserve_balance (const struct TALER_Amount *total_balance,
                         const struct TALER_Amount *total_fee_balance)
 {
-  // TODO (#4963): implement proper reporting logic writing to file.
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Escrow balance to be held for reserves is %s\n",
-              TALER_amount2s (total_balance));
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Withdraw fees income is %s\n",
-              TALER_amount2s (total_fee_balance));
+  report (report_reserve_balances,
+         json_pack ("{s:o, s:o}",
+                    "total_escrow_balance",
+                    TALER_JSON_from_amount (total_balance),
+                    "total_withdraw_fee_income",
+                    TALER_JSON_from_amount (total_fee_balance)));
 }
 
 
@@ -294,10 +368,10 @@ report_reserve_balance (const struct TALER_Amount 
*total_balance,
 static void
 report_aggregation_fee_balance (const struct TALER_Amount *total_fee_balance)
 {
-  // TODO (#4963): implement proper reporting logic writing to file.
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Aggregation fees income is %s\n",
-              TALER_amount2s (total_fee_balance));
+  report (report_aggregation_fee_balances,
+         json_pack ("{s:o}",
+                    "total_aggregation_fee_income",
+                    TALER_JSON_from_amount (total_fee_balance)));
 }
 
 
@@ -317,22 +391,18 @@ report_denomination_balance (const struct TALER_Amount 
*total_balance,
                              const struct TALER_Amount *melt_fees,
                              const struct TALER_Amount *refund_fees)
 {
-  // TODO (#4963/4962): implement proper reporting logic writing to file.
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Escrow balance for issued coins is %s\n",
-              TALER_amount2s (total_balance));
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Risk from active operations is %s\n",
-              TALER_amount2s (total_risk));
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Deposit fee income is %s\n",
-              TALER_amount2s (deposit_fees));
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Melt fee income is %s\n",
-              TALER_amount2s (melt_fees));
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Refund fee income is %s\n",
-              TALER_amount2s (refund_fees));
+  report (report_denomination_balances,
+         json_pack ("{s:o, s:o, s:o, s:o, s:o}",
+                    "total_escrow_balance",
+                    TALER_JSON_from_amount (total_balance),
+                    "total_active_risk",
+                    TALER_JSON_from_amount (total_risk),
+                    "total_deposit_fee_income",
+                    TALER_JSON_from_amount (deposit_fees),
+                    "total_melt_fee_income",
+                    TALER_JSON_from_amount (melt_fees),
+                    "total_refund_fee_income",
+                    TALER_JSON_from_amount (refund_fees)));
 }
 
 
@@ -3723,6 +3793,8 @@ run (void *cls,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
+  json_t *report;
+  
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Launching auditor\n");
   cfg = c;
@@ -3789,11 +3861,43 @@ run (void *cls,
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Starting audit\n");
+  GNUNET_assert (NULL !=
+                (report_emergencies = json_array ()));
+  GNUNET_assert (NULL !=
+                (report_row_inconsistencies = json_array ()));
+  GNUNET_assert (NULL !=
+                (report_row_minor_inconsistencies = json_array ()));
+  GNUNET_assert (NULL !=
+                (report_reserve_inconsistencies = json_array ()));
+  GNUNET_assert (NULL !=
+                (report_wire_out_inconsistencies = json_array ()));
+  GNUNET_assert (NULL !=
+                (report_coin_inconsistencies = json_array ()));
+  GNUNET_assert (NULL !=
+                (report_reserve_balances = json_array ()));
+  GNUNET_assert (NULL !=
+                (report_aggregation_fee_balances = json_array ()));
+  GNUNET_assert (NULL !=
+                (report_denomination_balances = json_array ()));
   setup_sessions_and_run ();
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Audit complete\n");
   TALER_AUDITORDB_plugin_unload (adb);
   TALER_EXCHANGEDB_plugin_unload (edb);
+  report = json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
+                     "emergencies", report_emergencies,
+                     "row-inconsistencies", report_row_inconsistencies,
+                     "row-minor-inconsistencies", 
report_row_minor_inconsistencies,
+                     "reserve-inconsistencies", report_reserve_inconsistencies,
+                     "wire-out-inconsistencies", 
report_wire_out_inconsistencies,
+                     "coin_inconsistencies", report_coin_inconsistencies,
+                     "reserve_balance", report_reserve_balances,
+                     "aggregation_fee_balance", 
report_aggregation_fee_balances,
+                     "report_denomination_balance", 
report_denomination_balances);
+  json_dumpf (report,
+             stdout,
+             JSON_INDENT (2));
+  json_decref (report);
 }
 
 
@@ -3812,14 +3916,14 @@ main (int argc,
   const struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_option_mandatory
     (GNUNET_GETOPT_option_base32_auto ('m',
-                                           "exchange-key",
-                                           "KEY",
-                                           "public key of the exchange 
(Crockford base32 encoded)",
-                                           &master_pub)),
+                                      "exchange-key",
+                                      "KEY",
+                                      "public key of the exchange (Crockford 
base32 encoded)",
+                                      &master_pub)),
     GNUNET_GETOPT_option_flag ('r',
-                                  "restart",
-                                  "restart audit from the beginning (required 
on first run)",
-                                  &restart),
+                              "restart",
+                              "restart audit from the beginning (required on 
first run)",
+                              &restart),
     GNUNET_GETOPT_OPTION_END
   };
 
diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c
index c0b29eb..8cc579f 100644
--- a/src/auditor/taler-wire-auditor.c
+++ b/src/auditor/taler-wire-auditor.c
@@ -129,6 +129,16 @@ static void *out_wire_off;
  */
 static size_t wire_off_size;
 
+/**
+ * Array of reports about row inconsitencies.
+ */
+static json_t *report_row_inconsistencies;
+
+/**
+ * Array of reports about minor row inconcistencies.
+ */
+static json_t *report_row_minor_inconsistencies;
+
 
 /* *****************************   Shutdown   **************************** */
 
@@ -240,6 +250,21 @@ free_roi (void *cls,
 static void
 do_shutdown (void *cls)
 {
+  if (NULL != report_row_inconsistencies)
+  {
+    json_t *report;
+    
+    GNUNET_assert (NULL != report_row_minor_inconsistencies);
+    report = json_pack ("{s:o, s:o}",
+                       "row-inconsistencies", report_row_inconsistencies,
+                       "row-minor-inconsistencies", 
report_row_minor_inconsistencies);
+    json_dumpf (report,
+               stdout,
+               JSON_INDENT (2));
+    json_decref (report);
+    report_row_inconsistencies = NULL;
+    report_row_minor_inconsistencies = NULL;
+  }
   if (NULL != hh)
   {
     wp->get_history_cancel (wp->cls,
@@ -284,6 +309,23 @@ do_shutdown (void *cls)
 
 
 /**
+ * Add @a object to the report @a array.  Fail hard if this fails.
+ *
+ * @param array report array to append @a object to
+ * @param object object to append, should be check that it is not NULL
+ */ 
+static void
+report (json_t *array,
+       json_t *object)
+{
+  GNUNET_assert (NULL != object);
+  GNUNET_assert (0 ==
+                json_array_append_new (array,
+                                       object));
+}
+
+
+/**
  * Report a (serious) inconsistency in the exchange's database.
  *
  * @param table affected table
@@ -295,12 +337,11 @@ report_row_inconsistency (const char *table,
                           uint64_t rowid,
                           const char *diagnostic)
 {
-  // TODO (#4963): implement proper reporting logic writing to file.
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Database inconsistency detected in table %s at row %llu: %s\n",
-              table,
-              (unsigned long long) rowid,
-              diagnostic);
+  report (report_row_inconsistencies,
+         json_pack ("{s:s, s:I, s:s}",
+                    "table", table,
+                    "row", (json_int_t) rowid,
+                    "diagnostic", diagnostic));
 }
 
 
@@ -317,12 +358,11 @@ report_row_minor_inconsistency (const char *table,
                                 uint64_t rowid,
                                 const char *diagnostic)
 {
-  // TODO (#4963): implement proper reporting logic writing to file.
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Minor inconsistency detected in table %s at row %llu: %s\n",
-              table,
-              (unsigned long long) rowid,
-              diagnostic);
+  report (report_row_minor_inconsistencies,
+         json_pack ("{s:s, s:I, s:s}",
+                    "table", table,
+                    "row", (json_int_t) rowid,
+                    "diagnostic", diagnostic));
 }
 
 
@@ -961,6 +1001,10 @@ run (void *cls,
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
+  GNUNET_assert (NULL !=
+                (report_row_inconsistencies = json_array ()));
+  GNUNET_assert (NULL !=
+                (report_row_minor_inconsistencies = json_array ()));
   qsx = adb->get_wire_auditor_progress (adb->cls,
                                         asession,
                                         &master_pub,
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 807c191..d39adf2 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1300,6 +1300,29 @@ postgres_prepare (PGconn *db_conn)
                             " ORDER BY prewire_uuid ASC"
                             " LIMIT 1;",
                             0),
+    /* Used in #postgres_select_deposits_missing_wire */
+    GNUNET_PQ_make_prepare ("deposits_get_overdue",
+                           "SELECT"
+                           " deposit_serial_id"
+                           ",coin_pub"
+                           ",amount_with_fee_val"
+                           ",amount_with_fee_frac"
+                           ",amount_with_fee_curr"
+                           ",wire"
+                           ",wire_deadline"
+                           ",tiny"
+                           ",done"
+                           " FROM deposits"
+                           " WHERE wire_deadline <= $1"
+                           " AND wire_deadline > $2" 
+                           " AND NOT (EXISTS (SELECT 1"
+                           "            FROM refunds"
+                           "            WHERE (refunds.coin_pub = 
deposits.coin_pub))"
+                           "       OR EXISTS (SELECT 1"
+                           "            FROM aggregation_tracking"
+                           "            WHERE 
(aggregation_tracking.deposit_serial_id = deposits.deposit_serial_id)))"
+                           " ORDER BY wire_deadline ASC",
+                           2),
     /* Used in #postgres_gc() */
     GNUNET_PQ_make_prepare ("gc_prewire",
                             "DELETE"
@@ -6217,6 +6240,135 @@ postgres_get_denomination_revocation (void *cls,
 
 
 /**
+ * Closure for #missing_wire_cb().
+ */
+struct MissingWireContext
+{
+  /**
+   * Function to call per result.
+   */
+  TALER_EXCHANGEDB_WireMissingCallback cb;
+
+  /**
+   * Closure for @e cb.
+   */
+  void *cb_cls;
+
+  /**
+   * Set to #GNUNET_SYSERR on error.
+   */
+  int status;
+};
+
+
+/**
+ * Invoke the callback for each result.
+ *
+ * @param cls a `struct MissingWireContext *`
+ * @param result SQL result
+ * @param num_results number of rows in @a result
+ */
+static void
+missing_wire_cb (void *cls,
+                PGresult *result,
+                unsigned int num_results)
+{
+  struct MissingWireContext *mwc = cls;
+
+  while (0 < num_results)
+  {
+    uint64_t rowid;
+    struct TALER_CoinSpendPublicKeyP coin_pub;
+    struct TALER_Amount amount;
+    json_t *wire;
+    struct GNUNET_TIME_Absolute deadline;
+    /* bool? */ uint32_t tiny;
+    /* bool? */ uint32_t done;
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_uint64 ("deposit_serial_id",
+                                   &rowid),
+      GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
+                                           &coin_pub),
+      TALER_PQ_result_spec_amount ("amount_with_fee",
+                                  &amount),
+      TALER_PQ_result_spec_json ("wire",
+                                &wire),
+      GNUNET_PQ_result_spec_absolute_time ("wire_deadline",
+                                          &deadline),
+      GNUNET_PQ_result_spec_uint32 ("tiny",
+                                   &tiny),
+      GNUNET_PQ_result_spec_uint32 ("done",
+                                   &done),
+      GNUNET_PQ_result_spec_end
+    };
+
+    if (GNUNET_OK !=
+       GNUNET_PQ_extract_result (result,
+                                 rs,
+                                 --num_results))
+    {
+      GNUNET_break (0);
+      mwc->status = GNUNET_SYSERR;
+      return;
+    }
+    mwc->cb (mwc->cb_cls,
+            rowid,
+            &coin_pub,
+            &amount,
+            wire,
+            deadline,
+            tiny,
+            done);
+    GNUNET_PQ_cleanup_result (rs);
+  }
+}
+
+
+/**
+ * Select all of those deposits in the database for which we do
+ * not have a wire transfer (or a refund) and which should have
+ * been deposited between @a start_date and @a end_date.
+ *
+ * @param cls closure
+ * @param session a session
+ * @param start_date lower bound on the requested wire execution date
+ * @param end_date upper bound on the requested wire execution date
+ * @param cb function to call on all such deposits
+ * @param cb_cls closure for @a cb
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_select_deposits_missing_wire (void *cls,
+                                      struct TALER_EXCHANGEDB_Session *session,
+                                      struct GNUNET_TIME_Absolute start_date,
+                                      struct GNUNET_TIME_Absolute end_date,
+                                      TALER_EXCHANGEDB_WireMissingCallback cb,
+                                      void *cb_cls)
+{
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_absolute_time (&start_date),
+    GNUNET_PQ_query_param_absolute_time (&end_date),
+    GNUNET_PQ_query_param_end
+  };
+  struct MissingWireContext mwc = {
+    .cb = cb,
+    .cb_cls = cb_cls,
+    .status = GNUNET_OK
+  };
+  enum GNUNET_DB_QueryStatus qs;
+
+  qs = GNUNET_PQ_eval_prepared_multi_select (session->conn,
+                                            "deposits_get_overdue",
+                                            params,
+                                            &missing_wire_cb,
+                                            &mwc);
+  if (GNUNET_OK != mwc.status)
+    return GNUNET_DB_STATUS_HARD_ERROR;
+  return qs;
+}
+
+
+/**
  * Initialize Postgres database subsystem.
  *
  * @param cls a configuration instance
@@ -6337,6 +6489,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
   plugin->get_reserve_by_h_blind = &postgres_get_reserve_by_h_blind;
   plugin->insert_denomination_revocation = 
&postgres_insert_denomination_revocation;
   plugin->get_denomination_revocation = &postgres_get_denomination_revocation;
+  plugin->select_deposits_missing_wire = 
&postgres_select_deposits_missing_wire;
   return plugin;
 }
 
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 2cc2c75..006ea39 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1042,6 +1042,30 @@ typedef void
 
 
 /**
+ * Function called on deposits that are past their due date
+ * and have not yet seen a wire transfer.
+ *
+ * @param cls closure
+ * @param rowid deposit table row of the coin's deposit
+ * @param coin_pub public key of the coin
+ * @param amount value of the deposit, including fee
+ * @param wire where should the funds be wired
+ * @param deadline what was the requested wire transfer deadline
+ * @param tiny did the exchange defer this transfer because it is too small?
+ * @param done did the exchange claim that it made a transfer?
+ */
+typedef void
+(*TALER_EXCHANGEDB_WireMissingCallback)(void *cls,
+                                       uint64_t rowid,
+                                       const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
+                                       const struct TALER_Amount *amount,
+                                       const json_t *wire,
+                                       struct GNUNET_TIME_Absolute deadline,
+                                       /* bool? */ int tiny,
+                                       /* bool? */ int done);
+
+
+/**
  * @brief The plugin API, returned from the plugin's "init" function.
  * The argument given to "init" is simply a configuration handle.
  */
@@ -2189,6 +2213,28 @@ struct TALER_EXCHANGEDB_Plugin
                                 uint64_t *rowid);
 
 
+  /**
+   * Select all of those deposits in the database for which we do
+   * not have a wire transfer (or a refund) and which should have
+   * been deposited between @a start_date and @a end_date.
+   *
+   * @param cls closure
+   * @param session a session
+   * @param start_date lower bound on the requested wire execution date
+   * @param end_date upper bound on the requested wire execution date
+   * @param cb function to call on all such deposits
+   * @param cb_cls closure for @a cb
+   * @return transaction status code
+   */
+  enum GNUNET_DB_QueryStatus
+  (*select_deposits_missing_wire)(void *cls,
+                                 struct TALER_EXCHANGEDB_Session *session,
+                                 struct GNUNET_TIME_Absolute start_date,
+                                 struct GNUNET_TIME_Absolute end_date,
+                                 TALER_EXCHANGEDB_WireMissingCallback cb,
+                                 void *cb_cls);
+  
+
 };
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]