/* IN_OWN_SAMPLER_LIST = 0x04, unneeded? */
/* IN_OWN_GOSSIP_LIST = 0x08, unneeded? */
- /**
- * We set this bit when we can be sure the other peer is/was live.
- */
- Peers_VALID = 0x10,
-
/**
* We set this bit when we know the peer is online.
*/
*/
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
*
+ * @param fn_valid_peers filename of the file used to store valid peer ids
* @param cadet_h cadet handle
* @param own_id own peer identity
*/
void
-Peers_initialise (struct GNUNET_CADET_Handle *cadet_h,
+Peers_initialise (char* fn_valid_peers,
+ struct GNUNET_CADET_Handle *cadet_h,
const struct GNUNET_PeerIdentity *own_id);
/**
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.
*
* @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
- *
- * If the other peer is not intending to send messages, we have messages pending
- * to be sent to this peer and we are not waiting for a reply, remove the
- * information about it (its #PeerContext).
+ * @brief Check if peer is removable.
*
- * @param peer the peer to clean
- * @return #GNUNET_YES if peer was removed
- * #GNUNET_NO otherwise
+ * Check if
+ * - a recv channel exists
+ * - there are pending messages
+ * - there is no pending pull reply
+ *
+ * @param peer the peer in question
+ * @return #GNUNET_YES if peer is removable
+ * #GNUNET_NO if peer is NOT removable
+ * #GNUNET_SYSERR if peer is not known
*/
int
-Peers_clean_peer (const struct GNUNET_PeerIdentity *peer);
+Peers_check_removable (const struct GNUNET_PeerIdentity *peer);
/**
* @brief Remove peer
- *
+ *
* @param peer the peer to clean
* @return #GNUNET_YES if peer was removed
* #GNUNET_NO otherwise
/**
* @brief Check whether we have information about the given peer.
*
+ * FIXME probably deprecated. Make this the new _online.
+ *
* @param peer peer in question
*
* @return #GNUNET_YES if peer is known
int
Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer);
+/**
+ * @brief Check whether @a peer is actually a peer.
+ *
+ * A valid peer is a peer that we know exists eg. we were connected to once.
+ *
+ * @param peer peer in question
+ *
+ * @return #GNUNET_YES if peer is valid
+ * #GNUNET_NO if peer is not valid
+ */
+int
+Peers_check_peer_valid (const struct GNUNET_PeerIdentity *peer);
+
/**
* @brief Indicate that we want to send to the other peer
*
Peers_handle_inbound_channel (void *cls,
struct GNUNET_CADET_Channel *channel,
const struct GNUNET_PeerIdentity *initiator,
- uint32_t port,
+ const struct GNUNET_HashCode *port,
enum GNUNET_CADET_ChannelOption options);
/**
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.
*