From f992fd2bc8ffa761d02549c1da8df4cb6e1877bc Mon Sep 17 00:00:00 2001 From: Julius Bünger Date: Mon, 13 Jun 2016 22:46:05 +0000 Subject: -rps: merge duplicate functions --- src/rps/gnunet-service-rps.c | 26 ++++++++++---------------- src/rps/gnunet-service-rps_peers.c | 25 +------------------------ src/rps/gnunet-service-rps_peers.h | 13 +------------ 3 files changed, 12 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index feffe2ba1..4e24c6231 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c @@ -466,7 +466,7 @@ insert_in_view (const struct GNUNET_PeerIdentity *peer) if ( (GNUNET_NO == online) || (GNUNET_SYSERR == online) ) /* peer is not even known */ { - (void) Peers_check_peer_live (peer); + (void) Peers_issue_peer_liveliness_check (peer); (void) Peers_schedule_operation (peer, insert_in_view_op); return GNUNET_NO; } @@ -704,11 +704,10 @@ insert_in_sampler (void *cls, if (0 < RPS_sampler_count_id (prot_sampler, peer)) { /* Make sure we 'know' about this peer */ - (void) Peers_check_peer_live (peer); + (void) Peers_issue_peer_liveliness_check (peer); /* Establish a channel towards that peer to indicate we are going to send * messages to it */ - Peers_indicate_sending_intention (peer); - //Peers_issue_peer_liveliness_check (peer); + //Peers_indicate_sending_intention (peer); } } @@ -722,7 +721,7 @@ static void got_peer (const struct GNUNET_PeerIdentity *peer) { /* If we did not know this peer already, insert it into sampler and view */ - if (GNUNET_YES == Peers_check_peer_live (peer)) + if (GNUNET_YES == Peers_issue_peer_liveliness_check (peer)) { Peers_schedule_operation (peer, insert_in_sampler); Peers_schedule_operation (peer, insert_in_view_op); @@ -1417,7 +1416,7 @@ handle_peer_pull_reply (void *cls, &peers[i])) { /* Make sure we 'know' about this peer */ - (void) Peers_check_peer_live (&peers[i]); + (void) Peers_insert_peer (&peers[i]); if (GNUNET_YES == Peers_check_peer_valid (&peers[i])) { @@ -1426,7 +1425,7 @@ handle_peer_pull_reply (void *cls, else { Peers_schedule_operation (&peers[i], insert_in_pull_map); - Peers_issue_peer_liveliness_check (&peers[i]); + (void) Peers_issue_peer_liveliness_check (&peers[i]); } } } @@ -1636,8 +1635,7 @@ handle_client_act_malicious (void *cls, /* Set the flag of the attacked peer to valid to avoid problems */ if (GNUNET_NO == Peers_check_peer_known (&attacked_peer)) { - Peers_check_peer_live (&attacked_peer); - Peers_issue_peer_liveliness_check (&attacked_peer); + (void) Peers_issue_peer_liveliness_check (&attacked_peer); } LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -1727,7 +1725,7 @@ do_mal_round (void *cls) * Send as many pushes to the attacked peer as possible * That is one push per round as it will ignore more. */ - Peers_check_peer_live (&attacked_peer); + (void) Peers_issue_peer_liveliness_check (&attacked_peer); if (GNUNET_YES == Peers_check_peer_valid (&attacked_peer)) send_push (&attacked_peer); } @@ -1739,7 +1737,7 @@ do_mal_round (void *cls) /* Send PUSH to attacked peers */ if (GNUNET_YES == Peers_check_peer_known (&attacked_peer)) { - Peers_check_peer_live (&attacked_peer); + (void) Peers_issue_peer_liveliness_check (&attacked_peer); if (GNUNET_YES == Peers_check_peer_valid (&attacked_peer)) { LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -1747,12 +1745,8 @@ do_mal_round (void *cls) GNUNET_i2s (&attacked_peer)); send_push (&attacked_peer); } - else - Peers_issue_peer_liveliness_check (&attacked_peer); } - else - Peers_check_peer_live (&attacked_peer); - Peers_issue_peer_liveliness_check (&attacked_peer); + (void) Peers_issue_peer_liveliness_check (&attacked_peer); /* The maximum of pushes we're going to send this round */ num_pushes = GNUNET_MIN (GNUNET_MIN (push_limit - 1, diff --git a/src/rps/gnunet-service-rps_peers.c b/src/rps/gnunet-service-rps_peers.c index 1153627f9..aeef409aa 100644 --- a/src/rps/gnunet-service-rps_peers.c +++ b/src/rps/gnunet-service-rps_peers.c @@ -1020,7 +1020,7 @@ Peers_insert_peer (const struct GNUNET_PeerIdentity *peer) * peer was #own_identity) */ int -Peers_check_peer_live (const struct GNUNET_PeerIdentity *peer) +Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) { struct PeerContext *peer_ctx; int ret; @@ -1520,29 +1520,6 @@ Peers_cleanup_destroyed_channel (void *cls, (void) Peers_check_connected (peer); } -/** - * @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) -{ - struct PeerContext *peer_ctx; - - if (0 == GNUNET_CRYPTO_cmp_peer_identity (peer, own_identity)) - { - return; /* We know that we are online */ - } - - peer_ctx = create_or_get_peer_ctx (peer); - // TODO if LIVE/ONLINE - check_peer_live (peer_ctx); -} - /** * @brief Send a message to another peer. * diff --git a/src/rps/gnunet-service-rps_peers.h b/src/rps/gnunet-service-rps_peers.h index a6018265c..abb5d831a 100644 --- a/src/rps/gnunet-service-rps_peers.h +++ b/src/rps/gnunet-service-rps_peers.h @@ -169,7 +169,7 @@ Peers_insert_peer (const struct GNUNET_PeerIdentity *peer); * peer was #own_identity) */ int -Peers_check_peer_live (const struct GNUNET_PeerIdentity *peer); +Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer); /** * @brief Remove unecessary data @@ -380,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. * -- cgit v1.2.3