gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 02/02: rps: deal with currently unused code


From: gnunet
Subject: [gnunet] 02/02: rps: deal with currently unused code
Date: Mon, 16 Nov 2020 23:59:07 +0100

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a commit to branch master
in repository gnunet.

commit 91e8c2ff26ab0f65bbfec3de0b4acbaa95e52a47
Author: Julius B√ľnger <buenger@mytum.de>
AuthorDate: Mon Nov 16 23:57:08 2020 +0100

    rps: deal with currently unused code
---
 src/rps/gnunet-rps-profiler.c | 209 +++++++++++++++---------------------------
 src/rps/gnunet-service-rps.c  |   2 +
 src/rps/rps-sampler_client.c  |  66 ++++++-------
 3 files changed, 109 insertions(+), 168 deletions(-)

diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 7d6bf407f..0ec2fec71 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -59,10 +59,10 @@ static struct GNUNET_TIME_Relative duration;
 static struct GNUNET_TIME_Relative timeout;
 
 
-/**
- * Portion of malicious peers
- */
-static double portion = .1;
+// /**
+//  * Portion of malicious peers
+//  */
+// static double portion = .1;
 
 /**
  * Type of malicious peer to test
@@ -1228,29 +1228,6 @@ post_test_op (void *cls)
 }
 
 
-/**
- * Seed peers.
- */
-static void
-seed_peers (void *cls)
-{
-  struct RPSPeer *peer = cls;
-  unsigned int amount;
-  unsigned int i;
-
-  // TODO if malicious don't seed mal peers
-  amount = round (.5 * num_peers);
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding peers:\n");
-  for (i = 0; i < amount; i++)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding %u. peer: %s\n",
-                i,
-                GNUNET_i2s (&rps_peer_ids[i]));
-
-  GNUNET_RPS_seed_ids (peer->rps_handle, amount, rps_peer_ids);
-}
-
-
 /**
  * Get the id of peer i.
  */
@@ -1635,76 +1612,76 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer)
 * MALICIOUS
 ***********************************/
 
