-rps: merge duplicate functions
[oweals/gnunet.git] / src / rps / gnunet-service-rps_peers.h
index 8a163f8cf7b1804b5f9e277a17a5860956b6e1ee..abb5d831a7ab0d7266a3e54b6ac7f10fedef308d 100644 (file)
@@ -99,6 +99,19 @@ enum Peers_ChannelRole
  */
 typedef void (* PeerOp) (void *cls, const struct GNUNET_PeerIdentity *peer);
 
+/**
+ * @brief Iterator over valid peers.
+ *
+ * @param cls closure
+ * @param peer current public peer id
+ * @return #GNUNET_YES if we should continue to
+ *         iterate,
+ *         #GNUNET_NO if not.
+ */
+typedef int
+(*PeersIterator) (void *cls,
+                  const struct GNUNET_PeerIdentity *peer);
+
 /**
  * @brief Initialise storage of peers
  *
@@ -117,6 +130,19 @@ Peers_initialise (char* fn_valid_peers,
 void
 Peers_terminate ();
 
+
+/**
+ * @brief Get all currently known, valid peer ids.
+ *
+ * @param it function to call on each peer id
+ * @param it_cls extra argument to @a it
+ * @return the number of key value pairs processed,
+ *         #GNUNET_SYSERR if it aborted iteration
+ */
+int
+Peers_get_valid_peers (PeersIterator iterator,
+                       void *it_cls);
+
 /**
  * @brief Add peer to known peers.
  *
@@ -126,24 +152,24 @@ Peers_terminate ();
  * @param peer the new #GNUNET_PeerIdentity
  *
  * @return #GNUNET_YES if peer was inserted
- *         #GNUNET_NO  if peer was already known
+ *         #GNUNET_NO  otherwise (if peer was already known or
+ *                     peer was #own_identity)
  */
 int
 Peers_insert_peer (const struct GNUNET_PeerIdentity *peer);
 
 /**
- * @brief Add peer to known peers and check for liveliness.
- *
- * This function is called on new peer_ids from 'external' sources
- * (client seed, cadet get_peers(), ...)
+ * @brief Try connecting to a peer to see whether it is online
  *
- * @param peer the new #GNUNET_PeerIdentity
+ * If not known yet, insert into known peers
  *
- * @return #GNUNET_YES if peer was inserted
- *         #GNUNET_NO  if peer was already known
+ * @param peer the peer whose liveliness is to be checked
+ * @return #GNUNET_YES if peer had to be inserted
+ *         #GNUNET_NO  otherwise (if peer was already known or
+ *                     peer was #own_identity)
  */
 int
-Peers_insert_peer_check_liveliness (const struct GNUNET_PeerIdentity *peer);
+Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer);
 
 /**
  * @brief Remove unecessary data
@@ -354,17 +380,6 @@ Peers_cleanup_destroyed_channel (void *cls,
                                  const struct GNUNET_CADET_Channel *channel,
                                  void *channel_ctx);
 
-/**
- * @brief Issue a check whether peer is live
- *
- * This tries to establish a channel to the given peer. Once the channel is
- * established successfully, we know the peer is live.
- *
- * @param peer the peer to check liveliness
- */
-void
-Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer);
-
 /**
  * @brief Send a message to another peer.
  *