gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: add logic to persist progress


From: gnunet
Subject: [taler-merchant] branch master updated: add logic to persist progress
Date: Wed, 12 Apr 2023 15:50:45 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new ab267651 add logic to persist progress
ab267651 is described below

commit ab267651d6dd065b16f2d38fb6651e9db368a9e9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Apr 12 15:50:42 2023 +0200

    add logic to persist progress
---
 src/backend/taler-merchant-wirewatch.c | 53 ++++++++++++++++++++++++++++++----
 1 file changed, 48 insertions(+), 5 deletions(-)

diff --git a/src/backend/taler-merchant-wirewatch.c 
b/src/backend/taler-merchant-wirewatch.c
index d78d9dbd..77cec3d3 100644
--- a/src/backend/taler-merchant-wirewatch.c
+++ b/src/backend/taler-merchant-wirewatch.c
@@ -105,6 +105,37 @@ static char *instance_id;
  */
 static uint64_t start_row;
 
+/**
+ * Set to true if we need to update instead of insert on the 
merchant_wirewatch table.
+ */
+static bool progress_update;
+
+
+/**
+ * Save progress in DB.
+ */
+static void
+save (void)
+{
+  enum GNUNET_DB_QueryStatus qs;
+
+  if (progress_update)
+    qs = db_plugin->update_wirewatch_progress (db_plugin->cls,
+                                               section,
+                                               start_row);
+  else
+    qs = db_plugin->insert_wirewatch_progress (db_plugin->cls,
+                                               section,
+                                               start_row);
+  if (qs <= 0)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Failed to persist wirewatch progress (%d)\n",
+                qs);
+  }
+}
+
+
 /**
  * We're being aborted with CTRL-C (or SIGTERM). Shut down.
  *
@@ -126,7 +157,7 @@ shutdown_task (void *cls)
     TALER_MERCHANT_BANK_credit_history_cancel (hh);
     hh = NULL;
   }
-  db_plugin->rollback (db_plugin->cls); /* just in case */
+  save ();
   TALER_MERCHANTDB_plugin_unload (db_plugin);
   db_plugin = NULL;
   cfg = NULL;
@@ -220,8 +251,6 @@ credit_cb (
         start_row = serial_id;
         return GNUNET_OK;
       }
-      // FIXME: should also store serial_id,
-      // at least "sometimes"...
       qs = db_plugin->insert_transfer (db_plugin->cls,
                                        instance_id,
                                        exchange_url,
@@ -240,6 +269,7 @@ credit_cb (
     start_row = serial_id;
     return GNUNET_OK;
   case MHD_HTTP_NO_CONTENT:
+    save ();
     delay = GNUNET_TIME_UNIT_ZERO;
     break;
   default:
@@ -346,8 +376,21 @@ run (void *cls,
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  // FIXME: extract 'start_row' from database somehow!
-  // (Note: depends on bank account! => need new table!)
+  {
+    enum GNUNET_DB_QueryStatus qs;
+
+    qs = db_plugin->select_wirewatch_progress (db_plugin->cls,
+                                               section,
+                                               &start_row);
+    if (qs < 0)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Failed to obtain wirewatch progress from database\n");
+      GNUNET_SCHEDULER_shutdown ();
+      return;
+    }
+    progress_update = (0 != qs);
+  }
   GNUNET_assert (NULL == task);
   task = GNUNET_SCHEDULER_add_now (&do_work,
                                    NULL);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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