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: more work on wirewa


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: more work on wirewatch
Date: Fri, 05 May 2017 12:17:55 +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 2c05a4b  more work on wirewatch
2c05a4b is described below

commit 2c05a4b278096a9f222a472c0f022c66ad367059
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri May 5 12:17:48 2017 +0200

    more work on wirewatch
---
 src/exchange/.gitignore                 |  3 ++-
 src/exchange/taler-exchange-wirewatch.c | 47 ++++++++++++++++++++++++++++-----
 src/include/taler_wire_plugin.h         |  3 ++-
 src/wire/plugin_wire_test.c             | 29 +++++++++++---------
 4 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/src/exchange/.gitignore b/src/exchange/.gitignore
index f9dcae1..6ea90e7 100644
--- a/src/exchange/.gitignore
+++ b/src/exchange/.gitignore
@@ -3,4 +3,5 @@ taler-exchange-keycheck
 taler-exchange-keyup
 taler-exchange-pursemod
 taler-exchange-reservemod
-taler-exchange-httpdtaler-exchange-wirewatch
+taler-exchange-httpd
+taler-exchange-wirewatch
diff --git a/src/exchange/taler-exchange-wirewatch.c 
b/src/exchange/taler-exchange-wirewatch.c
index 9c582dd..d343bb5 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -203,8 +203,9 @@ find_transfers (void *cls);
  * @param row_off identification of the position at which we are querying
  * @param row_off_size number of bytes in @a row_off
  * @param details details about the wire transfer
+ * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
  */
-static void
+static int
 history_cb (void *cls,
            enum TALER_BANK_Direction dir,
            const void *row_off,
@@ -212,13 +213,15 @@ history_cb (void *cls,
            const struct TALER_BANK_TransferDetails *details)
 {
   struct TALER_EXCHANGEDB_Session *session = cls;
+  int ret;
+  struct TALER_ReservePublicKeyP reserve_pub;
 
-  // TODO: store to DB...
   if (TALER_BANK_DIRECTION_NONE == dir)
   {
-    int ret;
-
     hh = NULL;
+
+    /* FIXME: commit last_off to DB! */
+
     ret = db_plugin->commit (db_plugin->cls,
                             session);
     if (GNUNET_OK == ret)
@@ -234,7 +237,37 @@ history_cb (void *cls,
     else
       task = GNUNET_SCHEDULER_add_now (&find_transfers,
                                       NULL);
-    return;
+    return GNUNET_OK; /* will be ignored anyway */
+  }
+  /* TODO: We should expect a checksum! */
+  if (GNUNET_OK !=
+      GNUNET_STRINGS_string_to_data (details->wire_transfer_subject,
+                                    strlen (details->wire_transfer_subject),
+                                    &reserve_pub,
+                                    sizeof (reserve_pub)))
+  {
+    /* FIXME: need way to wire money back immediately... */
+    GNUNET_break (0); // not implemented
+    
+    return GNUNET_OK;
+  }
+  // FIXME: store row_off+row_off_size instead of json_t?
+  ret = db_plugin->reserves_in_insert (db_plugin->cls,
+                                      session,
+                                      &reserve_pub,
+                                      &details->amount,
+                                      details->execution_date,
+                                      details->account_details,
+                                      NULL /* FIXME */);
+  if (GNUNET_OK != ret)
+  {
+    GNUNET_break (0);
+    db_plugin->rollback (db_plugin->cls,
+                         session);
+    /* try again */
+    task = GNUNET_SCHEDULER_add_now (&find_transfers,
+                                    NULL);
+    return GNUNET_SYSERR;
   }
   
   if (last_row_off_size != row_off_size)
@@ -245,6 +278,7 @@ history_cb (void *cls,
   memcpy (last_row_off,
          row_off,
          row_off_size);
+  return GNUNET_OK;
 }
 
 
@@ -279,6 +313,8 @@ find_transfers (void *cls)
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
+  /* FIXME: fetch start_off from DB! */
+
   delay = GNUNET_YES;
   hh = wire_plugin->get_history (wire_plugin->cls,
                                 TALER_BANK_DIRECTION_CREDIT,
@@ -297,7 +333,6 @@ find_transfers (void *cls)
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  /* FIXME: write last_off! */
 }
 
 
diff --git a/src/include/taler_wire_plugin.h b/src/include/taler_wire_plugin.h
index 032052e..715f94d 100644
--- a/src/include/taler_wire_plugin.h
+++ b/src/include/taler_wire_plugin.h
@@ -50,8 +50,9 @@ typedef void
  * @param row_off identification of the position at which we are querying
  * @param row_off_size number of bytes in @a row_off
  * @param details details about the wire transfer
+ * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
  */
-typedef void
+typedef int
 (*TALER_WIRE_HistoryResultCallback) (void *cls,
                                      enum TALER_BANK_Direction dir,
                                      const void *row_off,
diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c
index 604a364..0c14190 100644
--- a/src/wire/plugin_wire_test.c
+++ b/src/wire/plugin_wire_test.c
@@ -816,23 +816,26 @@ bhist_cb (void *cls,
   struct TALER_WIRE_HistoryHandle *whh = cls;
   uint64_t bserial_id = GNUNET_htonll (serial_id);
 
-  if (MHD_HTTP_OK == http_status)      
-    whh->hres_cb (whh->hres_cb_cls,
-                 dir,
-                 &bserial_id,
-                 sizeof (bserial_id),
-                 details);
+  if (MHD_HTTP_OK == http_status)
+  {
+    if ( (NULL != whh->hres_cb) &&
+        (GNUNET_OK !=
+         whh->hres_cb (whh->hres_cb_cls,
+                       dir,
+                       &bserial_id,
+                       sizeof (bserial_id),
+                       details)) )
+      whh->hres_cb = NULL;    
+  }
   else
-    whh->hres_cb (whh->hres_cb_cls,
-                 TALER_BANK_DIRECTION_NONE,
-                 NULL,
-                 0,
-                 NULL);
-  if (MHD_HTTP_OK != http_status)
   {
+    (void) whh->hres_cb (whh->hres_cb_cls,
+                        TALER_BANK_DIRECTION_NONE,
+                        NULL,
+                        0,
+                        NULL);
     whh->hh = NULL;
     GNUNET_free (whh);
-    return;
   }
 }
 

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



reply via email to

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