gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 05/06: Cadet: Changes to use DhtHelloMessage instead of HelloUr


From: gnunet
Subject: [gnunet] 05/06: Cadet: Changes to use DhtHelloMessage instead of HelloUriMessage, and to hand over not a HelloMessage, but a block to the dht.
Date: Fri, 27 Oct 2023 17:43:58 +0200

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

t3sserakt pushed a commit to branch master
in repository gnunet.

commit 8ebef9f2eddf91fa98d3f141e282ff0ce45dbe68
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Fri Oct 27 11:42:56 2023 +0200

    Cadet: Changes to use DhtHelloMessage instead of HelloUriMessage, and to 
hand over not a HelloMessage, but a block to the dht.
---
 src/service/cadet/gnunet-service-cadet_dht.c   | 15 ++++++++++++---
 src/service/cadet/gnunet-service-cadet_hello.c | 17 ++++++++++++++++-
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/service/cadet/gnunet-service-cadet_dht.c 
b/src/service/cadet/gnunet-service-cadet_dht.c
index ef5669344..28b5448fd 100644
--- a/src/service/cadet/gnunet-service-cadet_dht.c
+++ b/src/service/cadet/gnunet-service-cadet_dht.c
@@ -153,6 +153,8 @@ announce_id (void *cls)
   struct GNUNET_HashCode phash;
   const struct GNUNET_MessageHeader *hello;
   size_t size;
+  size_t block_size;
+  void *block;
   struct GNUNET_TIME_Absolute expiration;
   struct GNUNET_TIME_Relative next_put;
 
@@ -194,17 +196,24 @@ announce_id (void *cls)
   GNUNET_memcpy (&phash,
                  &my_full_id,
                  sizeof(my_full_id));
+  if (GNUNET_OK != GNUNET_HELLO_dht_msg_to_block (hello,
+                                                  &my_full_id,
+                                                  &block,
+                                                  &block_size,
+                                                  &expiration))
+    return;
+
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Announcing my HELLO (%lu bytes) in the DHT\n",
-       (unsigned long) size);
+       (unsigned long) block_size);
   GNUNET_DHT_put (dht_handle,    /* DHT handle */
                   &phash,       /* Key to use */
                   dht_replication_level,     /* Replication level */
                   GNUNET_DHT_RO_RECORD_ROUTE
                   | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,    /* DHT options */
                   GNUNET_BLOCK_TYPE_DHT_HELLO,       /* Block type */
-                  size,  /* Size of the data */
-                  (const char *) hello, /* Data itself */
+                  block_size,  /* Size of the data */
+                  (const char *) block, /* Data itself */
                   expiration,  /* Data expiration */
                   NULL,         /* Continuation */
                   NULL);        /* Continuation closure */
diff --git a/src/service/cadet/gnunet-service-cadet_hello.c 
b/src/service/cadet/gnunet-service-cadet_hello.c
index 135fde25a..3c8509ea4 100644
--- a/src/service/cadet/gnunet-service-cadet_hello.c
+++ b/src/service/cadet/gnunet-service-cadet_hello.c
@@ -68,6 +68,7 @@ got_hello (void *cls,
            const char *err_msg)
 {
   struct CadetPeer *peer;
+  struct GNUNET_HELLO_Builder *builder;
 
   if ((NULL == id) ||
       (NULL == hello))
@@ -76,7 +77,11 @@ got_hello (void *cls,
                           &my_full_id))
   {
     GNUNET_free (mine);
-    mine = GNUNET_copy_message (hello);
+    builder = GNUNET_HELLO_builder_from_msg (hello);
+    mine = GNUNET_HELLO_builder_to_dht_hello_msg (builder,
+                                                  my_private_key,
+                                                  GNUNET_TIME_UNIT_ZERO);
+    GNUNET_HELLO_builder_free (builder);
     GCD_hello_update ();
     return;
   }
@@ -142,6 +147,16 @@ GCH_shutdown ()
 const struct GNUNET_MessageHeader *
 GCH_get_mine (void)
 {
+  struct GNUNET_HELLO_Builder *builder;
+
+  if (NULL == mine)
+  {
+    builder = GNUNET_HELLO_builder_new (&my_full_id);
+    mine = GNUNET_HELLO_builder_to_dht_hello_msg (builder,
+                                       my_private_key,
+                                       GNUNET_TIME_UNIT_ZERO);
+    GNUNET_HELLO_builder_free (builder);
+  }
   return mine;
 }
 

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