deprecate ill-defined set_nick API
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Wed, 6 May 2020 16:42:45 +0000 (18:42 +0200)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Wed, 6 May 2020 16:42:45 +0000 (18:42 +0200)
src/include/gnunet_namestore_service.h
src/namestore/gnunet-namestore.c
src/namestore/namestore_api.c
src/namestore/test_namestore_api_lookup_nick.c
src/namestore/test_namestore_api_zone_iteration_nick.c

index a7b7c57b11d32c03ec8304fc83fb79c0f951b507..bf42c8d34d204a1863d83eb61b143754d5e2cbe4 100644 (file)
@@ -153,24 +153,6 @@ typedef void
                                    const struct GNUNET_GNSRECORD_Data *rd);
 
 
-/**
- * Set the desired nick name for a zone
- *
- * @param h handle to the namestore
- * @param pkey private key of the zone
- * @param nick the nick name to set
- * @param cont continuation to call when done
- * @param cont_cls closure for @a cont
- * @return handle to abort the request
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h,
-                           const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
-                           const char *nick,
-                           GNUNET_NAMESTORE_ContinuationWithStatus cont,
-                           void *cont_cls);
-
-
 /**
  * Lookup an item in the namestore.
  *
index 3514f4fd9491899a67d410564f50c1e6b14fd7c6..94fcb89529ad8387ad9dedc7bf907fefc5a35dd8 100644 (file)
@@ -1038,6 +1038,24 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
     GNUNET_free (rd);
     return;
   }
+  if (NULL != nickstring)
+  {
+    if (0 == strlen (nickstring))
+    {
+      fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
+      GNUNET_SCHEDULER_shutdown ();
+      ret = 1;
+      return;
+    }
+    add = 1;
+    typestring = GNUNET_strdup (GNUNET_GNSRECORD_number_to_typename (GNUNET_GNSRECORD_TYPE_NICK));
+    name = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT);
+    value = GNUNET_strdup (nickstring);
+    is_public = 0;
+    expirationstring = GNUNET_strdup ("never");
+    GNUNET_free (nickstring);
+    nickstring = NULL;
+  }
 
   if (add)
   {
@@ -1227,21 +1245,6 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
                                                  &add_continuation,
                                                  &add_qe_uri);
   }
-  if (NULL != nickstring)
-  {
-    if (0 == strlen (nickstring))
-    {
-      fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
-      GNUNET_SCHEDULER_shutdown ();
-      ret = 1;
-      return;
-    }
-    add_qe_uri = GNUNET_NAMESTORE_set_nick (ns,
-                                            &zone_pkey,
-                                            nickstring,
-                                            &add_continuation,
-                                            &add_qe_uri);
-  }
   if (monitor)
   {
     zm = GNUNET_NAMESTORE_zone_monitor_start (cfg,
index 156c115d2b861c00ed965f5cd546c6bd8d9f6649..2a085cf0413069360fdc019f70e459b79ea445d2 100644 (file)
@@ -1063,43 +1063,6 @@ GNUNET_NAMESTORE_records_store (
 }
 
 
-/**
- * Set the desired nick name for a zone
- *
- * @param h handle to the namestore
- * @param pkey private key of the zone
- * @param nick the nick name to set
- * @param cont continuation to call when done
- * @param cont_cls closure for @a cont
- * @return handle to abort the request
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h,
-                           const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
-                           const char *nick,
-                           GNUNET_NAMESTORE_ContinuationWithStatus cont,
-                           void *cont_cls)
-{
-  struct GNUNET_GNSRECORD_Data rd;
-
-  if (NULL == h->mq)
-    return NULL;
-  memset (&rd, 0, sizeof(rd));
-  rd.data = nick;
-  rd.data_size = strlen (nick) + 1;
-  rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
-  rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
-  rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
-  return GNUNET_NAMESTORE_records_store (h,
-                                         pkey,
-                                         GNUNET_GNS_EMPTY_LABEL_AT,
-                                         1,
-                                         &rd,
-                                         cont,
-                                         cont_cls);
-}
-
-
 /**
  * Lookup an item in the namestore.
  *
index 145a3e885367a6f4104fa42bdb95dc03aa74f71f..628e762542629971e9bb3dfa3e221c7c109d0928 100644 (file)
@@ -23,6 +23,7 @@
  */
 #include "platform.h"
 #include "gnunet_namestore_service.h"
