if (0 < RPS_sampler_count_id (prot_sampler, peer))
{
/* Make sure we 'know' about this peer */
- (void) Peers_insert_peer (peer);
+ (void) Peers_insert_peer_check_liveliness (peer);
/* Establish a channel towards that peer to indicate we are going to send
* messages to it */
Peers_indicate_sending_intention (peer);
i,
GNUNET_i2s (&peers[i]));
- if (GNUNET_YES == Peers_insert_peer (&peers[i]))
+ if (GNUNET_YES == Peers_insert_peer_check_liveliness (&peers[i]))
{
Peers_schedule_operation (&peers[i], insert_in_sampler);
Peers_schedule_operation (&peers[i], insert_in_view);
&peers[i]))
{
/* Make sure we 'know' about this peer */
- (void) Peers_insert_peer (&peers[i]);
+ (void) Peers_insert_peer_check_liveliness (&peers[i]);
if (GNUNET_YES == Peers_check_peer_flag (&peers[i], Peers_VALID))
{
/* Set the flag of the attacked peer to valid to avoid problems */
if (GNUNET_NO == Peers_check_peer_known (&attacked_peer))
{
- Peers_insert_peer (&attacked_peer);
+ Peers_insert_peer_check_liveliness (&attacked_peer);
Peers_issue_peer_liveliness_check (&attacked_peer);
}
* Send as many pushes to the attacked peer as possible
* That is one push per round as it will ignore more.
*/
- Peers_insert_peer (&attacked_peer);
+ Peers_insert_peer_check_liveliness (&attacked_peer);
if (GNUNET_YES == Peers_check_peer_flag (&attacked_peer, Peers_VALID))
send_push (&attacked_peer);
}
/* Send PUSH to attacked peers */
if (GNUNET_YES == Peers_check_peer_known (&attacked_peer))
{
- Peers_insert_peer (&attacked_peer);
+ Peers_insert_peer_check_liveliness (&attacked_peer);
if (GNUNET_YES == Peers_check_peer_flag (&attacked_peer, Peers_VALID))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
Peers_issue_peer_liveliness_check (&attacked_peer);
}
else
- Peers_insert_peer (&attacked_peer);
+ Peers_insert_peer_check_liveliness (&attacked_peer);
Peers_issue_peer_liveliness_check (&attacked_peer);
/* The maximum of pushes we're going to send this round */
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got peer_id %s from cadet\n",
GNUNET_i2s (peer));
- Peers_insert_peer (peer);
+ Peers_insert_peer_check_liveliness (peer);
Peers_schedule_operation (peer, insert_in_sampler);
Peers_schedule_operation (peer, insert_in_view);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got peer_id %s from peerinfo\n",
GNUNET_i2s (peer));
- Peers_insert_peer (peer);
+ Peers_insert_peer_check_liveliness (peer);
Peers_schedule_operation (peer, insert_in_sampler);
Peers_schedule_operation (peer, insert_in_view);
}
int
Peers_insert_peer (const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *peer_ctx;
-
if ( (GNUNET_YES == Peers_check_peer_known (peer)) ||
(0 == GNUNET_CRYPTO_cmp_peer_identity (peer, own_identity)) )
{
return GNUNET_NO; /* We already know this peer - nothing to do */
}
- peer_ctx = create_peer_ctx (peer);
- // TODO LIVE
+ (void) create_peer_ctx (peer);
+ return GNUNET_YES;
+}
+
+
+/**
+ * @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(), ...)
+ *
+ * @param peer the new #GNUNET_PeerIdentity
+ *
+ * @return #GNUNET_YES if peer was inserted
+ * #GNUNET_NO if peer was already known
+ */
+int
+Peers_insert_peer_check_liveliness (const struct GNUNET_PeerIdentity *peer)
+{
+ struct PeerContext *peer_ctx;
+ int ret;
+
+ ret = Peers_insert_peer (peer);
+ if (0 == GNUNET_CRYPTO_cmp_peer_identity (peer, own_identity))
+ {
+ return ret;
+ }
+ peer_ctx = get_peer_ctx (peer);
if (GNUNET_NO == check_peer_flag_set (peer_ctx, Peers_VALID))
{
check_peer_live (peer_ctx);
}
- return GNUNET_YES;
+ return ret;
}
/**