gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r25944 - in gnunet/src: core include


From: gnunet
Subject: [GNUnet-SVN] r25944 - in gnunet/src: core include
Date: Wed, 30 Jan 2013 14:38:49 +0100

Author: harsha
Date: 2013-01-30 14:38:49 +0100 (Wed, 30 Jan 2013)
New Revision: 25944

Modified:
   gnunet/src/core/core_api.c
   gnunet/src/include/gnunet_core_service.h
Log:
function to synchronously check if a peer is connected at CORE level

Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c  2013-01-30 13:34:47 UTC (rev 25943)
+++ gnunet/src/core/core_api.c  2013-01-30 13:38:49 UTC (rev 25944)
@@ -1369,4 +1369,29 @@
 }
 
 
+/**
+ * Check if the given peer is currently connected. This function is for special
+ * cirumstances (GNUNET_TESTBED uses it), normal users of the CORE API are
+ * expected to track which peers are connected based on the connect/disconnect
+ * callbacks from GNUNET_CORE_connect.  This function is NOT part of the
+ * 'versioned', 'official' API. The difference between this function and the
+ * function GNUNET_CORE_is_peer_connected() is that this one returns
+ * synchronously after looking in the CORE API cache. The function
+ * GNUNET_CORE_is_peer_connected() sends a message to the CORE service and 
hence
+ * its response is given asynchronously.
+ *
+ * @param h the core handle
+ * @param pid the identity of the peer to check if it has been connected to us
+ * @return GNUNET_YES if the peer is connected to us; GNUNET_NO if not
+ */
+int
+GNUNET_CORE_is_peer_connected_sync (const struct GNUNET_CORE_Handle *h,
+                                    const struct GNUNET_PeerIdentity *pid)
+{
+  GNUNET_assert (NULL != h);
+  GNUNET_assert (NULL != pid);
+  return GNUNET_CONTAINER_multihashmap_contains (h->peers, &pid->hashPubKey);
+}
+
+
 /* end of core_api.c */

Modified: gnunet/src/include/gnunet_core_service.h
===================================================================
--- gnunet/src/include/gnunet_core_service.h    2013-01-30 13:34:47 UTC (rev 
25943)
+++ gnunet/src/include/gnunet_core_service.h    2013-01-30 13:38:49 UTC (rev 
25944)
@@ -326,6 +326,26 @@
 GNUNET_CORE_is_peer_connected_cancel (struct GNUNET_CORE_ConnectTestHandle 
*cth);
 
 
+/**
+ * Check if the given peer is currently connected. This function is for special
+ * cirumstances (GNUNET_TESTBED uses it), normal users of the CORE API are
+ * expected to track which peers are connected based on the connect/disconnect
+ * callbacks from GNUNET_CORE_connect.  This function is NOT part of the
+ * 'versioned', 'official' API. The difference between this function and the
+ * function GNUNET_CORE_is_peer_connected() is that this one returns
+ * synchronously after looking in the CORE API cache. The function
+ * GNUNET_CORE_is_peer_connected() sends a message to the CORE service and 
hence
+ * its response is given asynchronously.
+ *
+ * @param h the core handle
+ * @param pid the identity of the peer to check if it has been connected to us
+ * @return GNUNET_YES if the peer is connected to us; GNUNET_NO if not
+ */
+int
+GNUNET_CORE_is_peer_connected_sync (const struct GNUNET_CORE_Handle *h,
+                                    const struct GNUNET_PeerIdentity *pid);
+
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif




reply via email to

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