diff options
author | Julius Bünger <buenger@mytum.de> | 2016-06-13 22:46:05 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2016-06-13 22:46:05 +0000 |
commit | f992fd2bc8ffa761d02549c1da8df4cb6e1877bc (patch) | |
tree | 954bb31470cb817a4d259b2ac583a50f671e36ee /src | |
parent | 88a38a7538d038b6d0febca509e934aaac4bc6f8 (diff) | |
download | gnunet-f992fd2bc8ffa761d02549c1da8df4cb6e1877bc.tar.gz gnunet-f992fd2bc8ffa761d02549c1da8df4cb6e1877bc.zip |
-rps: merge duplicate functions
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 26 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps_peers.c | 25 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps_peers.h | 13 |
3 files changed, 12 insertions, 52 deletions
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) | |||
466 | if ( (GNUNET_NO == online) || | 466 | if ( (GNUNET_NO == online) || |
467 | (GNUNET_SYSERR == online) ) /* peer is not even known */ | 467 | (GNUNET_SYSERR == online) ) /* peer is not even known */ |
468 | { | 468 | { |
469 | (void) Peers_check_peer_live (peer); | 469 | (void) Peers_issue_peer_liveliness_check (peer); |
470 | (void) Peers_schedule_operation (peer, insert_in_view_op); | 470 | (void) Peers_schedule_operation (peer, insert_in_view_op); |
471 | return GNUNET_NO; | 471 | return GNUNET_NO; |
472 | } | 472 | } |
@@ -704,11 +704,10 @@ insert_in_sampler (void *cls, | |||
704 | if (0 < RPS_sampler_count_id (prot_sampler, peer)) | 704 | if (0 < RPS_sampler_count_id (prot_sampler, peer)) |
705 | { | 705 | { |
706 | /* Make sure we 'know' about this peer */ | 706 | /* Make sure we 'know' about this peer */ |
707 | (void) Peers_check_peer_live (peer); | 707 | (void) Peers_issue_peer_liveliness_check (peer); |
708 | /* Establish a channel towards that peer to indicate we are going to send | 708 | /* Establish a channel towards that peer to indicate we are going to send |
709 | * messages to it */ | 709 | * messages to it */ |
710 | Peers_indicate_sending_intention (peer); | 710 | //Peers_indicate_sending_intention (peer); |
711 | //Peers_issue_peer_liveliness_check (peer); | ||
712 | } | 711 | } |
713 | } | 712 | } |
714 | 713 | ||
@@ -722,7 +721,7 @@ static void | |||
722 | got_peer (const struct GNUNET_PeerIdentity *peer) | 721 | got_peer (const struct GNUNET_PeerIdentity *peer) |
723 | { | 722 | { |
724 | /* If we did not know this peer already, insert it into sampler and view */ | 723 | /* If we did not know this peer already, insert it into sampler and view */ |
725 | if (GNUNET_YES == Peers_check_peer_live (peer)) | 724 | if (GNUNET_YES == Peers_issue_peer_liveliness_check (peer)) |
726 | { | 725 | { |
727 | Peers_schedule_operation (peer, insert_in_sampler); | 726 | Peers_schedule_operation (peer, insert_in_sampler); |
728 | Peers_schedule_operation (peer, insert_in_view_op); | 727 | Peers_schedule_operation (peer, insert_in_view_op); |
@@ -1417,7 +1416,7 @@ handle_peer_pull_reply (void *cls, | |||
1417 | &peers[i])) | 1416 | &peers[i])) |
1418 | { | 1417 | { |
1419 | /* Make sure we 'know' about this peer */ | 1418 | /* Make sure we 'know' about this peer */ |
1420 | (void) Peers_check_peer_live (&peers[i]); | 1419 | (void) Peers_insert_peer (&peers[i]); |
1421 | 1420 | ||
1422 | if (GNUNET_YES == Peers_check_peer_valid (&peers[i])) | 1421 | if (GNUNET_YES == Peers_check_peer_valid (&peers[i])) |
1423 | { | 1422 | { |
@@ -1426,7 +1425,7 @@ handle_peer_pull_reply (void *cls, | |||
1426 | else | 1425 | else |
1427 | { | 1426 | { |
1428 | Peers_schedule_operation (&peers[i], insert_in_pull_map); | 1427 | Peers_schedule_operation (&peers[i], insert_in_pull_map); |
1429 | Peers_issue_peer_liveliness_check (&peers[i]); | 1428 | (void) Peers_issue_peer_liveliness_check (&peers[i]); |
1430 | } | 1429 | } |
1431 | } | 1430 | } |
1432 | } | 1431 | } |
@@ -1636,8 +1635,7 @@ handle_client_act_malicious (void *cls, | |||
1636 | /* Set the flag of the attacked peer to valid to avoid problems */ | 1635 | /* Set the flag of the attacked peer to valid to avoid problems */ |
1637 | if (GNUNET_NO == Peers_check_peer_known (&attacked_peer)) | 1636 | if (GNUNET_NO == Peers_check_peer_known (&attacked_peer)) |
1638 | { | 1637 | { |
1639 | Peers_check_peer_live (&attacked_peer); | 1638 | (void) Peers_issue_peer_liveliness_check (&attacked_peer); |
1640 | Peers_issue_peer_liveliness_check (&attacked_peer); | ||
1641 | } | 1639 | } |
1642 | 1640 | ||
1643 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1641 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1727,7 +1725,7 @@ do_mal_round (void *cls) | |||
1727 | * Send as many pushes to the attacked peer as possible | 1725 | * Send as many pushes to the attacked peer as possible |
1728 | * That is one push per round as it will ignore more. | 1726 | * That is one push per round as it will ignore more. |
1729 | */ | 1727 | */ |
1730 | Peers_check_peer_live (&attacked_peer); | 1728 | (void) Peers_issue_peer_liveliness_check (&attacked_peer); |
1731 | if (GNUNET_YES == Peers_check_peer_valid (&attacked_peer)) | 1729 | if (GNUNET_YES == Peers_check_peer_valid (&attacked_peer)) |
1732 | send_push (&attacked_peer); | 1730 | send_push (&attacked_peer); |
1733 | } | 1731 | } |
@@ -1739,7 +1737,7 @@ do_mal_round (void *cls) | |||
1739 | /* Send PUSH to attacked peers */ | 1737 | /* Send PUSH to attacked peers */ |
1740 | if (GNUNET_YES == Peers_check_peer_known (&attacked_peer)) | 1738 | if (GNUNET_YES == Peers_check_peer_known (&attacked_peer)) |
1741 | { | 1739 | { |
1742 | Peers_check_peer_live (&attacked_peer); | 1740 | (void) Peers_issue_peer_liveliness_check (&attacked_peer); |
1743 | if (GNUNET_YES == Peers_check_peer_valid (&attacked_peer)) | 1741 | if (GNUNET_YES == Peers_check_peer_valid (&attacked_peer)) |
1744 | { | 1742 | { |
1745 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1743 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1747,12 +1745,8 @@ do_mal_round (void *cls) | |||
1747 | GNUNET_i2s (&attacked_peer)); | 1745 | GNUNET_i2s (&attacked_peer)); |
1748 | send_push (&attacked_peer); | 1746 | send_push (&attacked_peer); |
1749 | } | 1747 | } |
1750 | else | ||
1751 | Peers_issue_peer_liveliness_check (&attacked_peer); | ||
1752 | } | 1748 | } |
1753 | else | 1749 | (void) Peers_issue_peer_liveliness_check (&attacked_peer); |
1754 | Peers_check_peer_live (&attacked_peer); | ||
1755 | Peers_issue_peer_liveliness_check (&attacked_peer); | ||
1756 | 1750 | ||
1757 | /* The maximum of pushes we're going to send this round */ | 1751 | /* The maximum of pushes we're going to send this round */ |
1758 | num_pushes = GNUNET_MIN (GNUNET_MIN (push_limit - 1, | 1752 | 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) | |||
1020 | * peer was #own_identity) | 1020 | * peer was #own_identity) |
1021 | */ | 1021 | */ |
1022 | int | 1022 | int |
1023 | Peers_check_peer_live (const struct GNUNET_PeerIdentity *peer) | 1023 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) |
1024 | { | 1024 | { |
1025 | struct PeerContext *peer_ctx; | 1025 | struct PeerContext *peer_ctx; |
1026 | int ret; | 1026 | int ret; |
@@ -1521,29 +1521,6 @@ Peers_cleanup_destroyed_channel (void *cls, | |||
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | /** | 1523 | /** |
1524 | * @brief Issue a check whether peer is live | ||
1525 | * | ||
1526 | * This tries to establish a channel to the given peer. Once the channel is | ||
1527 | * established successfully, we know the peer is live. | ||
1528 | * | ||
1529 | * @param peer the peer to check liveliness | ||
1530 | */ | ||
1531 | void | ||
1532 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) | ||
1533 | { | ||
1534 | struct PeerContext *peer_ctx; | ||
1535 | |||
1536 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (peer, own_identity)) | ||
1537 | { | ||
1538 | return; /* We know that we are online */ | ||
1539 | } | ||
1540 | |||
1541 | peer_ctx = create_or_get_peer_ctx (peer); | ||
1542 | // TODO if LIVE/ONLINE | ||
1543 | check_peer_live (peer_ctx); | ||
1544 | } | ||
1545 | |||
1546 | /** | ||
1547 | * @brief Send a message to another peer. | 1524 | * @brief Send a message to another peer. |
1548 | * | 1525 | * |
1549 | * Keeps track about pending messages so they can be properly removed when the | 1526 | * Keeps track about pending messages so they can be properly removed when the |
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); | |||
169 | * peer was #own_identity) | 169 | * peer was #own_identity) |
170 | */ | 170 | */ |
171 | int | 171 | int |
172 | Peers_check_peer_live (const struct GNUNET_PeerIdentity *peer); | 172 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer); |
173 | 173 | ||
174 | /** | 174 | /** |
175 | * @brief Remove unecessary data | 175 | * @brief Remove unecessary data |
@@ -381,17 +381,6 @@ Peers_cleanup_destroyed_channel (void *cls, | |||
381 | void *channel_ctx); | 381 | void *channel_ctx); |
382 | 382 | ||
383 | /** | 383 | /** |
384 | * @brief Issue a check whether peer is live | ||
385 | * | ||
386 | * This tries to establish a channel to the given peer. Once the channel is | ||
387 | * established successfully, we know the peer is live. | ||
388 | * | ||
389 | * @param peer the peer to check liveliness | ||
390 | */ | ||
391 | void | ||
392 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer); | ||
393 | |||
394 | /** | ||
395 | * @brief Send a message to another peer. | 384 | * @brief Send a message to another peer. |
396 | * | 385 | * |
397 | * Keeps track about pending messages so they can be properly removed when the | 386 | * Keeps track about pending messages so they can be properly removed when the |