gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r15741 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r15741 - in gnunet/src: include util
Date: Wed, 22 Jun 2011 10:39:54 +0200

Author: bartpolot
Date: 2011-06-22 10:39:54 +0200 (Wed, 22 Jun 2011)
New Revision: 15741

Modified:
   gnunet/src/include/gnunet_peer_lib.h
   gnunet/src/util/peer.c
Log:
Added search function for PEER_id given a PeerIdentity


Modified: gnunet/src/include/gnunet_peer_lib.h
===================================================================
--- gnunet/src/include/gnunet_peer_lib.h        2011-06-22 08:38:48 UTC (rev 
15740)
+++ gnunet/src/include/gnunet_peer_lib.h        2011-06-22 08:39:54 UTC (rev 
15741)
@@ -48,6 +48,15 @@
 
 
 /**
+ * Search for a peer identity. The reference counter is not changed.
+ *
+ * @param pid identity to find
+ * @return the interned identity or 0.
+ */
+GNUNET_PEER_Id GNUNET_PEER_search (const struct GNUNET_PeerIdentity *pid);
+
+
+/**
  * Intern an peer identity.  If the identity is already known, its
  * reference counter will be increased by one.
  *

Modified: gnunet/src/util/peer.c
===================================================================
--- gnunet/src/util/peer.c      2011-06-22 08:38:48 UTC (rev 15740)
+++ gnunet/src/util/peer.c      2011-06-22 08:39:54 UTC (rev 15741)
@@ -73,6 +73,35 @@
 
 
 /**
+ * Search for a peer identity. The reference counter is not changed.
+ *
+ * @param pid identity to find
+ * @return the interned identity or 0.
+ */
+GNUNET_PEER_Id
+GNUNET_PEER_search (const struct GNUNET_PeerIdentity *pid)
+{
+  struct PeerEntry *e;
+  long off;
+
+  if (pid == NULL)
+    return 0;
+  if (NULL == map)
+    return 0;
+  off = (long) GNUNET_CONTAINER_multihashmap_get (map, &pid->hashPubKey);
+  e = (off == 0) ? NULL : &table[off];
+  if (e != NULL)
+    {
+      GNUNET_assert (e->rc > 0);
+      return e->pid;
+    }
+  else
+    {
+      return 0;
+    }
+}
+
+/**
  * Intern an peer identity.  If the identity is already known, its
  * reference counter will be increased by one.
  *




reply via email to

[Prev in Thread] Current Thread [Next in Thread]