aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2016-05-12 08:58:20 +0000
committerJulius Bünger <buenger@mytum.de>2016-05-12 08:58:20 +0000
commit2ffa3a95dae5f16350dadb1a42bf78cbd47d5e80 (patch)
tree2f2aa2d4cc46db8204d0f0d4d0c5905b8d2a39a7 /src/rps
parent58a56562f1d4d8c375144149690951b3ea6c36ec (diff)
downloadgnunet-2ffa3a95dae5f16350dadb1a42bf78cbd47d5e80.tar.gz
gnunet-2ffa3a95dae5f16350dadb1a42bf78cbd47d5e80.zip
-rps: restructure service internals
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 91d4840bb..8f25b269d 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -646,17 +646,20 @@ insert_in_pull_map (void *cls,
646 * Insert PeerID in #view 646 * Insert PeerID in #view
647 * 647 *
648 * Called once we know a peer is live. 648 * Called once we know a peer is live.
649 * Implements #PeerOp
649 */ 650 */
650static void 651static void
651insert_in_view (void *cls, 652insert_in_view (void *cls,
652 const struct GNUNET_PeerIdentity *peer) 653 const struct GNUNET_PeerIdentity *peer)
653{ 654{
655 GNUNET_assert (GNUNET_YES == Peers_check_peer_flag (peer, Peers_ONLINE));
654 View_put (peer); 656 View_put (peer);
655} 657}
656 658
657 659
658/** 660/**
659 * Update sampler with given PeerID. 661 * Update sampler with given PeerID.
662 * Implements #PeerOp
660 */ 663 */
661static void 664static void
662insert_in_sampler (void *cls, 665insert_in_sampler (void *cls,
@@ -678,6 +681,23 @@ insert_in_sampler (void *cls,
678 } 681 }
679} 682}
680 683
684/**
685 * @brief If @a peer was unknown, check liveliness and insert it in view and
686 * sampler
687 *
688 * @param peer peer to insert
689 */
690static void
691got_peer (const struct GNUNET_PeerIdentity *peer)
692{
693 /* If we did not know this peer already, insert it into sampler and view */
694 if (GNUNET_YES == Peers_insert_peer_check_liveliness (peer))
695 {
696 Peers_schedule_operation (peer, insert_in_sampler);
697 Peers_schedule_operation (peer, insert_in_view);
698 }
699}
700
681 701
682/** 702/**
683 * @brief Checks if there is a sending channel and if it is needed 703 * @brief Checks if there is a sending channel and if it is needed
@@ -1117,11 +1137,7 @@ handle_client_seed (void *cls,
1117 i, 1137 i,
1118 GNUNET_i2s (&peers[i])); 1138 GNUNET_i2s (&peers[i]));
1119 1139
1120 if (GNUNET_YES == Peers_insert_peer_check_liveliness (&peers[i])) 1140 got_peer (&peers[i]);
1121 {
1122 Peers_schedule_operation (&peers[i], insert_in_sampler);
1123 Peers_schedule_operation (&peers[i], insert_in_view);
1124 }
1125 1141
1126 //RPS_sampler_update (prot_sampler, &peers[i]); 1142 //RPS_sampler_update (prot_sampler, &peers[i]);
1127 //RPS_sampler_update (client_sampler, &peers[i]); 1143 //RPS_sampler_update (client_sampler, &peers[i]);
@@ -1995,9 +2011,7 @@ init_peer_cb (void *cls,
1995 LOG (GNUNET_ERROR_TYPE_DEBUG, 2011 LOG (GNUNET_ERROR_TYPE_DEBUG,
1996 "Got peer_id %s from cadet\n", 2012 "Got peer_id %s from cadet\n",
1997 GNUNET_i2s (peer)); 2013 GNUNET_i2s (peer));
1998 Peers_insert_peer_check_liveliness (peer); 2014 got_peer (peer);
1999 Peers_schedule_operation (peer, insert_in_sampler);
2000 Peers_schedule_operation (peer, insert_in_view);
2001 } 2015 }
2002} 2016}
2003 2017
@@ -2021,9 +2035,7 @@ process_peerinfo_peers (void *cls,
2021 LOG (GNUNET_ERROR_TYPE_DEBUG, 2035 LOG (GNUNET_ERROR_TYPE_DEBUG,
2022 "Got peer_id %s from peerinfo\n", 2036 "Got peer_id %s from peerinfo\n",
2023 GNUNET_i2s (peer)); 2037 GNUNET_i2s (peer));
2024 Peers_insert_peer_check_liveliness (peer); 2038 got_peer (peer);
2025 Peers_schedule_operation (peer, insert_in_sampler);
2026 Peers_schedule_operation (peer, insert_in_view);
2027 } 2039 }
2028} 2040}
2029 2041