gnunet-svn
[Top][All Lists]
Advanced

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

[taler-sync] branch master updated: adapt to new timestamp format


From: gnunet
Subject: [taler-sync] branch master updated: adapt to new timestamp format
Date: Tue, 14 Dec 2021 16:42:28 +0100

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

grothoff pushed a commit to branch master
in repository sync.

The following commit(s) were added to refs/heads/master by this push:
     new ef1b5a7  adapt to new timestamp format
ef1b5a7 is described below

commit ef1b5a7e9ee352ad4acf5a7e97099740ec16a9a6
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Dec 14 16:42:26 2021 +0100

    adapt to new timestamp format
---
 src/include/sync_database_plugin.h  |  2 +-
 src/sync/sync-httpd_backup_post.c   |  8 +++++---
 src/sync/sync-httpd_config.c        |  2 +-
 src/syncdb/plugin_syncdb_postgres.c | 37 +++++++++++++++++++------------------
 src/syncdb/sync-dbinit.c            |  1 -
 src/syncdb/test_sync_db.c           |  3 +--
 6 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/src/include/sync_database_plugin.h 
b/src/include/sync_database_plugin.h
index a779fab..ca54088 100644
--- a/src/include/sync_database_plugin.h
+++ b/src/include/sync_database_plugin.h
@@ -81,7 +81,7 @@ enum SYNC_DB_QueryStatus
  */
 typedef void
 (*SYNC_DB_PaymentPendingIterator)(void *cls,
-                                  struct GNUNET_TIME_Absolute timestamp,
+                                  struct GNUNET_TIME_Timestamp timestamp,
                                   const char *order_id,
                                   const struct TALER_ClaimTokenP *token,
                                   const struct TALER_Amount *amount);
diff --git a/src/sync/sync-httpd_backup_post.c 
b/src/sync/sync-httpd_backup_post.c
index 962142d..a895305 100644
--- a/src/sync/sync-httpd_backup_post.c
+++ b/src/sync/sync-httpd_backup_post.c
@@ -127,7 +127,7 @@ struct BackupContext
    * Timestamp of the order in @e existing_order_id. Used to
    * select the most recent unpaid offer.
    */
-  struct GNUNET_TIME_Absolute existing_order_timestamp;
+  struct GNUNET_TIME_Timestamp existing_order_timestamp;
 
   /**
    * Expected total upload size.
@@ -371,7 +371,7 @@ proposal_cb (void *cls,
  */
 static void
 ongoing_payment_cb (void *cls,
-                    struct GNUNET_TIME_Absolute timestamp,
+                    struct GNUNET_TIME_Timestamp timestamp,
                     const char *order_id,
                     const struct TALER_ClaimTokenP *token,
                     const struct TALER_Amount *amount)
@@ -383,7 +383,9 @@ ongoing_payment_cb (void *cls,
                              &SH_annual_fee))
     return; /* can't re-use, fees changed */
   if ( (NULL == bc->existing_order_id) ||
-       (bc->existing_order_timestamp.abs_value_us < timestamp.abs_value_us) )
+       (GNUNET_TIME_timestamp_cmp (bc->existing_order_timestamp,
+                                   (<),
+                                   timestamp)) )
   {
     GNUNET_free (bc->existing_order_id);
     bc->existing_order_id = GNUNET_strdup (order_id);
diff --git a/src/sync/sync-httpd_config.c b/src/sync/sync-httpd_config.c
index b75c1d5..f8a0b17 100644
--- a/src/sync/sync-httpd_config.c
+++ b/src/sync/sync-httpd_config.c
@@ -61,7 +61,7 @@ SH_handler_config (struct SH_RequestHandler *rh,
     TALER_JSON_pack_amount ("annual_fee",
                             &SH_annual_fee),
     GNUNET_JSON_pack_string ("version",
-                             "1:0:1"));
+                             "2:0:0"));
 }
 
 
