gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 23/40: NEWS: Changed method GNUNET_HELLO_builder_get_expiration


From: gnunet
Subject: [gnunet] 23/40: NEWS: Changed method GNUNET_HELLO_builder_get_expiration_time to not need parameter GNUNET_HELLO_Builder.
Date: Thu, 05 Oct 2023 08:57:26 +0200

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit 84913ba1514b516944887f6aef3d46979ea361cb
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Mon Oct 2 18:14:35 2023 +0200

    NEWS: Changed method GNUNET_HELLO_builder_get_expiration_time to not need 
parameter GNUNET_HELLO_Builder.
---
 src/cadet/gnunet-service-cadet_hello.c       | 11 ++++-------
 src/cadet/gnunet-service-cadet_peer.c        | 27 ++++++++++++---------------
 src/hostlist/gnunet-daemon-hostlist_server.c | 13 ++++---------
 src/include/gnunet_hello_uri_lib.h           |  5 ++---
 4 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/src/cadet/gnunet-service-cadet_hello.c 
b/src/cadet/gnunet-service-cadet_hello.c
index 7a33b0e05..1e3322733 100644
--- a/src/cadet/gnunet-service-cadet_hello.c
+++ b/src/cadet/gnunet-service-cadet_hello.c
@@ -68,7 +68,6 @@ got_hello (void *cls,
            const char *err_msg)
 {
   struct CadetPeer *peer;
-  struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (hello);
 
   if ((NULL == id) ||
       (NULL == hello))
@@ -81,19 +80,17 @@ got_hello (void *cls,
     GCD_hello_update ();
     return;
   }
-  
+
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Hello for %s (%d bytes), expires on %s\n",
        GNUNET_i2s (id),
        sizeof (hello),
        GNUNET_STRINGS_absolute_time_to_string (
-                                               
GNUNET_HELLO_builder_get_expiration_time (builder,
-                                                                               
          hello)));
+         GNUNET_HELLO_builder_get_expiration_time (hello)));
   peer = GCP_get (id,
                   GNUNET_YES);
   GCP_set_hello (peer,
                  hello);
-  GNUNET_HELLO_builder_free (builder);
 }
 
 
@@ -108,8 +105,8 @@ GCH_init (const struct GNUNET_CONFIGURATION_Handle *c)
   GNUNET_assert (NULL == peerstore_notify);
   peerstore = GNUNET_PEERSTORE_connect (c);
   peerstore_notify =
-      GNUNET_PEERSTORE_hello_changed_notify (peerstore, GNUNET_NO, &got_hello,
-                                             NULL);
+    GNUNET_PEERSTORE_hello_changed_notify (peerstore, GNUNET_NO, &got_hello,
+                                           NULL);
 }
 
 
