improve performance of identity_api_lookup.c logic to not be O(n)
authorChristian Grothoff <christian@grothoff.org>
Fri, 31 May 2019 22:58:06 +0000 (00:58 +0200)
committerChristian Grothoff <christian@grothoff.org>
Fri, 31 May 2019 22:58:06 +0000 (00:58 +0200)
src/identity/identity_api.c
src/identity/test_identity_defaults.c

index fa7c8b023ef60d2f48cc33eeccaca6ec7a0c4320..c463da641283037cb0947d52e21bacb3d2d82e4b 100644 (file)
@@ -596,6 +596,7 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h,
 
   if (NULL == h->mq)
     return NULL;
+  GNUNET_assert (NULL != h->cb);
   slen = strlen (service_name) + 1;
   if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage))
   {
@@ -641,6 +642,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h,
 
   if (NULL == h->mq)
     return NULL;
+  GNUNET_assert (NULL != h->cb);
   slen = strlen (service_name) + 1;
   if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage))
   {
index ecda31c4cccc058ca6d04b684300344da19353d1..71e70e7ba4d9a9cbd3996d4f276de12efb6a82d3 100644 (file)
@@ -148,6 +148,30 @@ get_cb (void *cls,
 }
 
 
+/**
+ * Called with events about egos.
+ *
+ * @param cls NULL
+ * @param ego ego handle
+ * @param ego_ctx context for application to store data for this ego
+ *                 (during the lifetime of this process, initially NULL)
+ * @param identifier identifier assigned by the user for this ego,
+ *                   NULL if the user just deleted the ego and it
+ *                   must thus no longer be used
+ */
+static void
+dummy_cb (void *cls,
+          struct GNUNET_IDENTITY_Ego *ego,
+          void **ctx,
+          const char *identifier)
+{
+  (void) cls;
+  (void) ego;
+  (void) ctx;
+  (void) identifier;
+}
+
+
 /**
  * Main function of the test, run from scheduler.
  *
@@ -162,7 +186,7 @@ run_get (void *cls,
 {
   endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL);
   GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
-  h = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
+  h = GNUNET_IDENTITY_connect (cfg, &dummy_cb, NULL);
   CHECK (NULL != h);
   op = GNUNET_IDENTITY_get (h, "test-service", &get_cb, NULL);
 }