diff --git a/src/syncdb/plugin_syncdb_postgres.c 
b/src/syncdb/plugin_syncdb_postgres.c
index 8e294cb..ffdb955 100644
--- a/src/syncdb/plugin_syncdb_postgres.c
+++ b/src/syncdb/plugin_syncdb_postgres.c
@@ -452,11 +452,11 @@ postgres_gc (void *cls,
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_QueryParam params[] = {
-    TALER_PQ_query_param_absolute_time (&expire_backups),
+    GNUNET_PQ_query_param_absolute_time (&expire_backups),
     GNUNET_PQ_query_param_end
   };
   struct GNUNET_PQ_QueryParam params2[] = {
-    TALER_PQ_query_param_absolute_time (&expire_pending_payments),
+    GNUNET_PQ_query_param_absolute_time (&expire_pending_payments),
     GNUNET_PQ_query_param_end
   };
   enum GNUNET_DB_QueryStatus qs;
@@ -496,12 +496,12 @@ postgres_store_payment (void *cls,
   struct PostgresClosure *pg = cls;
   enum GNUNET_DB_QueryStatus qs;
   struct TALER_ClaimTokenP tok;
-  struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+  struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (account_pub),
     GNUNET_PQ_query_param_string (order_id),
     GNUNET_PQ_query_param_auto_from_type (&tok),
-    GNUNET_PQ_query_param_absolute_time (&now),
+    GNUNET_PQ_query_param_timestamp (&now),
     TALER_PQ_query_param_amount (amount),
     GNUNET_PQ_query_param_end
   };
@@ -581,13 +581,13 @@ payment_by_account_cb (void *cls,
 
   for (unsigned int i = 0; i < num_results; i++)
   {
-    struct GNUNET_TIME_Absolute timestamp;
+    struct GNUNET_TIME_Timestamp timestamp;
     char *order_id;
     struct TALER_Amount amount;
     struct TALER_ClaimTokenP token;
     struct GNUNET_PQ_ResultSpec rs[] = {
-      GNUNET_PQ_result_spec_absolute_time ("timestamp",
-                                           &timestamp),
+      GNUNET_PQ_result_spec_timestamp ("timestamp",
+                                       &timestamp),
       GNUNET_PQ_result_spec_string ("order_id",
                                     &order_id),
       GNUNET_PQ_result_spec_auto_from_type ("token",
@@ -723,7 +723,7 @@ postgres_store_backup (void *cls,
 
   /* First, check if account exists */
   {
-    struct GNUNET_TIME_Absolute ed;
+    struct GNUNET_TIME_Timestamp ed;
     struct GNUNET_PQ_QueryParam params[] = {
       GNUNET_PQ_query_param_auto_from_type (account_pub),
       GNUNET_PQ_query_param_end
@@ -864,7 +864,7 @@ postgres_update_backup (void *cls,
 
   /* First, check if account exists */
   {
-    struct GNUNET_TIME_Absolute ed;
+    struct GNUNET_TIME_Timestamp ed;
     struct GNUNET_PQ_QueryParam params[] = {
       GNUNET_PQ_query_param_auto_from_type (account_pub),
       GNUNET_PQ_query_param_end
@@ -1000,7 +1000,7 @@ postgres_lookup_account (void *cls,
 
   /* check if account exists */
   {
-    struct GNUNET_TIME_Absolute expiration;
+    struct GNUNET_TIME_Timestamp expiration;
     struct GNUNET_PQ_ResultSpec rs[] = {
       GNUNET_PQ_result_spec_auto_from_type ("expiration_date",
                                             &expiration),
@@ -1111,7 +1111,7 @@ postgres_increment_lifetime (void *cls,
                              struct GNUNET_TIME_Relative lifetime)
 {
   struct PostgresClosure *pg = cls;
-  struct GNUNET_TIME_Absolute expiration;
+  struct GNUNET_TIME_Timestamp expiration;
   enum GNUNET_DB_QueryStatus qs;
 
   check_connection (pg);
@@ -1157,8 +1157,8 @@ postgres_increment_lifetime (void *cls,
       GNUNET_PQ_query_param_end
     };
     struct GNUNET_PQ_ResultSpec rs[] = {
-      TALER_PQ_result_spec_absolute_time ("expiration_date",
-                                          &expiration),
+      GNUNET_PQ_result_spec_timestamp ("expiration_date",
+                                       &expiration),
       GNUNET_PQ_result_spec_end
     };
 
@@ -1180,11 +1180,11 @@ postgres_increment_lifetime (void *cls,
     {
       struct GNUNET_PQ_QueryParam params[] = {
         GNUNET_PQ_query_param_auto_from_type (account_pub),
-        GNUNET_PQ_query_param_absolute_time (&expiration),
+        GNUNET_PQ_query_param_timestamp (&expiration),
         GNUNET_PQ_query_param_end
       };
 
-      expiration = GNUNET_TIME_relative_to_absolute (lifetime);
+      expiration = GNUNET_TIME_relative_to_timestamp (lifetime);
       qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
                                                "account_insert",
                                                params);
@@ -1193,13 +1193,14 @@ postgres_increment_lifetime (void *cls,
   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
     {
       struct GNUNET_PQ_QueryParam params[] = {
-        GNUNET_PQ_query_param_absolute_time (&expiration),
+        GNUNET_PQ_query_param_timestamp (&expiration),
         GNUNET_PQ_query_param_auto_from_type (account_pub),
         GNUNET_PQ_query_param_end
       };
 
-      expiration = GNUNET_TIME_absolute_add (expiration,
-                                             lifetime);
+      expiration = GNUNET_TIME_absolute_to_timestamp (
+        GNUNET_TIME_absolute_add (expiration.abs_time,
+                                  lifetime));
       qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
                                                "account_update",
                                                params);
diff --git a/src/syncdb/sync-dbinit.c b/src/syncdb/sync-dbinit.c
index a158abf..be7b2ae 100644
--- a/src/syncdb/sync-dbinit.c
+++ b/src/syncdb/sync-dbinit.c
@@ -85,7 +85,6 @@ run (void *cls,
     struct GNUNET_TIME_Absolute ancient;
 
     now = GNUNET_TIME_absolute_get ();
-    (void) GNUNET_TIME_round_abs (&now);
     ancient = GNUNET_TIME_absolute_subtract (now,
                                              GNUNET_TIME_relative_multiply (
                                                GNUNET_TIME_UNIT_YEARS,
diff --git a/src/syncdb/test_sync_db.c b/src/syncdb/test_sync_db.c
index 8bea684..73c5e1f 100644
--- a/src/syncdb/test_sync_db.c
+++ b/src/syncdb/test_sync_db.c
@@ -60,7 +60,7 @@ static struct SYNC_DatabasePlugin *plugin;
  */
 static void
 payment_it (void *cls,
-            struct GNUNET_TIME_Absolute timestamp,
+            struct GNUNET_TIME_Timestamp timestamp,
             const char *order_id,
             const struct TALER_ClaimTokenP *token,
             const struct TALER_Amount *amount)
@@ -235,7 +235,6 @@ run (void *cls)
                                     4,
                                     "DATA"));
   ts = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS);
-  (void) GNUNET_TIME_round_abs (&ts);
   FAILIF (0 >
           plugin->gc (plugin->cls,
                       ts,

-- 
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]