-/**
- * Initialise only non-mal RPSPeers
- */
-static void
-mal_init_peer (struct RPSPeer *rps_peer)
-{
-  if (rps_peer->index >= round (portion * num_peers))
-    rps_peer->num_ids_to_request = 1;
-}
-
-
-/**
- * @brief Set peers to (non-)malicious before execution
- *
- * Of signature #PreTest
- *
- * @param rps_peer the peer to set (non-) malicious
- * @param h the handle to the service
- */
-static void
-mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
-{
-  #if ENABLE_MALICIOUS
-  uint32_t num_mal_peers;
-
-  GNUNET_assert ((1 >= portion) &&
-                 (0 < portion));
-  num_mal_peers = round (portion * num_peers);
-
-  if (rps_peer->index < num_mal_peers)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "%u. peer [%s] of %" PRIu32
-                " malicious peers turning malicious\n",
-                rps_peer->index,
-                GNUNET_i2s (rps_peer->peer_id),
-                num_mal_peers);
-
-    GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers,
-                              rps_peer_ids, target_peer);
-  }
-  #endif /* ENABLE_MALICIOUS */
-}
-
-
-static void
-mal_cb (struct RPSPeer *rps_peer)
-{
-  if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
-  {
-    return;
-  }
-
-  #if ENABLE_MALICIOUS
-  uint32_t num_mal_peers;
-
-  GNUNET_assert ((1 >= portion) &&
-                 (0 < portion));
-  num_mal_peers = round (portion * num_peers);
-
-  if (rps_peer->index >= num_mal_peers)
-  {   /* It's useless to ask a malicious peer about a random sample -
-         it's not sampling */
-    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
-                                    GNUNET_TIME_UNIT_SECONDS, 2),
-                                  seed_peers, rps_peer);
-    schedule_missing_requests (rps_peer);
-  }
-  #endif /* ENABLE_MALICIOUS */
-}
+///**
+// * Initialise only non-mal RPSPeers
+// */
+//static void
+//mal_init_peer (struct RPSPeer *rps_peer)
+//{
+//  if (rps_peer->index >= round (portion * num_peers))
+//    rps_peer->num_ids_to_request = 1;
+//}
+
+
+///**
+// * @brief Set peers to (non-)malicious before execution
+// *
+// * Of signature #PreTest
+// *
+// * @param rps_peer the peer to set (non-) malicious
+// * @param h the handle to the service
+// */
+//static void
+//mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
+//{
+//  #if ENABLE_MALICIOUS
+//  uint32_t num_mal_peers;
+//
+//  GNUNET_assert ((1 >= portion) &&
+//                 (0 < portion));
+//  num_mal_peers = round (portion * num_peers);
+//
+//  if (rps_peer->index < num_mal_peers)
+//  {
+//    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+//                "%u. peer [%s] of %" PRIu32
+//                " malicious peers turning malicious\n",
+//                rps_peer->index,
+//                GNUNET_i2s (rps_peer->peer_id),
+//                num_mal_peers);
+//
+//    GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers,
+//                              rps_peer_ids, target_peer);
+//  }
+//  #endif /* ENABLE_MALICIOUS */
+//}
+
+
+// static void
+// mal_cb (struct RPSPeer *rps_peer)
+// {
+//   if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
+//   {
+//     return;
+//   }
+// 
+//   #if ENABLE_MALICIOUS
+//   uint32_t num_mal_peers;
+// 
+//   GNUNET_assert ((1 >= portion) &&
+//                  (0 < portion));
+//   num_mal_peers = round (portion * num_peers);
+// 
+//   if (rps_peer->index >= num_mal_peers)
+//   {   /* It's useless to ask a malicious peer about a random sample -
+//          it's not sampling */
+//     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
+//                                     GNUNET_TIME_UNIT_SECONDS, 2),
+//                                   seed_peers, rps_peer);
+//     schedule_missing_requests (rps_peer);
+//   }
+//   #endif /* ENABLE_MALICIOUS */
+// }
 
 
 /***********************************
@@ -1714,44 +1691,6 @@ mal_cb (struct RPSPeer *rps_peer)
 static void
 churn (void *cls);
 
-/**
- * @brief Starts churn
- *
- * Has signature of #MainTest
- *
- * This is not implemented too nicely as this is called for each peer, but we
- * only need to call it once. (Yes we check that we only schedule the task
- * once.)
- *
- * @param rps_peer The peer it's called for
- */
-static void
-churn_test_cb (struct RPSPeer *rps_peer)
-{
-  if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
-  {
-    return;
-  }
-
-  /* Start churn */
-  if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Starting churn task\n");
-    churn_task = GNUNET_SCHEDULER_add_delayed (
-      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
-      churn,
-      NULL);
-  }
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Not starting churn task\n");
-  }
-
-  schedule_missing_requests (rps_peer);
-}
-
 
 /***********************************
 * PROFILER
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 48b5194c8..dc4c5dab7 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -2466,6 +2466,7 @@ resize_wrapper (struct RPS_Sampler *sampler, uint32_t 
new_size)
 }
 
 
+#if ENABLE_MALICIOUS
 /**
  * Add all peers in @a peer_array to @a peer_map used as set.
  *
@@ -2502,6 +2503,7 @@ add_peer_array_to_set (const struct GNUNET_PeerIdentity 
*peer_array,
     }
   }
 }
+#endif /* ENABLE_MALICIOUS */
 
 
 /**
diff --git a/src/rps/rps-sampler_client.c b/src/rps/rps-sampler_client.c
index 714943b51..f6e98ce29 100644
--- a/src/rps/rps-sampler_client.c
+++ b/src/rps/rps-sampler_client.c
@@ -258,39 +258,39 @@ RPS_sampler_mod_init (size_t init_size,
 }
 
 
-/**
- * @brief Compute the probability that we already observed all peers from a
- * biased stream of peer ids.
- *
- * Deficiency factor:
- * As introduced by Brahms: Factor between the number of unique ids in a
- * truly random stream and number of unique ids in the gossip stream.
- *
- * @param num_peers_estim The estimated number of peers in the network
- * @param num_peers_observed The number of peers the given element has observed
- * @param deficiency_factor A factor that catches the 'bias' of a random stream
- * of peer ids
- *
- * @return The estimated probability
- */
-static double
-prob_observed_n_peers (uint32_t num_peers_estim,
-                       uint32_t num_peers_observed,
-                       double deficiency_factor)
-{
-  uint32_t num_peers = num_peers_estim * (1 / deficiency_factor);
-  uint64_t sum = 0;
-
-  for (uint32_t i = 0; i < num_peers; i++)
-  {
-    uint64_t a = pow (-1, num_peers - i);
-    uint64_t b = binom (num_peers, i);
-    uint64_t c = pow (i, num_peers_observed);
-    sum += a * b * c;
-  }
-
-  return sum / (double) pow (num_peers, num_peers_observed);
-}
+// /**
+//  * @brief Compute the probability that we already observed all peers from a
+//  * biased stream of peer ids.
+//  *
+//  * Deficiency factor:
+//  * As introduced by Brahms: Factor between the number of unique ids in a
+//  * truly random stream and number of unique ids in the gossip stream.
+//  *
+//  * @param num_peers_estim The estimated number of peers in the network
+//  * @param num_peers_observed The number of peers the given element has 
observed
+//  * @param deficiency_factor A factor that catches the 'bias' of a random 
stream
+//  * of peer ids
+//  *
+//  * @return The estimated probability
+//  */
+// static double
+// prob_observed_n_peers (uint32_t num_peers_estim,
+//                        uint32_t num_peers_observed,
+//                        double deficiency_factor)
+// {
+//   uint32_t num_peers = num_peers_estim * (1 / deficiency_factor);
+//   uint64_t sum = 0;
+// 
+//   for (uint32_t i = 0; i < num_peers; i++)
+//   {
+//     uint64_t a = pow (-1, num_peers - i);
+//     uint64_t b = binom (num_peers, i);
+//     uint64_t c = pow (i, num_peers_observed);
+//     sum += a * b * c;
+//   }
+// 
+//   return sum / (double) pow (num_peers, num_peers_observed);
+// }
 
 
 /**

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]