+#include "gnunet_gns_service.h"
 #include "gnunet_testing_lib.h"
 #include "gnunet_dnsparser_lib.h"
 
@@ -280,6 +281,8 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg,
      struct GNUNET_TESTING_Peer *peer)
 {
+  struct GNUNET_GNSRECORD_Data rd;
+
   endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
                                                 &endbadly,
                                                 NULL);
@@ -290,11 +293,20 @@ run (void *cls,
   nsh = GNUNET_NAMESTORE_connect (cfg);
   GNUNET_break (NULL != nsh);
 
-  nsqe = GNUNET_NAMESTORE_set_nick (nsh,
-                                    &privkey,
-                                    TEST_NICK,
-                                    &nick_cont,
-                                    (void *) name);
+  memset (&rd, 0, sizeof(rd));
+  rd.data = TEST_NICK;
+  rd.data_size = strlen (TEST_NICK) + 1;
+  rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
+  rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+  rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+  nsqe = GNUNET_NAMESTORE_records_store (nsh,
+                                         &privkey,
+                                         GNUNET_GNS_EMPTY_LABEL_AT,
+                                         1,
+                                         &rd,
+                                         &nick_cont,
+                                         (void *) name);
+
   if (NULL == nsqe)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
index b0c4c8211f4cd60b153c30ee6fa23dc6bc06c67c..1ebdfd073511afcbe10168f856b9a68c9dc0b8db 100644 (file)
@@ -23,6 +23,7 @@
  */
 #include "platform.h"
 #include "gnunet_namestore_service.h"
+#include "gnunet_gns_service.h"
 #include "gnunet_testing_lib.h"
 #include "namestore.h"
 #include "gnunet_dnsparser_lib.h"
@@ -313,10 +314,22 @@ nick_1_cont (void *cls, int32_t success, const char *emsg)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Nick 1 added : %s\n",
               (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
+  struct GNUNET_GNSRECORD_Data rd;
+
+  memset (&rd, 0, sizeof(rd));
+  rd.data = ZONE_NICK_2;
+  rd.data_size = strlen (ZONE_NICK_2) + 1;
+  rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
+  rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+  rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+  nsqe = GNUNET_NAMESTORE_records_store (nsh,
+                                         &privkey2,
+                                         GNUNET_GNS_EMPTY_LABEL_AT,
+                                         1,
+                                         &rd,
+                                         &nick_2_cont,
+                                         &privkey2);
 
-  nsqe = GNUNET_NAMESTORE_set_nick (nsh,
-                                    &privkey2, ZONE_NICK_2, &nick_2_cont,
-                                    &privkey2);
   if (NULL == nsqe)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -363,14 +376,25 @@ static void
 empty_zone_end (void *cls)
 {
   GNUNET_assert (nsh == cls);
+  struct GNUNET_GNSRECORD_Data rd;
+
   zi = NULL;
   GNUNET_CRYPTO_ecdsa_key_create (&privkey);
   GNUNET_CRYPTO_ecdsa_key_create (&privkey2);
-  nsqe = GNUNET_NAMESTORE_set_nick (nsh,
-                                    &privkey,
-                                    ZONE_NICK_1,
-                                    &nick_1_cont,
-                                    NULL);
+
+  memset (&rd, 0, sizeof(rd));
+  rd.data = ZONE_NICK_1;
+  rd.data_size = strlen (ZONE_NICK_1) + 1;
+  rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
+  rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+  rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+  nsqe = GNUNET_NAMESTORE_records_store (nsh,
+                                         &privkey,
+                                         GNUNET_GNS_EMPTY_LABEL_AT,
+                                         1,
+                                         &rd,
+                                         &nick_1_cont,
+                                         NULL);
   if (NULL == nsqe)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,