diff --git a/src/cadet/gnunet-service-cadet_peer.c 
b/src/cadet/gnunet-service-cadet_peer.c
index c46e968dc..5c810e926 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -491,15 +491,13 @@ consider_peer_destroy (struct CadetPeer *cp)
     return; /* still relevant! */
   if (NULL != cp->hello)
   {
-    struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg 
(cp->hello);
-
     /* relevant only until HELLO expires */
-    exp = GNUNET_TIME_absolute_get_remaining 
(GNUNET_HELLO_builder_get_expiration_time (builder,
-                                                                               
         cp->hello));
+    exp = GNUNET_TIME_absolute_get_remaining (
+      GNUNET_HELLO_builder_get_expiration_time (cp
+                                                ->hello));
     cp->destroy_task = GNUNET_SCHEDULER_add_delayed (exp,
                                                      &destroy_peer,
                                                      cp);
-    GNUNET_HELLO_builder_free (builder);
     return;
   }
   cp->destroy_task = GNUNET_SCHEDULER_add_delayed (IDLE_PEER_TIMEOUT,
@@ -1323,14 +1321,15 @@ GCP_set_hello (struct CadetPeer *cp,
   if (NULL != cp->hello)
   {
     struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
-    struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg 
(hello);
-    struct GNUNET_HELLO_Builder *cp_builder = GNUNET_HELLO_builder_from_msg 
(cp->hello);
-    struct GNUNET_TIME_Absolute new_hello_exp = 
GNUNET_HELLO_builder_get_expiration_time (builder,
-                                                                               
           hello);
-    struct GNUNET_TIME_Absolute old_hello_exp = 
GNUNET_HELLO_builder_get_expiration_time (cp_builder,
-                                                                               
           cp->hello);
-
-    if (GNUNET_TIME_absolute_cmp (new_hello_exp, > , now) && 
GNUNET_TIME_absolute_cmp (new_hello_exp, > , old_hello_exp))
+    
+    struct GNUNET_TIME_Absolute new_hello_exp =
+      GNUNET_HELLO_builder_get_expiration_time (hello);
+    struct GNUNET_TIME_Absolute old_hello_exp =
+      GNUNET_HELLO_builder_get_expiration_time (cp
+                                                ->hello);
+
+    if (GNUNET_TIME_absolute_cmp (new_hello_exp, >, now) &&
+        GNUNET_TIME_absolute_cmp (new_hello_exp, >, old_hello_exp))
     {
       GNUNET_free (cp->hello);
       cp->hello = GNUNET_malloc (size);
@@ -1340,8 +1339,6 @@ GCP_set_hello (struct CadetPeer *cp,
     {
       return;
     }
-    GNUNET_HELLO_builder_free (builder);
-    GNUNET_HELLO_builder_free (cp_builder);
   }
   else
   {
diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c 
b/src/hostlist/gnunet-daemon-hostlist_server.c
index 4c276ce80..f383ec394 100644
--- a/src/hostlist/gnunet-daemon-hostlist_server.c
+++ b/src/hostlist/gnunet-daemon-hostlist_server.c
@@ -195,11 +195,10 @@ host_processor (void *cls,
 {
   size_t old;
   size_t s;
-  struct GNUNET_HELLO_Builder *hello_builder;
   struct GNUNET_MessageHeader *hello;
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
   struct GNUNET_TIME_Absolute hello_exp;
-  
+
   if (NULL != emsg)
   {
     GNUNET_assert (NULL == &record->peer);
@@ -226,19 +225,17 @@ host_processor (void *cls,
       GNUNET_break (0);
       return;
     }
-    hello_builder = GNUNET_HELLO_builder_new (&record->peer);
-    hello_exp = GNUNET_HELLO_builder_get_expiration_time (hello_builder, 
hello);
-    if (GNUNET_TIME_absolute_cmp (hello_exp, < , now))
+    hello_exp = GNUNET_HELLO_builder_get_expiration_time (hello);
+    if (GNUNET_TIME_absolute_cmp (hello_exp, <, now))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "HELLO for peer `%4s' has expired address, not suitable for 
hostlist!\n",
                   GNUNET_i2s (&record->peer));
       GNUNET_STATISTICS_update (stats,
                                 gettext_noop (
-                                              "Expired HELLO encountered 
(ignored)"),
+                                  "Expired HELLO encountered (ignored)"),
                                 1,
                                 GNUNET_NO);
-      GNUNET_HELLO_builder_free (hello_builder);
       return;
     }
   }
@@ -258,7 +255,6 @@ host_processor (void *cls,
                                 "bytes not included in hostlist (size limit)"),
                               s,
                               GNUNET_NO);
-    GNUNET_HELLO_builder_free (hello_builder);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -267,7 +263,6 @@ host_processor (void *cls,
               (unsigned int) s);
   GNUNET_array_grow (builder->data, builder->size, old + s);
   GNUNET_memcpy (&builder->data[old], hello, s);
-  GNUNET_HELLO_builder_free (hello_builder);
 }
 
 
diff --git a/src/include/gnunet_hello_uri_lib.h 
b/src/include/gnunet_hello_uri_lib.h
index ec84f35b0..858b60793 100644
--- a/src/include/gnunet_hello_uri_lib.h
+++ b/src/include/gnunet_hello_uri_lib.h
@@ -120,13 +120,12 @@ GNUNET_HELLO_builder_from_url (const char *url);
 /**
  * Get the expiration time for this HELLO.
  *
- * @param builder builder to serialize
  * @param  msg The hello msg.
  * @return The expiration time.
  */
 struct GNUNET_TIME_Absolute
-GNUNET_HELLO_builder_get_expiration_time (struct GNUNET_HELLO_Builder *builder,
-                                          const struct GNUNET_MessageHeader 
*msg);
+GNUNET_HELLO_builder_get_expiration_time (const struct
+                                          GNUNET_MessageHeader *msg);
 
 
 /**

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