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: address #5010 for w


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: address #5010 for wirewatch
Date: Fri, 23 Jun 2017 14:40:08 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 6acb027  address #5010 for wirewatch
6acb027 is described below

commit 6acb0271d6413b250cf78b42aed52a9cb0d0869c
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Jun 23 14:37:53 2017 +0200

    address #5010 for wirewatch
---
 src/exchange/taler-exchange-wirewatch.c     | 54 +++++++++++++++++++----------
 src/exchangedb/plugin_exchangedb_postgres.c | 52 +++++++--------------------
 src/exchangedb/test_exchangedb.c            |  8 ++---
 src/include/taler_exchangedb_plugin.h       |  8 ++---
 4 files changed, 54 insertions(+), 68 deletions(-)

diff --git a/src/exchange/taler-exchange-wirewatch.c 
b/src/exchange/taler-exchange-wirewatch.c
index f019f9b..312f8ac 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -223,7 +223,7 @@ history_cb (void *cls,
            const struct TALER_WIRE_TransferDetails *details)
 {
   struct TALER_EXCHANGEDB_Session *session = cls;
-  int ret;
+  enum GNUNET_DB_QueryStatus qs;
 
   if (TALER_BANK_DIRECTION_NONE == dir)
   {
@@ -231,9 +231,9 @@ history_cb (void *cls,
 
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "End of list. Committing progress!\n");
-    ret = db_plugin->commit (db_plugin->cls,
-                            session);
-    if (GNUNET_OK == ret)
+    qs = db_plugin->commit (db_plugin->cls,
+                           session);
+    if (0 <= qs)
     {
       GNUNET_free_non_null (start_off);
       start_off = last_row_off;
@@ -258,18 +258,25 @@ history_cb (void *cls,
               "Adding wire transfer over %s with subject `%s'\n",
               TALER_amount2s (&details->amount),
               TALER_B2S (&details->reserve_pub));
-  ret = db_plugin->reserves_in_insert (db_plugin->cls,
-                                      session,
-                                      &details->reserve_pub,
-                                      &details->amount,
-                                      details->execution_date,
-                                      details->account_details,
-                                       row_off,
-                                       row_off_size);
-  if (GNUNET_OK != ret)
+  qs = db_plugin->reserves_in_insert (db_plugin->cls,
+                                     session,
+                                     &details->reserve_pub,
+                                     &details->amount,
+                                     details->execution_date,
+                                     details->account_details,
+                                     row_off,
+                                     row_off_size);
+  if (GNUNET_DB_STATUS_HARD_ERROR == qs)
   {
     GNUNET_break (0);
     db_plugin->rollback (db_plugin->cls,
+                        session);
+    GNUNET_SCHEDULER_shutdown ();
+    return GNUNET_SYSERR;
+  }
+  if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+  {
+    db_plugin->rollback (db_plugin->cls,
                          session);
     /* try again */
     task = GNUNET_SCHEDULER_add_now (&find_transfers,
@@ -298,7 +305,7 @@ static void
 find_transfers (void *cls)
 {
   struct TALER_EXCHANGEDB_Session *session;
-  int ret;
+  enum GNUNET_DB_QueryStatus qs;
 
   task = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -322,11 +329,11 @@ find_transfers (void *cls)
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  ret = db_plugin->get_latest_reserve_in_reference (db_plugin->cls,
-                                                    session,
-                                                    &start_off,
-                                                    &start_off_size);
-  if (GNUNET_SYSERR == ret)
+  qs = db_plugin->get_latest_reserve_in_reference (db_plugin->cls,
+                                                  session,
+                                                  &start_off,
+                                                  &start_off_size);
+  if (GNUNET_DB_STATUS_HARD_ERROR == qs)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Failed to obtain starting point for montoring from 
database!\n");
@@ -334,6 +341,15 @@ find_transfers (void *cls)
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
+  if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+  {
+    /* try again */
+    db_plugin->rollback (db_plugin->cls,
+                         session);
+    task = GNUNET_SCHEDULER_add_now (&find_transfers,
+                                    NULL);
+    return;
+  }
   delay = GNUNET_YES;
   hh = wire_plugin->get_history (wire_plugin->cls,
                                 TALER_BANK_DIRECTION_CREDIT,
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 6758a30..a41b196 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -2092,56 +2092,28 @@ postgres_reserves_in_insert (void *cls,
  * @param session the database session handle
  * @param[out] wire_reference set to unique reference identifying the wire 
transfer (binary blob)
  * @param[out] wire_reference_size set to number of bytes in @a wire_reference
- * @return #GNUNET_OK upon success; #GNUNET_NO if we never got any incoming 
transfers
- *         #GNUNET_SYSERR upon failures (DB error)
+ * @return transaction status code
  */
-static int
+static enum GNUNET_DB_QueryStatus
 postgres_get_latest_reserve_in_reference (void *cls,
                                           struct TALER_EXCHANGEDB_Session 
*session,
                                           void **wire_reference,
                                           size_t *wire_reference_size)
 {
-  PGresult *result;
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_end
   };
-  int ret;
-
-  ret = GNUNET_SYSERR;
-  result = GNUNET_PQ_exec_prepared (session->conn,
-                                    "reserves_in_get_latest_wire_reference",
-                                    params);
-  if (PGRES_TUPLES_OK != PQresultStatus (result))
-  {
-    QUERY_ERR (result, session->conn);
-    goto cleanup;
-  }
-  if (0 == PQntuples (result))
-  {
-    ret = GNUNET_NO;
-    goto cleanup;
-  }
-  {
-    struct GNUNET_PQ_ResultSpec rs[] = {
-      GNUNET_PQ_result_spec_variable_size ("wire_reference",
-                                           wire_reference,
-                                           wire_reference_size),
-      GNUNET_PQ_result_spec_end
-    };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_variable_size ("wire_reference",
+                                        wire_reference,
+                                        wire_reference_size),
+    GNUNET_PQ_result_spec_end
+  };
 
-    if (GNUNET_OK !=
-        GNUNET_PQ_extract_result (result,
-                                  rs,
-                                  0))
-    {
-      GNUNET_break (0);
-      goto cleanup;
-    }
-  }
-  ret = GNUNET_OK;
- cleanup:
-  PQclear (result);
-  return ret;
+  return GNUNET_PQ_eval_prepared_singleton_select (session->conn,
+                                                  
"reserves_in_get_latest_wire_reference",
+                                                  params,
+                                                  rs);
 }
 
 
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 701c20c..ae0c821 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1518,7 +1518,7 @@ run (void *cls)
   result = 4;
   sndr = json_loads ("{ \"account\":\"1\" }", 0, NULL);
   GNUNET_assert (NULL != sndr);
-  FAILIF (GNUNET_NO !=
+  FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
           plugin->get_latest_reserve_in_reference (plugin->cls,
                                                    session,
                                                    &rr,
@@ -1532,7 +1532,7 @@ run (void *cls)
                                       sndr,
                                       "TEST",
                                       4));
-  FAILIF (GNUNET_OK !=
+  FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_latest_reserve_in_reference (plugin->cls,
                                                    session,
                                                    &rr,
@@ -1555,12 +1555,12 @@ run (void *cls)
                                      sndr,
                                       "TEST2",
                                       5));
-  FAILIF (GNUNET_OK !=
+  FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_latest_reserve_in_reference (plugin->cls,
                                                    session,
                                                    &rr,
                                                    &rr_size));
-  FAILIF (GNUNET_OK !=
+  FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_latest_reserve_in_reference (plugin->cls,
                                                    session,
                                                    &rr,
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 7c245e2..9a97b5f 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1107,8 +1107,7 @@ struct TALER_EXCHANGEDB_Plugin
    *
    * @param cls the @e cls of this struct with the plugin-specific state
    * @param session connection to use
-   * @return #GNUNET_OK on success, #GNUNET_NO if the transaction
-   *         can be retried, #GNUNET_SYSERR on hard failures
+   * @return transaction status
    */
   enum GNUNET_DB_QueryStatus
   (*commit) (void *cls,
@@ -1210,10 +1209,9 @@ struct TALER_EXCHANGEDB_Plugin
    * @param db the database connection handle
    * @param[out] wire_reference set to unique reference identifying the wire 
transfer (binary blob)
    * @param[out] wire_reference_size set to number of bytes in @a 
wire_reference
-   * @return #GNUNET_OK upon success; #GNUNET_NO if we never got any incoming 
transfers
-   *         #GNUNET_SYSERR upon failures (DB error)
+   * @return transaction status code
    */
-  int
+  enum GNUNET_DB_QueryStatus 
   (*get_latest_reserve_in_reference)(void *cls,
                                      struct TALER_EXCHANGEDB_Session *db,
                                      void **wire_reference,

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



reply via email to

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