gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (b1920f975 -> 4ac7b35eb)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (b1920f975 -> 4ac7b35eb)
Date: Mon, 01 Oct 2018 23:16:23 +0200

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

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

    from b1920f975 urlencode base64
     new c8e4a6600 Rename "live" -> online
     new b3aad5bef Change architecture of service (towards subsampling)
     new 3823c7a71 Restructure implementation of view (towards subsampling)
     new 4ac7b35eb Change terminology: "live" -> "online"

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/rps/gnunet-service-rps.c      | 1203 +++++++++++++++++++------------------
 src/rps/gnunet-service-rps_view.c |  160 +++--
 src/rps/gnunet-service-rps_view.h |   51 +-
 src/rps/test_service_rps_view.c   |  141 ++---
 4 files changed, 828 insertions(+), 727 deletions(-)

diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index f20f49492..07b88ddcd 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -51,30 +51,6 @@
 
 // hist_size_init, hist_size_max
 
-/**
- * Our configuration.
- */
-static const struct GNUNET_CONFIGURATION_Handle *cfg;
-
-/**
- * Handle to the statistics service.
- */
-struct GNUNET_STATISTICS_Handle *stats;
-
-/**
- * Our own identity.
- */
-static struct GNUNET_PeerIdentity own_identity;
-
-static int in_shutdown = GNUNET_NO;
-
-/**
- * @brief Port used for cadet.
- *
- * Don't compute multiple times through making it global
- */
-static struct GNUNET_HashCode port;
-
 /***********************************************************************
  * Old gnunet-service-rps_peers.c
 ***********************************************************************/
@@ -168,7 +144,7 @@ struct ChannelCtx;
  * This is stored in a multipeermap.
  * It contains information such as cadet channels, a message queue for sending,
  * status about the channels, the pending operations on this peer and some 
flags
- * about the status of the peer itself. (live, valid, ...)
+ * about the status of the peer itself. (online, valid, ...)
  */
 struct PeerContext
 {
@@ -197,7 +173,7 @@ struct PeerContext
    *
    * To be canceled on shutdown.
    */
-  struct PendingMessage *liveliness_check_pending;
+  struct PendingMessage *online_check_pending;
 
   /**
    * Number of pending operations.
@@ -276,31 +252,282 @@ struct ChannelCtx
   struct GNUNET_SCHEDULER_Task *destruction_task;
 };
 
+
+#ifdef ENABLE_MALICIOUS
+
 /**
- * @brief Hashmap of valid peers.
+ * If type is 2 This struct is used to store the attacked peers in a DLL
  */
-static struct GNUNET_CONTAINER_MultiPeerMap *valid_peers;
+struct AttackedPeer
+{
+  /**
+   * DLL
+   */
+  struct AttackedPeer *next;
+  struct AttackedPeer *prev;
+
+  /**
+   * PeerID
+   */
+  struct GNUNET_PeerIdentity peer_id;
+};
+
+#endif /* ENABLE_MALICIOUS */
 
 /**
- * @brief Maximum number of valid peers to keep.
- * TODO read from config
+ * @brief One SubSampler.
+ *
+ * Essentially one instance of brahms that only connects to other instances
+ * with the same (secret) value.
  */
-static uint32_t num_valid_peers_max = UINT32_MAX;
+struct SubSampler
+{
+  /**
+   * @brief Port used for cadet.
+   *
+   * Don't compute multiple times through making it global
+   */
+  struct GNUNET_HashCode port;
+
+  /**
+   * Handler to CADET.
+   */
+  struct GNUNET_CADET_Handle *cadet_handle;
+
+  /**
+   * @brief Port to communicate to other peers.
+   */
+  struct GNUNET_CADET_Port *cadet_port;
+
+  /**
+   * @brief Hashmap of valid peers.
+   */
+  struct GNUNET_CONTAINER_MultiPeerMap *valid_peers;
+
+  /**
+   * @brief Filename of the file that stores the valid peers persistently.
+   */
+  char *filename_valid_peers;
+
+  /**
+   * Set of all peers to keep track of them.
+   */
+  struct GNUNET_CONTAINER_MultiPeerMap *peer_map;
+
+  /**
+   * @brief This is the minimum estimate used as sampler size.
+   *
+   * It is configured by the user.
+   */
+  unsigned int sampler_size_est_min;
+
+  /**
+   * The size of sampler we need to be able to satisfy the Brahms protocol's
+   * need of random peers.
+   *
+   * This is one minimum size the sampler grows to.
+   */
+  unsigned int sampler_size_est_need;
+
+  /**
+   * Time inverval the do_round task runs in.
+   */
+  struct GNUNET_TIME_Relative round_interval;
+
+  /**
+   * Sampler used for the Brahms protocol itself.
+   */
+  struct RPS_Sampler *sampler;
+
+  /**
+   * Name to log view to
+   */
+  char *file_name_view_log;
+
+#ifdef TO_FILE
+  /**
+   * Name to log number of observed peers to
+   */
+  char *file_name_observed_log;
+
+  /**
+   * @brief Count the observed peers
+   */
+  uint32_t num_observed_peers;
+
+  /**
+   * @brief Multipeermap (ab-) used to count unique peer_ids
+   */
+  struct GNUNET_CONTAINER_MultiPeerMap *observed_unique_peers;
+#endif /* TO_FILE */
+
+  /**
+   * List to store peers received through pushes temporary.
+   */
+  struct CustomPeerMap *push_map;
+
+  /**
+   * List to store peers received through pulls temporary.
+   */
+  struct CustomPeerMap *pull_map;
+
+  /**
+   * @brief This is the estimate used as view size.
+   *
+   * It is initialised with the minimum
+   */
+  unsigned int view_size_est_need;
+
+  /**
+   * @brief This is the minimum estimate used as view size.
+   *
+   * It is configured by the user.
+   */
+  unsigned int view_size_est_min;
+
+  /**
+   * @brief The view.
+   */
+  struct View *view;
+
+  /**
+   * Identifier for the main task that runs periodically.
+   */
+  struct GNUNET_SCHEDULER_Task *do_round_task;
+};
+
+
+/***********************************************************************
+ * Globals
+***********************************************************************/
 
 /**
- * @brief Filename of the file that stores the valid peers persistently.
+ * Our configuration.
  */
-static char *filename_valid_peers;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
 /**
- * Set of all peers to keep track of them.
+ * Handle to the statistics service.
  */
-static struct GNUNET_CONTAINER_MultiPeerMap *peer_map;
+struct GNUNET_STATISTICS_Handle *stats;
 
 /**
- * Cadet handle.
+ * Our own identity.
  */
-static struct GNUNET_CADET_Handle *cadet_handle;
+static struct GNUNET_PeerIdentity own_identity;
+
+/**
+ * Percentage of total peer number in the view
+ * to send random PUSHes to
+ */
+static float alpha;
+
+/**
+ * Percentage of total peer number in the view
+ * to send random PULLs to
+ */
+static float beta;
+
+/**
+ * Handler to NSE.
+ */
+static struct GNUNET_NSE_Handle *nse;
+
+/**
+ * Handler to PEERINFO.
+ */
+static struct GNUNET_PEERINFO_Handle *peerinfo_handle;
+
+/**
+ * Handle for cancellation of iteration over peers.
+ */
+static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle;
+
+
+#ifdef ENABLE_MALICIOUS
+/**
+ * Type of malicious peer
+ *
+ * 0 Don't act malicious at all - Default
+ * 1 Try to maximise representation
+ * 2 Try to partition the network
+ * 3 Combined attack
+ */
+static uint32_t mal_type;
+
+/**
+ * Other malicious peers
+ */
+static struct GNUNET_PeerIdentity *mal_peers;
+
+/**
+ * Hashmap of malicious peers used as set.
+ * Used to more efficiently check whether we know that peer.
+ */
+static struct GNUNET_CONTAINER_MultiPeerMap *mal_peer_set;
+
+/**
+ * Number of other malicious peers
+ */
+static uint32_t num_mal_peers;
+
+
+/**
+ * If type is 2 this is the DLL of attacked peers
+ */
+static struct AttackedPeer *att_peers_head;
+static struct AttackedPeer *att_peers_tail;
+
+/**
+ * This index is used to point to an attacked peer to
+ * implement the round-robin-ish way to select attacked peers.
+ */
+static struct AttackedPeer *att_peer_index;
+
+/**
+ * Hashmap of attacked peers used as set.
+ * Used to more efficiently check whether we know that peer.
+ */
+static struct GNUNET_CONTAINER_MultiPeerMap *att_peer_set;
+
+/**
+ * Number of attacked peers
+ */
+static uint32_t num_attacked_peers;
+
+/**
+ * If type is 1 this is the attacked peer
+ */
+static struct GNUNET_PeerIdentity attacked_peer;
+
+/**
+ * The limit of PUSHes we can send in one round.
+ * This is an assumption of the Brahms protocol and either implemented
+ * via proof of work
+ * or
+ * assumend to be the bandwidth limitation.
+ */
+static uint32_t push_limit = 10000;
+#endif /* ENABLE_MALICIOUS */
+
+/**
+ * @brief Main SubSampler.
+ *
+ * This is run in any case by all peers and connects to all peers without
+ * specifying a shared value.
+ */
+static struct SubSampler *mss;
+
+/**
+ * @brief Maximum number of valid peers to keep.
+ * TODO read from config
+ */
+static const uint32_t num_valid_peers_max = UINT32_MAX;
+
+
+/***********************************************************************
+ * /Globals
+***********************************************************************/
 
 
 /**
@@ -316,9 +543,9 @@ get_peer_ctx (const struct GNUNET_PeerIdentity *peer)
   struct PeerContext *ctx;
   int ret;
 
-  ret = GNUNET_CONTAINER_multipeermap_contains (peer_map, peer);
+  ret = GNUNET_CONTAINER_multipeermap_contains (mss->peer_map, peer);
   GNUNET_assert (GNUNET_YES == ret);
-  ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer);
+  ctx = GNUNET_CONTAINER_multipeermap_get (mss->peer_map, peer);
   GNUNET_assert (NULL != ctx);
   return ctx;
 }
@@ -336,9 +563,9 @@ get_peer_ctx (const struct GNUNET_PeerIdentity *peer)
 static int
 check_peer_known (const struct GNUNET_PeerIdentity *peer)
 {
-  if (NULL != peer_map)
+  if (NULL != mss->peer_map)
   {
-    return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer);
+    return GNUNET_CONTAINER_multipeermap_contains (mss->peer_map, peer);
   } else
   {
     return GNUNET_NO;
@@ -363,12 +590,12 @@ create_peer_ctx (const struct GNUNET_PeerIdentity *peer)
 
   ctx = GNUNET_new (struct PeerContext);
   ctx->peer_id = *peer;
-  ret = GNUNET_CONTAINER_multipeermap_put (peer_map, peer, ctx,
+  ret = GNUNET_CONTAINER_multipeermap_put (mss->peer_map, peer, ctx,
       GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
   GNUNET_assert (GNUNET_OK == ret);
   GNUNET_STATISTICS_set (stats,
                         "# known peers",
-                        GNUNET_CONTAINER_multipeermap_size (peer_map),
+                        GNUNET_CONTAINER_multipeermap_size (mss->peer_map),
                         GNUNET_NO);
   return ctx;
 }
@@ -496,7 +723,7 @@ get_random_peer_from_peermap (const struct
   iterator_cls = GNUNET_new (struct GetRandPeerIteratorCls);
   iterator_cls->index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
       GNUNET_CONTAINER_multipeermap_size (peer_map));
-  (void) GNUNET_CONTAINER_multipeermap_iterate (valid_peers,
+  (void) GNUNET_CONTAINER_multipeermap_iterate (mss->valid_peers,
                                                 get_rand_peer_iterator,
                                                 iterator_cls);
   ret = iterator_cls->peer;
@@ -522,17 +749,18 @@ add_valid_peer (const struct GNUNET_PeerIdentity *peer)
   int ret;
 
   ret = GNUNET_YES;
-  while (GNUNET_CONTAINER_multipeermap_size (valid_peers) >= 
num_valid_peers_max)
+  while (GNUNET_CONTAINER_multipeermap_size (
+        mss->valid_peers) >= num_valid_peers_max)
   {
-    rand_peer = get_random_peer_from_peermap (valid_peers);
-    GNUNET_CONTAINER_multipeermap_remove_all (valid_peers, rand_peer);
+    rand_peer = get_random_peer_from_peermap (mss->valid_peers);
+    GNUNET_CONTAINER_multipeermap_remove_all (mss->valid_peers, rand_peer);
     ret = GNUNET_NO;
   }
-  (void) GNUNET_CONTAINER_multipeermap_put (valid_peers, peer, NULL,
+  (void) GNUNET_CONTAINER_multipeermap_put (mss->valid_peers, peer, NULL,
       GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
   GNUNET_STATISTICS_set (stats,
                          "# valid peers",
-                         GNUNET_CONTAINER_multipeermap_size (valid_peers),
+                         GNUNET_CONTAINER_multipeermap_size (mss->valid_peers),
                          GNUNET_NO);
   return ret;
 }
@@ -546,29 +774,29 @@ remove_pending_message (struct PendingMessage 
*pending_msg, int cancel);
  *
  * Also adds peer to #valid_peers.
  *
- * @param peer_ctx the #PeerContext of the peer to set live
+ * @param peer_ctx the #PeerContext of the peer to set online
  */
 static void
-set_peer_live (struct PeerContext *peer_ctx)
+set_peer_online (struct PeerContext *peer_ctx)
 {
   struct GNUNET_PeerIdentity *peer;
   unsigned int i;
 
   peer = &peer_ctx->peer_id;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-      "Peer %s is live and valid, calling %i pending operations on it\n",
+      "Peer %s is online and valid, calling %i pending operations on it\n",
       GNUNET_i2s (peer),
       peer_ctx->num_pending_ops);
 
-  if (NULL != peer_ctx->liveliness_check_pending)
+  if (NULL != peer_ctx->online_check_pending)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Removing pending liveliness check for peer %s\n",
+         "Removing pending online check for peer %s\n",
          GNUNET_i2s (&peer_ctx->peer_id));
     // TODO wait until cadet sets mq->cancel_impl
-    //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
-    remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES);
-    peer_ctx->liveliness_check_pending = NULL;
+    //GNUNET_MQ_send_cancel (peer_ctx->online_check_pending->ev);
+    remove_pending_message (peer_ctx->online_check_pending, GNUNET_YES);
+    peer_ctx->online_check_pending = NULL;
   }
 
   (void) add_valid_peer (peer);
@@ -700,10 +928,10 @@ get_channel (const struct GNUNET_PeerIdentity *peer)
     *ctx_peer = *peer;
     peer_ctx->send_channel_ctx = add_channel_ctx (peer_ctx);
     peer_ctx->send_channel_ctx->channel =
-      GNUNET_CADET_channel_create (cadet_handle,
+      GNUNET_CADET_channel_create (mss->cadet_handle,
                                    peer_ctx->send_channel_ctx, /* context */
                                    peer,
-                                   &port,
+                                   &mss->port,
                                    GNUNET_CADET_OPTION_RELIABLE,
                                    NULL, /* WindowSize handler */
                                    &cleanup_destroyed_channel, /* Disconnect 
handler */
@@ -794,51 +1022,51 @@ remove_pending_message (struct PendingMessage 
*pending_msg, int cancel)
 
 /**
  * @brief This is called in response to the first message we sent as a
- * liveliness check.
+ * online check.
  *
- * @param cls #PeerContext of peer with pending liveliness check
+ * @param cls #PeerContext of peer with pending online check
  */
 static void
-mq_liveliness_check_successful (void *cls)
+mq_online_check_successful (void *cls)
 {
   struct PeerContext *peer_ctx = cls;
 
-  if (NULL != peer_ctx->liveliness_check_pending)
+  if (NULL != peer_ctx->online_check_pending)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Liveliness check for peer %s was successfull\n",
+        "Online check for peer %s was successfull\n",
         GNUNET_i2s (&peer_ctx->peer_id));
-    remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES);
-    peer_ctx->liveliness_check_pending = NULL;
-    set_peer_live (peer_ctx);
+    remove_pending_message (peer_ctx->online_check_pending, GNUNET_YES);
+    peer_ctx->online_check_pending = NULL;
+    set_peer_online (peer_ctx);
   }
 }
 
 /**
- * Issue a check whether peer is live
+ * Issue a check whether peer is online
  *
  * @param peer_ctx the context of the peer
  */
 static void
-check_peer_live (struct PeerContext *peer_ctx)
+check_peer_online (struct PeerContext *peer_ctx)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Get informed about peer %s getting live\n",
+       "Get informed about peer %s getting online\n",
        GNUNET_i2s (&peer_ctx->peer_id));
 
   struct GNUNET_MQ_Handle *mq;
   struct GNUNET_MQ_Envelope *ev;
 
   ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE);
-  peer_ctx->liveliness_check_pending =
-    insert_pending_message (&peer_ctx->peer_id, ev, "Check liveliness");
+  peer_ctx->online_check_pending =
+    insert_pending_message (&peer_ctx->peer_id, ev, "Check online");
   mq = get_mq (&peer_ctx->peer_id);
   GNUNET_MQ_notify_sent (ev,
-                         mq_liveliness_check_successful,
+                         mq_online_check_successful,
                          peer_ctx);
   GNUNET_MQ_send (mq, ev);
   GNUNET_STATISTICS_update (stats,
-                            "# pending liveliness checks",
+                            "# pending online checks",
                             1,
                             GNUNET_NO);
 }
@@ -945,9 +1173,9 @@ static int
 destroy_peer (struct PeerContext *peer_ctx)
 {
   GNUNET_assert (NULL != peer_ctx);
-  GNUNET_assert (NULL != peer_map);
+  GNUNET_assert (NULL != mss->peer_map);
   if (GNUNET_NO ==
-      GNUNET_CONTAINER_multipeermap_contains (peer_map,
+      GNUNET_CONTAINER_multipeermap_contains (mss->peer_map,
                                               &peer_ctx->peer_id))
   {
     return GNUNET_NO;
@@ -971,14 +1199,14 @@ destroy_peer (struct PeerContext *peer_ctx)
          "Removing unsent %s\n",
          peer_ctx->pending_messages_head->type);
     /* Cancle pending message, too */
-    if ( (NULL != peer_ctx->liveliness_check_pending) &&
+    if ( (NULL != peer_ctx->online_check_pending) &&
          (0 == memcmp (peer_ctx->pending_messages_head,
-                     peer_ctx->liveliness_check_pending,
+                     peer_ctx->online_check_pending,
                      sizeof (struct PendingMessage))) )
       {
-        peer_ctx->liveliness_check_pending = NULL;
+        peer_ctx->online_check_pending = NULL;
         GNUNET_STATISTICS_update (stats,
-                                  "# pending liveliness checks",
+                                  "# pending online checks",
                                   -1,
                                   GNUNET_NO);
       }
@@ -986,18 +1214,18 @@ destroy_peer (struct PeerContext *peer_ctx)
                             GNUNET_YES);
   }
 
-  /* If we are still waiting for notification whether this peer is live
+  /* If we are still waiting for notification whether this peer is online
    * cancel the according task */
-  if (NULL != peer_ctx->liveliness_check_pending)
+  if (NULL != peer_ctx->online_check_pending)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Removing pending liveliness check for peer %s\n",
+                "Removing pending online check for peer %s\n",
                 GNUNET_i2s (&peer_ctx->peer_id));
     // TODO wait until cadet sets mq->cancel_impl
-    //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
-    remove_pending_message (peer_ctx->liveliness_check_pending,
+    //GNUNET_MQ_send_cancel (peer_ctx->online_check_pending->ev);
+    remove_pending_message (peer_ctx->online_check_pending,
                             GNUNET_YES);
-    peer_ctx->liveliness_check_pending = NULL;
+    peer_ctx->online_check_pending = NULL;
   }
 
   if (NULL != peer_ctx->send_channel_ctx)
@@ -1017,15 +1245,15 @@ destroy_peer (struct PeerContext *peer_ctx)
   }
 
   if (GNUNET_YES !=
-      GNUNET_CONTAINER_multipeermap_remove_all (peer_map,
+      GNUNET_CONTAINER_multipeermap_remove_all (mss->peer_map,
                                                 &peer_ctx->peer_id))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         "removing peer from peer_map failed\n");
+         "removing peer from mss->peer_map failed\n");
   }
   GNUNET_STATISTICS_set (stats,
                         "# known peers",
-                        GNUNET_CONTAINER_multipeermap_size (peer_map),
+                        GNUNET_CONTAINER_multipeermap_size (mss->peer_map),
                         GNUNET_NO);
   GNUNET_free (peer_ctx);
   return GNUNET_YES;
@@ -1130,27 +1358,27 @@ store_valid_peers ()
   uint32_t number_written_peers;
   int ret;
 
-  if (0 == strncmp ("DISABLE", filename_valid_peers, 7))
+  if (0 == strncmp ("DISABLE", mss->filename_valid_peers, 7))
   {
     return;
   }
 
-  ret = GNUNET_DISK_directory_create_for_file (filename_valid_peers);
+  ret = GNUNET_DISK_directory_create_for_file (mss->filename_valid_peers);
   if (GNUNET_SYSERR == ret)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Not able to create directory for file `%s'\n",
-        filename_valid_peers);
+        mss->filename_valid_peers);
     GNUNET_break (0);
   }
   else if (GNUNET_NO == ret)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Directory for file `%s' exists but is not writable for us\n",
-        filename_valid_peers);
+        mss->filename_valid_peers);
     GNUNET_break (0);
   }
-  fh = GNUNET_DISK_file_open (filename_valid_peers,
+  fh = GNUNET_DISK_file_open (mss->filename_valid_peers,
                               GNUNET_DISK_OPEN_WRITE |
                                   GNUNET_DISK_OPEN_CREATE,
                               GNUNET_DISK_PERM_USER_READ |
@@ -1159,19 +1387,19 @@ store_valid_peers ()
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Not able to write valid peers to file `%s'\n",
-        filename_valid_peers);
+        mss->filename_valid_peers);
     return;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
       "Writing %u valid peers to disk\n",
-      GNUNET_CONTAINER_multipeermap_size (valid_peers));
+      GNUNET_CONTAINER_multipeermap_size (mss->valid_peers));
   number_written_peers =
-    GNUNET_CONTAINER_multipeermap_iterate (valid_peers,
+    GNUNET_CONTAINER_multipeermap_iterate (mss->valid_peers,
                                            store_peer_presistently_iterator,
                                            fh);
   GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
   GNUNET_assert (number_written_peers ==
-      GNUNET_CONTAINER_multipeermap_size (valid_peers));
+      GNUNET_CONTAINER_multipeermap_size (mss->valid_peers));
 }
 
 
@@ -1236,16 +1464,16 @@ restore_valid_peers ()
   char *str_repr;
   const struct GNUNET_PeerIdentity *peer;
 
-  if (0 == strncmp ("DISABLE", filename_valid_peers, 7))
+  if (0 == strncmp ("DISABLE", mss->filename_valid_peers, 7))
   {
     return;
   }
 
-  if (GNUNET_OK != GNUNET_DISK_file_test (filename_valid_peers))
+  if (GNUNET_OK != GNUNET_DISK_file_test (mss->filename_valid_peers))
   {
     return;
   }
-  fh = GNUNET_DISK_file_open (filename_valid_peers,
+  fh = GNUNET_DISK_file_open (mss->filename_valid_peers,
                               GNUNET_DISK_OPEN_READ,
                               GNUNET_DISK_PERM_NONE);
   GNUNET_assert (NULL != fh);
@@ -1257,7 +1485,7 @@ restore_valid_peers ()
   LOG (GNUNET_ERROR_TYPE_DEBUG,
       "Restoring %" PRIu32 " peers from file `%s'\n",
       num_peers,
-      filename_valid_peers);
+      mss->filename_valid_peers);
   for (iter_buf = buf; iter_buf < buf + file_size - 1; iter_buf += 53)
   {
     str_repr = GNUNET_strndup (iter_buf, 53);
@@ -1271,10 +1499,10 @@ restore_valid_peers ()
   iter_buf = NULL;
   GNUNET_free (buf);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-      "num_peers: %" PRIu32 ", _size (valid_peers): %u\n",
+      "num_peers: %" PRIu32 ", _size (mss->valid_peers): %u\n",
       num_peers,
-      GNUNET_CONTAINER_multipeermap_size (valid_peers));
-  if (num_peers != GNUNET_CONTAINER_multipeermap_size (valid_peers))
+      GNUNET_CONTAINER_multipeermap_size (mss->valid_peers));
+  if (num_peers != GNUNET_CONTAINER_multipeermap_size (mss->valid_peers))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Number of restored peers does not match file size. Have probably 
duplicates.\n");
@@ -1282,26 +1510,7 @@ restore_valid_peers ()
   GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
   LOG (GNUNET_ERROR_TYPE_DEBUG,
       "Restored %u valid peers from disk\n",
-      GNUNET_CONTAINER_multipeermap_size (valid_peers));
-}
-
-
-/**
- * @brief Initialise storage of peers
- *
- * @param fn_valid_peers filename of the file used to store valid peer ids
- * @param cadet_h cadet handle
- * @param own_id own peer identity
- */
-static void
-initialise_peers (char* fn_valid_peers,
-                  struct GNUNET_CADET_Handle *cadet_h)
-{
-  filename_valid_peers = GNUNET_strdup (fn_valid_peers);
-  cadet_handle = cadet_h;
-  peer_map = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO);
-  valid_peers = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO);
-  restore_valid_peers ();
+      GNUNET_CONTAINER_multipeermap_size (mss->valid_peers));
 }
 
 
@@ -1312,20 +1521,20 @@ static void
 peers_terminate ()
 {
   if (GNUNET_SYSERR ==
-      GNUNET_CONTAINER_multipeermap_iterate (peer_map,
+      GNUNET_CONTAINER_multipeermap_iterate (mss->peer_map,
                                              &peermap_clear_iterator,
                                              NULL))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Iteration destroying peers was aborted.\n");
   }
-  GNUNET_CONTAINER_multipeermap_destroy (peer_map);
-  peer_map = NULL;
+  GNUNET_CONTAINER_multipeermap_destroy (mss->peer_map);
+  mss->peer_map = NULL;
   store_valid_peers ();
-  GNUNET_free (filename_valid_peers);
-  filename_valid_peers = NULL;
-  GNUNET_CONTAINER_multipeermap_destroy (valid_peers);
-  valid_peers = NULL;
+  GNUNET_free (mss->filename_valid_peers);
+  mss->filename_valid_peers = NULL;
+  GNUNET_CONTAINER_multipeermap_destroy (mss->valid_peers);
+  mss->valid_peers = NULL;
 }
 
 
@@ -1370,7 +1579,7 @@ get_valid_peers (PeersIterator iterator,
   cls = GNUNET_new (struct PeersIteratorCls);
   cls->iterator = iterator;
   cls->cls = it_cls;
-  ret = GNUNET_CONTAINER_multipeermap_iterate (valid_peers,
+  ret = GNUNET_CONTAINER_multipeermap_iterate (mss->valid_peers,
                                                valid_peer_iterator,
                                                cls);
   GNUNET_free (cls);
@@ -1430,21 +1639,21 @@ check_peer_flag (const struct GNUNET_PeerIdentity *peer,
  *
  * If not known yet, insert into known peers
  *
- * @param peer the peer whose liveliness is to be checked
+ * @param peer the peer whose online is to be checked
  * @return #GNUNET_YES if the check was issued
  *         #GNUNET_NO  otherwise
  */
 static int
-issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer)
+issue_peer_online_check (const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *peer_ctx;
 
   (void) insert_peer (peer);
   peer_ctx = get_peer_ctx (peer);
   if ( (GNUNET_NO == check_peer_flag (peer, Peers_ONLINE)) &&
-       (NULL == peer_ctx->liveliness_check_pending) )
+       (NULL == peer_ctx->online_check_pending) )
   {
-    check_peer_live (peer_ctx);
+    check_peer_online (peer_ctx);
     return GNUNET_YES;
   }
   return GNUNET_NO;
@@ -1469,7 +1678,7 @@ check_removable (const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *peer_ctx;
 
-  if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
+  if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mss->peer_map, 
peer))
   {
     return GNUNET_SYSERR;
   }
@@ -1498,7 +1707,7 @@ check_removable (const struct GNUNET_PeerIdentity *peer)
 static int
 check_peer_valid (const struct GNUNET_PeerIdentity *peer)
 {
-  return GNUNET_CONTAINER_multipeermap_contains (valid_peers, peer);
+  return GNUNET_CONTAINER_multipeermap_contains (mss->valid_peers, peer);
 }
 
 
@@ -1566,7 +1775,7 @@ handle_inbound_channel (void *cls,
   GNUNET_assert (NULL != channel); /* according to cadet API */
   /* Make sure we 'know' about this peer */
   peer_ctx = create_or_get_peer_ctx (initiator);
-  set_peer_live (peer_ctx);
+  set_peer_online (peer_ctx);
   ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity);
   *ctx_peer = *initiator;
   channel_ctx = add_channel_ctx (peer_ctx);
@@ -1675,7 +1884,8 @@ send_message (const struct GNUNET_PeerIdentity *peer,
  *
  * Avoids scheduling an operation twice.
  *
- * @param peer the peer we want to schedule the operation for once it gets live
+ * @param peer the peer we want to schedule the operation for once it gets
+ * online
  *
  * @return #GNUNET_YES if the operation was scheduled
  *         #GNUNET_NO  otherwise
@@ -1689,7 +1899,7 @@ schedule_operation (const struct GNUNET_PeerIdentity 
*peer,
 
   GNUNET_assert (GNUNET_YES == check_peer_known (peer));
 
-  //TODO if LIVE/ONLINE execute immediately
+  //TODO if ONLINE execute immediately
 
   if (GNUNET_NO == check_operation_scheduled (peer, peer_op))
   {
@@ -1790,213 +2000,6 @@ struct ClientContext *cli_ctx_tail;
 
 
 /***********************************************************************
- * Globals
-***********************************************************************/
-
-/**
- * Sampler used for the Brahms protocol itself.
- */
-static struct RPS_Sampler *prot_sampler;
-
-/**
- * Name to log view to
- */
-static const char *file_name_view_log;
-
-#ifdef TO_FILE
-/**
- * Name to log number of observed peers to
- */
-static const char *file_name_observed_log;
-
-/**
- * @brief Count the observed peers
- */
-static uint32_t num_observed_peers;
-
-/**
- * @brief Multipeermap (ab-) used to count unique peer_ids
- */
-static struct GNUNET_CONTAINER_MultiPeerMap *observed_unique_peers;
-#endif /* TO_FILE */
-
-/**
- * The size of sampler we need to be able to satisfy the Brahms protocol's
- * need of random peers.
- *
- * This is one minimum size the sampler grows to.
- */
-static unsigned int sampler_size_est_need;
-
-/**
- * @brief This is the minimum estimate used as sampler size.
- *
- * It is configured by the user.
- */
-static unsigned int sampler_size_est_min;
-
-/**
- * @brief This is the estimate used as view size.
- *
- * It is initialised with the minimum
- */
-static unsigned int view_size_est_need;
-
-/**
- * @brief This is the minimum estimate used as view size.
- *
- * It is configured by the user.
- */
-static unsigned int view_size_est_min;
-
-/**
- * Percentage of total peer number in the view
- * to send random PUSHes to
- */
-static float alpha;
-
-/**
- * Percentage of total peer number in the view
- * to send random PULLs to
- */
-static float beta;
-
-/**
- * Identifier for the main task that runs periodically.
- */
-static struct GNUNET_SCHEDULER_Task *do_round_task;
-
-/**
- * Time inverval the do_round task runs in.
- */
-static struct GNUNET_TIME_Relative round_interval;
-
-/**
- * List to store peers received through pushes temporary.
- */
-static struct CustomPeerMap *push_map;
-
-/**
- * List to store peers received through pulls temporary.
- */
-static struct CustomPeerMap *pull_map;
-
-/**
- * Handler to NSE.
- */
-static struct GNUNET_NSE_Handle *nse;
-
-/**
- * Handler to CADET.
- */
-static struct GNUNET_CADET_Handle *cadet_handle;
-
-/**
- * @brief Port to communicate to other peers.
- */
-static struct GNUNET_CADET_Port *cadet_port;
-
-/**
- * Handler to PEERINFO.
- */
-static struct GNUNET_PEERINFO_Handle *peerinfo_handle;
-
-/**
- * Handle for cancellation of iteration over peers.
- */
-static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle;
-
-
-#ifdef ENABLE_MALICIOUS
-/**
- * Type of malicious peer
- *
- * 0 Don't act malicious at all - Default
- * 1 Try to maximise representation
- * 2 Try to partition the network
- * 3 Combined attack
- */
-static uint32_t mal_type;
-
-/**
- * Other malicious peers
- */
-static struct GNUNET_PeerIdentity *mal_peers;
-
-/**
- * Hashmap of malicious peers used as set.
- * Used to more efficiently check whether we know that peer.
- */
-static struct GNUNET_CONTAINER_MultiPeerMap *mal_peer_set;
-
-/**
- * Number of other malicious peers
- */
-static uint32_t num_mal_peers;
-
-
-/**
- * If type is 2 This struct is used to store the attacked peers in a DLL
- */
-struct AttackedPeer
-{
-  /**
-   * DLL
-   */
-  struct AttackedPeer *next;
-  struct AttackedPeer *prev;
-
-  /**
-   * PeerID
-   */
-  struct GNUNET_PeerIdentity peer_id;
-};
-
-/**
- * If type is 2 this is the DLL of attacked peers
- */
-static struct AttackedPeer *att_peers_head;
-static struct AttackedPeer *att_peers_tail;
-
-/**
- * This index is used to point to an attacked peer to
- * implement the round-robin-ish way to select attacked peers.
- */
-static struct AttackedPeer *att_peer_index;
-
-/**
- * Hashmap of attacked peers used as set.
- * Used to more efficiently check whether we know that peer.
- */
-static struct GNUNET_CONTAINER_MultiPeerMap *att_peer_set;
-
-/**
- * Number of attacked peers
- */
-static uint32_t num_attacked_peers;
-
-/**
- * If type is 1 this is the attacked peer
- */
-static struct GNUNET_PeerIdentity attacked_peer;
-
-/**
- * The limit of PUSHes we can send in one round.
- * This is an assumption of the Brahms protocol and either implemented
- * via proof of work
- * or
- * assumend to be the bandwidth limitation.
- */
-static uint32_t push_limit = 10000;
-#endif /* ENABLE_MALICIOUS */
-
-
-/***********************************************************************
- * /Globals
-***********************************************************************/
-
-
-/***********************************************************************
  * Util functions
 ***********************************************************************/
 
@@ -2061,7 +2064,7 @@ rem_from_list (struct GNUNET_PeerIdentity **peer_list,
 /**
  * Insert PeerID in #view
  *
- * Called once we know a peer is live.
+ * Called once we know a peer is online.
  * Implements #PeerOp
  *
  * @return GNUNET_OK if peer was actually inserted
@@ -2074,7 +2077,7 @@ insert_in_view_op (void *cls,
 /**
  * Insert PeerID in #view
  *
- * Called once we know a peer is live.
+ * Called once we know a peer is online.
  *
  * @return GNUNET_OK if peer was actually inserted
  *         GNUNET_NO if peer was not inserted
@@ -2089,14 +2092,14 @@ insert_in_view (const struct GNUNET_PeerIdentity *peer)
   if ( (GNUNET_NO == online) ||
        (GNUNET_SYSERR == online) ) /* peer is not even known */
   {
-    (void) issue_peer_liveliness_check (peer);
+    (void) issue_peer_online_check (peer);
     (void) schedule_operation (peer, insert_in_view_op);
     return GNUNET_NO;
   }
   /* Open channel towards peer to keep connection open */
   indicate_sending_intention (peer);
-  ret = View_put (peer);
-  GNUNET_STATISTICS_set (stats, "view size", View_size(), GNUNET_NO);
+  ret = View_put (mss->view, peer);
+  GNUNET_STATISTICS_set (stats, "view size", View_size(mss->view), GNUNET_NO);
   return ret;
 }
 
@@ -2118,8 +2121,8 @@ send_view (const struct ClientContext *cli_ctx,
 
   if (NULL == view_array)
   {
-    view_size = View_size ();
-    view_array = View_get_as_array();
+    view_size = View_size (mss->view);
+    view_array = View_get_as_array(mss->view);
   }
 
   ev = GNUNET_MQ_msg_extra (out_msg,
@@ -2175,8 +2178,8 @@ clients_notify_view_update (void)
   uint64_t num_peers;
   const struct GNUNET_PeerIdentity *view_array;
 
-  num_peers = View_size ();
-  view_array = View_get_as_array();
+  num_peers = View_size (mss->view);
+  view_array = View_get_as_array(mss->view);
   /* check size of view is small enough */
   if (GNUNET_MAX_MESSAGE_SIZE < num_peers)
   {
@@ -2253,7 +2256,7 @@ hist_update (const struct GNUNET_PeerIdentity *ids,
     {
       clients_notify_stream_peer (1, &ids[i]);
     }
-    to_file (file_name_view_log,
+    to_file (mss->file_name_view_log,
              "+%s\t(hist)",
              GNUNET_i2s_full (ids));
   }
@@ -2376,21 +2379,21 @@ send_pull_reply (const struct GNUNET_PeerIdentity 
*peer_id,
 /**
  * Insert PeerID in #pull_map
  *
- * Called once we know a peer is live.
+ * Called once we know a peer is online.
  */
 static void
 insert_in_pull_map (void *cls,
                     const struct GNUNET_PeerIdentity *peer)
 {
   (void) cls;
-  CustomPeerMap_put (pull_map, peer);
+  CustomPeerMap_put (mss->pull_map, peer);
 }
 
 
 /**
  * Insert PeerID in #view
  *
- * Called once we know a peer is live.
+ * Called once we know a peer is online.
  * Implements #PeerOp
  */
 static void
@@ -2420,35 +2423,35 @@ insert_in_sampler (void *cls,
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Updating samplers with peer %s from insert_in_sampler()\n",
        GNUNET_i2s (peer));
-  RPS_sampler_update (prot_sampler,   peer);
-  if (0 < RPS_sampler_count_id (prot_sampler, peer))
+  RPS_sampler_update (mss->sampler, peer);
+  if (0 < RPS_sampler_count_id (mss->sampler, peer))
   {
     /* Make sure we 'know' about this peer */
-    (void) issue_peer_liveliness_check (peer);
+    (void) issue_peer_online_check (peer);
     /* Establish a channel towards that peer to indicate we are going to send
      * messages to it */
     //indicate_sending_intention (peer);
   }
   #ifdef TO_FILE
-  num_observed_peers++;
+  mss->num_observed_peers++;
   GNUNET_CONTAINER_multipeermap_put
-    (observed_unique_peers,
+    (mss->observed_unique_peers,
      peer,
      NULL,
      GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
-  uint32_t num_observed_unique_peers = GNUNET_CONTAINER_multipeermap_size (
-      observed_unique_peers);
-  to_file (file_name_observed_log,
+  uint32_t num_observed_unique_peers =
+    GNUNET_CONTAINER_multipeermap_size (mss->observed_unique_peers);
+  to_file (mss->file_name_observed_log,
           "%" PRIu32 " %" PRIu32 " %f\n",
-          num_observed_peers,
+          mss->num_observed_peers,
           num_observed_unique_peers,
-          1.0*num_observed_unique_peers/num_observed_peers)
+          1.0*num_observed_unique_peers/mss->num_observed_peers)
   #endif /* TO_FILE */
 }
 
 /**
  * @brief This is called on peers from external sources (cadet, peerinfo, ...)
- *        If the peer is not known, liveliness check is issued and it is
+ *        If the peer is not known, online check is issued and it is
  *        scheduled to be inserted in sampler and view.
  *
  * "External sources" refer to every source except the gossip.
@@ -2459,7 +2462,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 == issue_peer_liveliness_check (peer))
+  if (GNUNET_YES == issue_peer_online_check (peer))
   {
     schedule_operation (peer, insert_in_sampler);
     schedule_operation (peer, insert_in_view_op);
@@ -2487,10 +2490,10 @@ check_sending_channel_needed (const struct 
GNUNET_PeerIdentity *peer)
   }
   if (GNUNET_YES == check_sending_channel_exists (peer))
   {
-    if ( (0 < RPS_sampler_count_id (prot_sampler, peer)) ||
-         (GNUNET_YES == View_contains_peer (peer)) ||
-         (GNUNET_YES == CustomPeerMap_contains_peer (push_map, peer)) ||
-         (GNUNET_YES == CustomPeerMap_contains_peer (pull_map, peer)) ||
+    if ( (0 < RPS_sampler_count_id (mss->sampler, peer)) ||
+         (GNUNET_YES == View_contains_peer (mss->view, peer)) ||
+         (GNUNET_YES == CustomPeerMap_contains_peer (mss->push_map, peer)) ||
+         (GNUNET_YES == CustomPeerMap_contains_peer (mss->pull_map, peer)) ||
          (GNUNET_YES == check_peer_flag (peer, Peers_PULL_REPLY_PENDING)))
     { /* If we want to keep the connection to peer open */
       return GNUNET_YES;
@@ -2509,10 +2512,10 @@ check_sending_channel_needed (const struct 
GNUNET_PeerIdentity *peer)
 static void
 remove_peer (const struct GNUNET_PeerIdentity *peer)
 {
-  (void) View_remove_peer (peer);
-  CustomPeerMap_remove_peer (pull_map, peer);
-  CustomPeerMap_remove_peer (push_map, peer);
-  RPS_sampler_reinitialise_by_value (prot_sampler, peer);
+  (void) View_remove_peer (mss->view, peer);
+  CustomPeerMap_remove_peer (mss->pull_map, peer);
+  CustomPeerMap_remove_peer (mss->push_map, peer);
+  RPS_sampler_reinitialise_by_value (mss->sampler, peer);
   destroy_peer (get_peer_ctx (peer));
 }
 
@@ -2541,10 +2544,10 @@ clean_peer (const struct GNUNET_PeerIdentity *peer)
   }
 
   if ( (GNUNET_NO == check_peer_send_intention (peer)) &&
-       (GNUNET_NO == View_contains_peer (peer)) &&
-       (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
-       (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
-       (0 == RPS_sampler_count_id (prot_sampler,   peer)) &&
+       (GNUNET_NO == View_contains_peer (mss->view, peer)) &&
+       (GNUNET_NO == CustomPeerMap_contains_peer (mss->push_map, peer)) &&
+       (GNUNET_NO == CustomPeerMap_contains_peer (mss->push_map, peer)) &&
+       (0 == RPS_sampler_count_id (mss->sampler,   peer)) &&
        (GNUNET_NO != check_removable (peer)) )
   { /* We can safely remove this peer */
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2590,6 +2593,116 @@ cleanup_destroyed_channel (void *cls,
  * /Util functions
 ***********************************************************************/
 
+
+
+/***********************************************************************
+ * SubSampler
+***********************************************************************/
+
+struct SubSampler *
+new_subsampler (const char *shared_value,
+                uint32_t sampler_size,
+                struct GNUNET_TIME_Relative round_interval)
+{
+  struct SubSampler *ss;
+  char hash_port_string[512] = GNUNET_APPLICATION_PORT_RPS;
+
+  ss = GNUNET_new (struct SubSampler);
+
+  /* With the hash generated from the secret value this service only connects
+   * to rps instances that share the value */
+  strcat (hash_port_string, shared_value);
+  GNUNET_CRYPTO_hash (hash_port_string,
+                      strlen (hash_port_string),
+                      &ss->port);
+  struct GNUNET_MQ_MessageHandler cadet_handlers[] = {
+    GNUNET_MQ_hd_fixed_size (peer_check,
+                             GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE,
+                             struct GNUNET_MessageHeader,
+                             NULL),
+    GNUNET_MQ_hd_fixed_size (peer_push,
+                             GNUNET_MESSAGE_TYPE_RPS_PP_PUSH,
+                             struct GNUNET_MessageHeader,
+                             NULL),
+    GNUNET_MQ_hd_fixed_size (peer_pull_request,
+                             GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST,
+                             struct GNUNET_MessageHeader,
+                             NULL),
+    GNUNET_MQ_hd_var_size (peer_pull_reply,
+                           GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY,
+                           struct GNUNET_RPS_P2P_PullReplyMessage,
+                           NULL),
+    GNUNET_MQ_handler_end ()
+  };
+  ss->cadet_handle = GNUNET_CADET_connect (cfg);
+  GNUNET_assert (NULL != ss->cadet_handle);
+  ss->cadet_port =
+    GNUNET_CADET_open_port (ss->cadet_handle,
+                            &ss->port,
+                            &handle_inbound_channel, /* Connect handler */
+                            NULL, /* cls */
+                            NULL, /* WindowSize handler */
+                            &cleanup_destroyed_channel, /* Disconnect handler 
*/
+                            cadet_handlers);
+  if (NULL == ss->cadet_port)
+  {
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+        "Cadet port `%s' is already in use.\n",
+        GNUNET_APPLICATION_PORT_RPS);
+    GNUNET_assert (0);
+  }
+
+  /* Set up general data structure to keep track about peers */
+  ss->valid_peers = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO);
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                               "rps",
+                                               "FILENAME_VALID_PEERS",
+                                               &ss->filename_valid_peers))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               "rps",
+                               "FILENAME_VALID_PEERS");
+  }
+  ss->peer_map = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO);
+
+  /* Set up the sampler */
+  ss->sampler_size_est_min = sampler_size;
+  ss->sampler_size_est_need = sampler_size;;
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "MINSIZE is %u\n", ss->sampler_size_est_min);
+  ss->round_interval = round_interval;
+  ss->sampler = RPS_sampler_init (sampler_size,
+                                  round_interval);
+
+  /* Logging of internals */
+  ss->file_name_view_log = store_prefix_file_name (&own_identity, "view");
+  #ifdef TO_FILE
+  ss->file_name_observed_log = store_prefix_file_name (&own_identity,
+                                                       "observed");
+  ss->num_observed_peers = 0;
+  ss->observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1,
+                                                                    GNUNET_NO);
+  #endif /* TO_FILE */
+
+  /* Set up data structures for gossip */
+  ss->push_map = CustomPeerMap_create (4);
+  ss->pull_map = CustomPeerMap_create (4);
+  ss->view_size_est_min = sampler_size;;
+  ss->view = View_create (ss->view_size_est_min);
+  GNUNET_STATISTICS_set (stats,
+                         "view size aim",
+                         ss->view_size_est_min,
+                         GNUNET_NO);
+
+
+  return ss;
+}
+
+/***********************************************************************
+ * /SubSampler
+***********************************************************************/
+
+
 static void
 destroy_cli_ctx (struct ClientContext *cli_ctx)
 {
@@ -2619,29 +2732,29 @@ nse_callback (void *cls,
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Received a ns estimate - logest: %f, std_dev: %f (old_size: %u)\n",
-       logestimate, std_dev, RPS_sampler_get_size (prot_sampler));
+       logestimate, std_dev, RPS_sampler_get_size (mss->sampler));
   //scale = .01;
   estimate = GNUNET_NSE_log_estimate_to_n (logestimate);
   // GNUNET_NSE_log_estimate_to_n (logestimate);
   estimate = pow (estimate, 1.0 / 3);
   // TODO add if std_dev is a number
   // estimate += (std_dev * scale);
-  if (view_size_est_min < ceil (estimate))
+  if (mss->view_size_est_min < ceil (estimate))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Changing estimate to %f\n", estimate);
-    sampler_size_est_need = estimate;
-    view_size_est_need = estimate;
+    mss->sampler_size_est_need = estimate;
+    mss->view_size_est_need = estimate;
   } else
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Not using estimate %f\n", estimate);
-    //sampler_size_est_need = view_size_est_min;
-    view_size_est_need = view_size_est_min;
+    //mss->sampler_size_est_need = mss->view_size_est_min;
+    mss->view_size_est_need = mss->view_size_est_min;
   }
-  GNUNET_STATISTICS_set (stats, "view size aim", view_size_est_need, 
GNUNET_NO);
+  GNUNET_STATISTICS_set (stats, "view size aim", mss->view_size_est_need, 
GNUNET_NO);
 
   /* If the NSE has changed adapt the lists accordingly */
-  resize_wrapper (prot_sampler, sampler_size_est_need);
-  View_change_len (view_size_est_need);
+  resize_wrapper (mss->sampler, mss->sampler_size_est_need);
+  View_change_len (mss->view, mss->view_size_est_need);
 }
 
 
@@ -2827,7 +2940,7 @@ handle_peer_check (void *cls,
   LOG (GNUNET_ERROR_TYPE_DEBUG,
       "Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer));
   GNUNET_STATISTICS_update (stats,
-                            "# pending liveliness checks",
+                            "# pending online checks",
                             -1,
                             GNUNET_NO);
 
@@ -2891,7 +3004,7 @@ handle_peer_push (void *cls,
   #endif /* ENABLE_MALICIOUS */
 
   /* Add the sending peer to the push_map */
-  CustomPeerMap_put (push_map, peer);
+  CustomPeerMap_put (mss->push_map, peer);
 
   GNUNET_break_op (check_peer_known (peer));
   GNUNET_CADET_receive_done (channel_ctx->channel);
@@ -2936,8 +3049,8 @@ handle_peer_pull_request (void *cls,
 
   GNUNET_break_op (check_peer_known (peer));
   GNUNET_CADET_receive_done (channel_ctx->channel);
-  view_array = View_get_as_array ();
-  send_pull_reply (peer, view_array, View_size ());
+  view_array = View_get_as_array (mss->view);
+  send_pull_reply (peer, view_array, View_size (mss->view));
 }
 
 
@@ -3056,12 +3169,12 @@ handle_peer_pull_reply (void *cls,
 
     if (GNUNET_YES == check_peer_valid (&peers[i]))
     {
-      CustomPeerMap_put (pull_map, &peers[i]);
+      CustomPeerMap_put (mss->pull_map, &peers[i]);
     }
     else
     {
       schedule_operation (&peers[i], insert_in_pull_map);
-      (void) issue_peer_liveliness_check (&peers[i]);
+      (void) issue_peer_online_check (&peers[i]);
     }
   }
 
@@ -3252,8 +3365,8 @@ handle_client_act_malicious (void *cls,
                            mal_peer_set);
 
     /* Substitute do_round () with do_mal_round () */
-    GNUNET_SCHEDULER_cancel (do_round_task);
-    do_round_task = GNUNET_SCHEDULER_add_now (&do_mal_round, NULL);
+    GNUNET_SCHEDULER_cancel (mss->do_round_task);
+    mss->do_round_task = GNUNET_SCHEDULER_add_now (&do_mal_round, NULL);
   }
 
   else if ( (2 == mal_type) ||
@@ -3287,7 +3400,7 @@ handle_client_act_malicious (void *cls,
     /* Set the flag of the attacked peer to valid to avoid problems */
     if (GNUNET_NO == check_peer_known (&attacked_peer))
     {
-      (void) issue_peer_liveliness_check (&attacked_peer);
+      (void) issue_peer_online_check (&attacked_peer);
     }
 
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -3295,16 +3408,16 @@ handle_client_act_malicious (void *cls,
          GNUNET_i2s (&attacked_peer));
 
     /* Substitute do_round () with do_mal_round () */
-    GNUNET_SCHEDULER_cancel (do_round_task);
-    do_round_task = GNUNET_SCHEDULER_add_now (&do_mal_round, NULL);
+    GNUNET_SCHEDULER_cancel (mss->do_round_task);
+    mss->do_round_task = GNUNET_SCHEDULER_add_now (&do_mal_round, NULL);
   }
   else if (0 == mal_type)
   { /* Stop acting malicious */
     GNUNET_array_grow (mal_peers, num_mal_peers, 0);
 
     /* Substitute do_mal_round () with do_round () */
-    GNUNET_SCHEDULER_cancel (do_round_task);
-    do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL);
+    GNUNET_SCHEDULER_cancel (mss->do_round_task);
+    mss->do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL);
   }
   else
   {
@@ -3332,7 +3445,7 @@ do_mal_round (void *cls)
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Going to execute next round maliciously type %" PRIu32 ".\n",
       mal_type);
-  do_round_task = NULL;
+  mss->do_round_task = NULL;
   GNUNET_assert (mal_type <= 3);
   /* Do malicious actions */
   if (1 == mal_type)
@@ -3378,7 +3491,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.
      */
-    (void) issue_peer_liveliness_check (&attacked_peer);
+    (void) issue_peer_online_check (&attacked_peer);
     if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE))
       send_push (&attacked_peer);
   }
@@ -3390,7 +3503,7 @@ do_mal_round (void *cls)
     /* Send PUSH to attacked peers */
     if (GNUNET_YES == check_peer_known (&attacked_peer))
     {
-      (void) issue_peer_liveliness_check (&attacked_peer);
+      (void) issue_peer_online_check (&attacked_peer);
       if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE))
       {
         LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -3399,7 +3512,7 @@ do_mal_round (void *cls)
         send_push (&attacked_peer);
       }
     }
-    (void) issue_peer_liveliness_check (&attacked_peer);
+    (void) issue_peer_online_check (&attacked_peer);
 
     /* The maximum of pushes we're going to send this round */
     num_pushes = GNUNET_MIN (GNUNET_MIN (push_limit - 1,
@@ -3434,13 +3547,13 @@ do_mal_round (void *cls)
   }
 
   /* Schedule next round */
-  time_next_round = compute_rand_delay (round_interval, 2);
+  time_next_round = compute_rand_delay (mss->round_interval, 2);
 
-  //do_round_task = GNUNET_SCHEDULER_add_delayed (round_interval, 
&do_mal_round,
+  //mss->do_round_task = GNUNET_SCHEDULER_add_delayed (mss->round_interval, 
&do_mal_round,
   //NULL);
-  GNUNET_assert (NULL == do_round_task);
-  do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round,
-                                               &do_mal_round, NULL);
+  GNUNET_assert (NULL == mss->do_round_task);
+  mss->do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round,
+                                                    &do_mal_round, NULL);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n");
 }
 #endif /* ENABLE_MALICIOUS */
@@ -3467,34 +3580,34 @@ do_round (void *cls)
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Going to execute next round.\n");
   GNUNET_STATISTICS_update(stats, "# rounds", 1, GNUNET_NO);
-  do_round_task = NULL;
+  mss->do_round_task = NULL;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Printing view:\n");
-  to_file (file_name_view_log,
+  to_file (mss->file_name_view_log,
            "___ new round ___");
-  view_array = View_get_as_array ();
-  for (i = 0; i < View_size (); i++)
+  view_array = View_get_as_array (mss->view);
+  for (i = 0; i < View_size (mss->view); i++)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "\t%s\n", GNUNET_i2s (&view_array[i]));
-    to_file (file_name_view_log,
+    to_file (mss->file_name_view_log,
              "=%s\t(do round)",
              GNUNET_i2s_full (&view_array[i]));
   }
 
 
   /* Send pushes and pull requests */
-  if (0 < View_size ())
+  if (0 < View_size (mss->view))
   {
     permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG,
-                                           View_size ());
+                                           View_size (mss->view));
 
     /* Send PUSHes */
-    a_peers = ceil (alpha * View_size ());
+    a_peers = ceil (alpha * View_size (mss->view));
 
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Going to send pushes to %u (ceil (%f * %u)) peers.\n",
-         a_peers, alpha, View_size ());
+         a_peers, alpha, View_size (mss->view));
     for (i = 0; i < a_peers; i++)
     {
       peer = view_array[permut[i]];
@@ -3503,17 +3616,17 @@ do_round (void *cls)
     }
 
     /* Send PULL requests */
-    b_peers = ceil (beta * View_size ());
+    b_peers = ceil (beta * View_size (mss->view));
     first_border = a_peers;
     second_border = a_peers + b_peers;
-    if (second_border > View_size ())
+    if (second_border > View_size (mss->view))
     {
-      first_border = View_size () - b_peers;
-      second_border = View_size ();
+      first_border = View_size (mss->view) - b_peers;
+      second_border = View_size (mss->view);
     }
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Going to send pulls to %u (ceil (%f * %u)) peers.\n",
-        b_peers, beta, View_size ());
+        b_peers, beta, View_size (mss->view));
     for (i = first_border; i < second_border; i++)
     {
       peer = view_array[permut[i]];
@@ -3531,9 +3644,9 @@ do_round (void *cls)
   /* Update view */
   /* TODO see how many peers are in push-/pull- list! */
 
-  if ((CustomPeerMap_size (push_map) <= alpha * view_size_est_need) &&
-      (0 < CustomPeerMap_size (push_map)) &&
-      (0 < CustomPeerMap_size (pull_map)))
+  if ((CustomPeerMap_size (mss->push_map) <= alpha * mss->view_size_est_need) 
&&
+      (0 < CustomPeerMap_size (mss->push_map)) &&
+      (0 < CustomPeerMap_size (mss->pull_map)))
   //if (GNUNET_YES) // disable blocking temporarily
   { /* If conditions for update are fulfilled, update */
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Update of the view.\n");
@@ -3544,23 +3657,25 @@ do_round (void *cls)
 
     peers_to_clean = NULL;
     peers_to_clean_size = 0;
-    GNUNET_array_grow (peers_to_clean, peers_to_clean_size, View_size ());
+    GNUNET_array_grow (peers_to_clean,
+                       peers_to_clean_size,
+                       View_size (mss->view));
     GNUNET_memcpy (peers_to_clean,
             view_array,
-            View_size () * sizeof (struct GNUNET_PeerIdentity));
+            View_size (mss->view) * sizeof (struct GNUNET_PeerIdentity));
 
     /* Seems like recreating is the easiest way of emptying the peermap */
-    View_clear ();
-    to_file (file_name_view_log,
+    View_clear (mss->view);
+    to_file (mss->file_name_view_log,
              "--- emptied ---");
 
-    first_border  = GNUNET_MIN (ceil (alpha * view_size_est_need),
-                                CustomPeerMap_size (push_map));
+    first_border  = GNUNET_MIN (ceil (alpha * mss->view_size_est_need),
+                                CustomPeerMap_size (mss->push_map));
     second_border = first_border +
-                    GNUNET_MIN (floor (beta  * view_size_est_need),
-                                CustomPeerMap_size (pull_map));
+                    GNUNET_MIN (floor (beta  * mss->view_size_est_need),
+                                CustomPeerMap_size (mss->pull_map));
     final_size    = second_border +
-      ceil ((1 - (alpha + beta)) * view_size_est_need);
+      ceil ((1 - (alpha + beta)) * mss->view_size_est_need);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "first border: %" PRIu32 ", second border: %" PRIu32 ", final size: 
%"PRIu32 "\n",
         first_border,
@@ -3569,18 +3684,18 @@ do_round (void *cls)
 
     /* Update view with peers received through PUSHes */
     permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG,
-                                           CustomPeerMap_size (push_map));
+                                           CustomPeerMap_size (mss->push_map));
     for (i = 0; i < first_border; i++)
     {
       int inserted;
-      inserted = insert_in_view (CustomPeerMap_get_peer_by_index (push_map,
+      inserted = insert_in_view (CustomPeerMap_get_peer_by_index 
(mss->push_map,
                                                                   permut[i]));
       if (GNUNET_OK == inserted)
       {
         clients_notify_stream_peer (1,
-            CustomPeerMap_get_peer_by_index (push_map, permut[i]));
+            CustomPeerMap_get_peer_by_index (mss->push_map, permut[i]));
       }
-      to_file (file_name_view_log,
+      to_file (mss->file_name_view_log,
                "+%s\t(push list)",
                GNUNET_i2s_full (&view_array[i]));
       // TODO change the peer_flags accordingly
@@ -3590,19 +3705,19 @@ do_round (void *cls)
 
     /* Update view with peers received through PULLs */
     permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG,
-                                           CustomPeerMap_size (pull_map));
+                                           CustomPeerMap_size (mss->pull_map));
     for (i = first_border; i < second_border; i++)
     {
       int inserted;
-      inserted = insert_in_view (CustomPeerMap_get_peer_by_index (pull_map,
+      inserted = insert_in_view (CustomPeerMap_get_peer_by_index 
(mss->pull_map,
             permut[i - first_border]));
       if (GNUNET_OK == inserted)
       {
         clients_notify_stream_peer (1,
-            CustomPeerMap_get_peer_by_index (pull_map,
+            CustomPeerMap_get_peer_by_index (mss->pull_map,
                                              permut[i - first_border]));
       }
-      to_file (file_name_view_log,
+      to_file (mss->file_name_view_log,
                "+%s\t(pull list)",
                GNUNET_i2s_full (&view_array[i]));
       // TODO change the peer_flags accordingly
@@ -3611,19 +3726,19 @@ do_round (void *cls)
     permut = NULL;
 
     /* Update view with peers from history */
-    RPS_sampler_get_n_rand_peers (prot_sampler,
+    RPS_sampler_get_n_rand_peers (mss->sampler,
                                   final_size - second_border,
                                   hist_update,
                                   NULL);
     // TODO change the peer_flags accordingly
 
-    for (i = 0; i < View_size (); i++)
+    for (i = 0; i < View_size (mss->view); i++)
       rem_from_list (&peers_to_clean, &peers_to_clean_size, &view_array[i]);
 
     /* Clean peers that were removed from the view */
     for (i = 0; i < peers_to_clean_size; i++)
     {
-      to_file (file_name_view_log,
+      to_file (mss->file_name_view_log,
                "-%s",
                GNUNET_i2s_full (&peers_to_clean[i]));
       clean_peer (&peers_to_clean[i]);
@@ -3634,49 +3749,49 @@ do_round (void *cls)
   } else {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "No update of the view.\n");
     GNUNET_STATISTICS_update(stats, "# rounds blocked", 1, GNUNET_NO);
-    if (CustomPeerMap_size (push_map) > alpha * View_size () &&
-        !(0 >= CustomPeerMap_size (pull_map)))
+    if (CustomPeerMap_size (mss->push_map) > alpha * View_size (mss->view) &&
+        !(0 >= CustomPeerMap_size (mss->pull_map)))
       GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes", 1, 
GNUNET_NO);
-    if (CustomPeerMap_size (push_map) > alpha * View_size () &&
-        (0 >= CustomPeerMap_size (pull_map)))
+    if (CustomPeerMap_size (mss->push_map) > alpha * View_size (mss->view) &&
+        (0 >= CustomPeerMap_size (mss->pull_map)))
       GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes, no 
pull replies", 1, GNUNET_NO);
-    if (0 >= CustomPeerMap_size (push_map) &&
-        !(0 >= CustomPeerMap_size (pull_map)))
+    if (0 >= CustomPeerMap_size (mss->push_map) &&
+        !(0 >= CustomPeerMap_size (mss->pull_map)))
       GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes", 1, 
GNUNET_NO);
-    if (0 >= CustomPeerMap_size (push_map) &&
-        (0 >= CustomPeerMap_size (pull_map)))
+    if (0 >= CustomPeerMap_size (mss->push_map) &&
+        (0 >= CustomPeerMap_size (mss->pull_map)))
       GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes, no pull 
replies", 1, GNUNET_NO);
-    if (0 >= CustomPeerMap_size (pull_map) &&
-        CustomPeerMap_size (push_map) > alpha * View_size () &&
-        0 >= CustomPeerMap_size (push_map))
+    if (0 >= CustomPeerMap_size (mss->pull_map) &&
+        CustomPeerMap_size (mss->push_map) > alpha * View_size (mss->view) &&
+        0 >= CustomPeerMap_size (mss->push_map))
       GNUNET_STATISTICS_update(stats, "# rounds blocked - no pull replies", 1, 
GNUNET_NO);
   }
   // TODO independent of that also get some peers from CADET_get_peers()?
   GNUNET_STATISTICS_set (stats,
       "# peers in push map at end of round",
-      CustomPeerMap_size (push_map),
+      CustomPeerMap_size (mss->push_map),
       GNUNET_NO);
   GNUNET_STATISTICS_set (stats,
       "# peers in pull map at end of round",
-      CustomPeerMap_size (pull_map),
+      CustomPeerMap_size (mss->pull_map),
       GNUNET_NO);
   GNUNET_STATISTICS_set (stats,
       "# peers in view at end of round",
-      View_size (),
+      View_size (mss->view),
       GNUNET_NO);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Received %u pushes and %u pulls last round (alpha (%.2f) * view_size 
(%u) = %.2f)\n",
-       CustomPeerMap_size (push_map),
-       CustomPeerMap_size (pull_map),
+       "Received %u pushes and %u pulls last round (alpha (%.2f) * view_size 
(mss->view%u) = %.2f)\n",
+       CustomPeerMap_size (mss->push_map),
+       CustomPeerMap_size (mss->pull_map),
        alpha,
-       View_size (),
-       alpha * View_size ());
+       View_size (mss->view),
+       alpha * View_size (mss->view));
 
   /* Update samplers */
-  for (i = 0; i < CustomPeerMap_size (push_map); i++)
+  for (i = 0; i < CustomPeerMap_size (mss->push_map); i++)
   {
-    update_peer = CustomPeerMap_get_peer_by_index (push_map, i);
+    update_peer = CustomPeerMap_get_peer_by_index (mss->push_map, i);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Updating with peer %s from push list\n",
          GNUNET_i2s (update_peer));
@@ -3684,33 +3799,33 @@ do_round (void *cls)
     clean_peer (update_peer); /* This cleans only if it is not in the view */
   }
 
-  for (i = 0; i < CustomPeerMap_size (pull_map); i++)
+  for (i = 0; i < CustomPeerMap_size (mss->pull_map); i++)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Updating with peer %s from pull list\n",
-         GNUNET_i2s (CustomPeerMap_get_peer_by_index (pull_map, i)));
-    insert_in_sampler (NULL, CustomPeerMap_get_peer_by_index (pull_map, i));
+         GNUNET_i2s (CustomPeerMap_get_peer_by_index (mss->pull_map, i)));
+    insert_in_sampler (NULL, CustomPeerMap_get_peer_by_index (mss->pull_map, 
i));
     /* This cleans only if it is not in the view */
-    clean_peer (CustomPeerMap_get_peer_by_index (pull_map, i));
+    clean_peer (CustomPeerMap_get_peer_by_index (mss->pull_map, i));
   }
 
 
   /* Empty push/pull lists */
-  CustomPeerMap_clear (push_map);
-  CustomPeerMap_clear (pull_map);
+  CustomPeerMap_clear (mss->push_map);
+  CustomPeerMap_clear (mss->pull_map);
 
   GNUNET_STATISTICS_set (stats,
                          "view size",
-                         View_size(),
+                         View_size(mss->view),
                          GNUNET_NO);
 
   struct GNUNET_TIME_Relative time_next_round;
 
-  time_next_round = compute_rand_delay (round_interval, 2);
+  time_next_round = compute_rand_delay (mss->round_interval, 2);
 
   /* Schedule next round */
-  do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round,
-                                               &do_round, NULL);
+  mss->do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round,
+                                                    &do_round, NULL);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n");
 }
 
@@ -3810,10 +3925,8 @@ shutdown_task (void *cls)
   struct ClientContext *client_ctx;
   (void) cls;
 
-  in_shutdown = GNUNET_YES;
-
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "RPS is going down\n");
+       "RPS service is going down\n");
 
   /* Clean all clients */
   for (client_ctx = cli_ctx_head;
@@ -3825,22 +3938,22 @@ shutdown_task (void *cls)
   GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle);
   GNUNET_PEERINFO_disconnect (peerinfo_handle);
   peerinfo_handle = NULL;
-  if (NULL != do_round_task)
+  if (NULL != mss->do_round_task)
   {
-    GNUNET_SCHEDULER_cancel (do_round_task);
-    do_round_task = NULL;
+    GNUNET_SCHEDULER_cancel (mss->do_round_task);
+    mss->do_round_task = NULL;
   }
 
   peers_terminate ();
 
   GNUNET_NSE_disconnect (nse);
-  RPS_sampler_destroy (prot_sampler);
-  GNUNET_CADET_close_port (cadet_port);
-  GNUNET_CADET_disconnect (cadet_handle);
-  cadet_handle = NULL;
-  View_destroy ();
-  CustomPeerMap_destroy (push_map);
-  CustomPeerMap_destroy (pull_map);
+  RPS_sampler_destroy (mss->sampler);
+  GNUNET_CADET_close_port (mss->cadet_port);
+  GNUNET_CADET_disconnect (mss->cadet_handle);
+  mss->cadet_handle = NULL;
+  View_destroy (mss->view);
+  CustomPeerMap_destroy (mss->push_map);
+  CustomPeerMap_destroy (mss->pull_map);
   if (NULL != stats)
   {
     GNUNET_STATISTICS_destroy (stats,
@@ -3850,10 +3963,10 @@ shutdown_task (void *cls)
 #ifdef ENABLE_MALICIOUS
   struct AttackedPeer *tmp_att_peer;
   /* it is ok to free this const during shutdown: */
-  GNUNET_free ((char *) file_name_view_log);
+  GNUNET_free ((char *) mss->file_name_view_log);
 #ifdef TO_FILE
-  GNUNET_free ((char *) file_name_observed_log);
-  GNUNET_CONTAINER_multipeermap_destroy (observed_unique_peers);
+  GNUNET_free ((char *) mss->file_name_observed_log);
+  GNUNET_CONTAINER_multipeermap_destroy (mss->observed_unique_peers);
 #endif /* TO_FILE */
   GNUNET_array_grow (mal_peers,
                     num_mal_peers,
@@ -3948,9 +4061,12 @@ run (void *cls,
      struct GNUNET_SERVICE_Handle *service)
 {
   char *fn_valid_peers;
+  struct GNUNET_TIME_Relative round_interval;
+  long long unsigned int sampler_size;
 
   (void) cls;
   (void) service;
+
   GNUNET_log_setup ("rps",
                    GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG),
                    NULL);
@@ -3981,17 +4097,16 @@ run (void *cls,
 
   /* Get initial size of sampler/view from the configuration */
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (cfg, "RPS", "MINSIZE",
-        (long long unsigned int *) &sampler_size_est_min))
+      GNUNET_CONFIGURATION_get_value_number (cfg,
+                                             "RPS",
+                                             "MINSIZE",
+                                             &sampler_size))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                "RPS", "MINSIZE");
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  sampler_size_est_need = sampler_size_est_min;
-  view_size_est_min = sampler_size_est_min;
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "MINSIZE is %u\n", sampler_size_est_min);
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_filename (cfg,
@@ -4004,16 +4119,6 @@ run (void *cls,
   }
 
 
-  View_create (view_size_est_min);
-  GNUNET_STATISTICS_set (stats, "view size aim", view_size_est_min, GNUNET_NO);
-
-  /* file_name_view_log */
-  file_name_view_log = store_prefix_file_name (&own_identity, "view");
-  #ifdef TO_FILE
-  file_name_observed_log = store_prefix_file_name (&own_identity, "observed");
-  observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1, GNUNET_NO);
-  #endif /* TO_FILE */
-
   /* connect to NSE */
   nse = GNUNET_NSE_connect (cfg, nse_callback, NULL);
 
@@ -4022,72 +4127,20 @@ run (void *cls,
   beta  = 0.45;
 
 
-  /* Initialise cadet */
-  /* There exists a copy-paste-clone in get_channel() */
-  struct GNUNET_MQ_MessageHandler cadet_handlers[] = {
-    GNUNET_MQ_hd_fixed_size (peer_check,
-                             GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE,
-                             struct GNUNET_MessageHeader,
-                             NULL),
-    GNUNET_MQ_hd_fixed_size (peer_push,
-                             GNUNET_MESSAGE_TYPE_RPS_PP_PUSH,
-                             struct GNUNET_MessageHeader,
-                             NULL),
-    GNUNET_MQ_hd_fixed_size (peer_pull_request,
-                             GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST,
-                             struct GNUNET_MessageHeader,
-                             NULL),
-    GNUNET_MQ_hd_var_size (peer_pull_reply,
-                           GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY,
-                           struct GNUNET_RPS_P2P_PullReplyMessage,
-                           NULL),
-    GNUNET_MQ_handler_end ()
-  };
-
-  cadet_handle = GNUNET_CADET_connect (cfg);
-  GNUNET_assert (NULL != cadet_handle);
-  GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_RPS,
-                      strlen (GNUNET_APPLICATION_PORT_RPS),
-                      &port);
-  cadet_port = GNUNET_CADET_open_port (cadet_handle,
-                                       &port,
-                                       &handle_inbound_channel, /* Connect 
handler */
-                                       NULL, /* cls */
-                                       NULL, /* WindowSize handler */
-                                       &cleanup_destroyed_channel, /* 
Disconnect handler */
-                                       cadet_handlers);
-  if (NULL == cadet_port)
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-        "Cadet port `%s' is already in use.\n",
-        GNUNET_APPLICATION_PORT_RPS);
-    GNUNET_assert (0);
-  }
+  /* Set up main SubSampler */
+  mss = new_subsampler ("", /* this is the main sampler - no shared value */
+                         sampler_size, /* Will be overwritten by config */
+                         round_interval);
 
 
   peerinfo_handle = GNUNET_PEERINFO_connect (cfg);
-  initialise_peers (fn_valid_peers, cadet_handle);
-  GNUNET_free (fn_valid_peers);
-
-  /* Initialise sampler */
-  struct GNUNET_TIME_Relative half_round_interval;
-  struct GNUNET_TIME_Relative  max_round_interval;
-
-  half_round_interval = GNUNET_TIME_relative_divide (round_interval, 2);
-  max_round_interval = GNUNET_TIME_relative_add (round_interval, 
half_round_interval);
-
-  prot_sampler =   RPS_sampler_init     (sampler_size_est_need, 
max_round_interval);
-
-  /* Initialise push and pull maps */
-  push_map = CustomPeerMap_create (4);
-  pull_map = CustomPeerMap_create (4);
-
 
   //LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting peers from CADET\n");
-  //GNUNET_CADET_get_peers (cadet_handle, &init_peer_cb, NULL);
+  //GNUNET_CADET_get_peers (mss.cadet_handle, &init_peer_cb, NULL);
   // TODO send push/pull to each of those peers?
   // TODO read stored valid peers from last run
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting stored valid peers\n");
+  restore_valid_peers ();
   get_valid_peers (valid_peers_iterator, NULL);
 
   peerinfo_notify_handle = GNUNET_PEERINFO_notify (cfg,
@@ -4097,7 +4150,7 @@ run (void *cls,
 
   LOG (GNUNET_ERROR_TYPE_INFO, "Ready to receive requests from clients\n");
 
-  do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL);
+  mss->do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n");
 
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
diff --git a/src/rps/gnunet-service-rps_view.c 
b/src/rps/gnunet-service-rps_view.c
index 26a0b22bc..3af858e60 100644
--- a/src/rps/gnunet-service-rps_view.c
+++ b/src/rps/gnunet-service-rps_view.c
@@ -26,192 +26,221 @@
 #include "gnunet-service-rps_view.h"
 #include <inttypes.h>
 
+struct View
+{
+  /**
+   * Array containing the peers
+   */
+  struct GNUNET_PeerIdentity *array;
 
-/**
- * Array containing the peers
- */
-static struct GNUNET_PeerIdentity *array;
-
-/**
- * (Maximum) length of the view
- */
-static uint32_t length;
+  /**
+   * (Maximum) length of the view
+   */
+  uint32_t length;
 
-/**
- * Multipeermap containing the peers
- */
-static struct GNUNET_CONTAINER_MultiPeerMap *mpm;
+  /**
+   * Multipeermap containing the peers
+   */
+  struct GNUNET_CONTAINER_MultiPeerMap *mpm;
+};
 
 
 /**
  * Create an empty view.
  *
  * @param len the maximum length for the view
+ * @return The newly created view
  */
-void
+struct View *
 View_create (uint32_t len)
 {
-  length = len;
-  array = GNUNET_new_array (len, struct GNUNET_PeerIdentity);
-  mpm = GNUNET_CONTAINER_multipeermap_create (len, GNUNET_NO); /* might even be
-                                                                * set to _YES 
*/
+  struct View *view;
+
+  view = GNUNET_new (struct View);
+  view->length = len;
+  view->array = GNUNET_new_array (len, struct GNUNET_PeerIdentity);
+  view->mpm =
+    GNUNET_CONTAINER_multipeermap_create (len, GNUNET_NO); /* might even be
+                                                            * set to _YES */
+  return view;
 }
 
+
 /**
  * Change length of view
  *
  * If size is decreased, peers with higher indices are removed.
  *
+ * @param view The view that is changed
  * @param len the (maximum) length for the view
  */
 void
-View_change_len (uint32_t len)
+View_change_len (struct View *view,
+                 uint32_t len)
 {
   uint32_t i;
   uint32_t *index;
 
-  if (GNUNET_CONTAINER_multipeermap_size (mpm) < len)
+  if (GNUNET_CONTAINER_multipeermap_size (view->mpm) < len)
   { /* Simply shrink */
     /* We might simply clear and free the left over space */
-    GNUNET_array_grow (array, length, len);
+    GNUNET_array_grow (view->array, view->length, len);
   }
   else /* We have to remove elements */
   {
     /* TODO find a way to preserve indices */
     for (i = 0; i < len; i++)
     {
-      index = GNUNET_CONTAINER_multipeermap_get (mpm, &array[i]);
+      index = GNUNET_CONTAINER_multipeermap_get (view->mpm, &view->array[i]);
       GNUNET_assert (NULL != index);
       GNUNET_free (index);
     }
-    GNUNET_array_grow (array, length, len);
-    GNUNET_CONTAINER_multipeermap_destroy (mpm);
-    mpm = GNUNET_CONTAINER_multipeermap_create (len, GNUNET_NO);
+    GNUNET_array_grow (view->array, view->length, len);
+    GNUNET_CONTAINER_multipeermap_destroy (view->mpm);
+    view->mpm = GNUNET_CONTAINER_multipeermap_create (len, GNUNET_NO);
     for (i = 0; i < len; i++)
     {
       index = GNUNET_new (uint32_t);
       *index = i;
-      GNUNET_CONTAINER_multipeermap_put (mpm, &array[i], index,
+      GNUNET_CONTAINER_multipeermap_put (view->mpm, &view->array[i], index,
           GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
     }
   }
-  GNUNET_assert (length == len);
+  GNUNET_assert (view->length == len);
 }
 
+
 /**
  * Get the view as an array
  *
+ * @param view The view of which the array representation is of interest
  * @return the view in array representation
  */
 const struct GNUNET_PeerIdentity *
-View_get_as_array ()
+View_get_as_array (const struct View *view)
 {
-  return array;
+  return view->array;
 }
 
+
 /**
  * Get the size of the view
  *
+ * @param view The view of which the size should be returned
  * @return current number of actually contained peers
  */
 unsigned int
-View_size ()
+View_size (const struct View *view)
 {
-  return GNUNET_CONTAINER_multipeermap_size (mpm);
+  return GNUNET_CONTAINER_multipeermap_size (view->mpm);
 }
 
+
 /**
  * Insert peer into the view
  *
+ * @param view The view to put the peer into
  * @param peer the peer to insert
  *
  * @return GNUNET_OK if peer was actually inserted
  *         GNUNET_NO if peer was not inserted
  */
 int
-View_put (const struct GNUNET_PeerIdentity *peer)
+View_put (struct View *view,
+          const struct GNUNET_PeerIdentity *peer)
 {
   uint32_t *index;
 
-  if ((length <= View_size ()) || /* If array is 'full' */
-      (GNUNET_YES == View_contains_peer (peer)))
+  if ((view->length <= View_size (view)) || /* If array is 'full' */
+      (GNUNET_YES == View_contains_peer (view, peer)))
   {
     return GNUNET_NO;
   }
   else
   {
     index = GNUNET_new (uint32_t);
-    *index = (uint32_t) View_size ();
-    array[*index] = *peer;
-    GNUNET_CONTAINER_multipeermap_put (mpm, peer, index,
+    *index = (uint32_t) View_size (view);
+    view->array[*index] = *peer;
+    GNUNET_CONTAINER_multipeermap_put (view->mpm, peer, index,
         GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
     return GNUNET_OK;
   }
 }
 
+
 /**
  * Check whether view contains a peer
  *
+ * @param view The which is checked for a peer
  * @param peer the peer to check for
  *
  * @return GNUNET_OK if view contains peer
  *         GNUNET_NO otherwise
  */
 int
-View_contains_peer (const struct GNUNET_PeerIdentity *peer)
+View_contains_peer (const struct View *view,
+                    const struct GNUNET_PeerIdentity *peer)
 {
-  return GNUNET_CONTAINER_multipeermap_contains (mpm, peer);
+  return GNUNET_CONTAINER_multipeermap_contains (view->mpm, peer);
 }
 
+
 /**
  * Remove peer from view
  *
+ * @param view The view of which to remove the peer
  * @param peer the peer to remove
  *
  * @return GNUNET_OK if view contained peer and removed it successfully
  *         GNUNET_NO if view does not contain peer
  */
 int
-View_remove_peer (const struct GNUNET_PeerIdentity *peer)
+View_remove_peer (struct View *view,
+                  const struct GNUNET_PeerIdentity *peer)
 {
   uint32_t *index;
   uint32_t *swap_index;
   uint32_t last_index;
 
-  if (GNUNET_NO == View_contains_peer (peer))
+  if (GNUNET_NO == View_contains_peer (view, peer))
   {
     return GNUNET_NO;
   }
-  index = GNUNET_CONTAINER_multipeermap_get (mpm, peer);
+  index = GNUNET_CONTAINER_multipeermap_get (view->mpm, peer);
   GNUNET_assert (NULL != index);
-  last_index = View_size () - 1;
+  last_index = View_size (view) - 1;
   if (*index < last_index)
   { /* Fill the 'gap' in the array with the last peer */
-    array[*index] = array[last_index];
-    GNUNET_assert (GNUNET_YES == View_contains_peer (&array[last_index]));
-    swap_index = GNUNET_CONTAINER_multipeermap_get (mpm, &array[last_index]);
+    view->array[*index] = view->array[last_index];
+    GNUNET_assert (GNUNET_YES == View_contains_peer (view,
+                                                     
&view->array[last_index]));
+    swap_index = GNUNET_CONTAINER_multipeermap_get (view->mpm,
+                                                    &view->array[last_index]);
     GNUNET_assert (NULL != swap_index);
     *swap_index = *index;
     GNUNET_free (index);
   }
-  GNUNET_CONTAINER_multipeermap_remove_all (mpm, peer);
+  GNUNET_CONTAINER_multipeermap_remove_all (view->mpm, peer);
   return GNUNET_OK;
 }
 
+
 /**
  * Get a peer by index
  *
+ * @param view the view of which to get the peer
  * @param index the index of the peer to get
  *
  * @return peer to the corresponding index.
  *         NULL if this index is not known
  */
 const struct GNUNET_PeerIdentity *
-View_get_peer_by_index (uint32_t index)
+View_get_peer_by_index (const struct View *view,
+                        uint32_t index)
 {
-  if (index < GNUNET_CONTAINER_multipeermap_size (mpm))
+  if (index < GNUNET_CONTAINER_multipeermap_size (view->mpm))
   {
-    return &array[index];
+    return &view->array[index];
   }
   else
   {
@@ -219,42 +248,41 @@ View_get_peer_by_index (uint32_t index)
   }
 }
 
+
 /**
- * Clear the custom peer map
- *
- * @param c_peer_map the custom peer map to look in
+ * Clear the view
  *
- * @return size of the map
+ * @param view The view to clear
  */
 void
-View_clear ()
+View_clear (struct View *view)
 {
-  for (uint32_t i = 0; 0 < View_size (); i++)
+  for (uint32_t i = 0; 0 < View_size (view); i++)
   { /* Need to free indices stored at peers */
     uint32_t *index;
 
     GNUNET_assert (GNUNET_YES ==
-        GNUNET_CONTAINER_multipeermap_contains (mpm, &array[i]));
-    index = GNUNET_CONTAINER_multipeermap_get (mpm, &array[i]);
+        GNUNET_CONTAINER_multipeermap_contains (view->mpm, &view->array[i]));
+    index = GNUNET_CONTAINER_multipeermap_get (view->mpm, &view->array[i]);
     GNUNET_assert (NULL != index);
     GNUNET_free (index);
-    GNUNET_CONTAINER_multipeermap_remove_all (mpm, &array[i]);
+    GNUNET_CONTAINER_multipeermap_remove_all (view->mpm, &view->array[i]);
   }
-  GNUNET_assert (0 == View_size ());
+  GNUNET_assert (0 == View_size (view));
 }
 
 
 /**
- * Destroy peermap.
+ * Destroy view.
  *
- * @param c_peer_map the map to destroy
+ * @param view the view to destroy
  */
 void
-View_destroy ()
+View_destroy (struct View *view)
 {
-  View_clear ();
-  GNUNET_free (array);
-  GNUNET_CONTAINER_multipeermap_destroy (mpm);
+  View_clear (view);
+  GNUNET_free (view->array);
+  GNUNET_CONTAINER_multipeermap_destroy (view->mpm);
 }
 
 /* end of gnunet-service-rps_view.c */
diff --git a/src/rps/gnunet-service-rps_view.h 
b/src/rps/gnunet-service-rps_view.h
index 127b49faf..a9017bab8 100644
--- a/src/rps/gnunet-service-rps_view.h
+++ b/src/rps/gnunet-service-rps_view.h
@@ -24,24 +24,29 @@
 #include "gnunet_util_lib.h"
 #include <inttypes.h>
 
+struct View;
 
 /**
  * Create an empty view.
  *
  * @param len the maximum length for the view
+ * @return The newly created view
  */
-void
+struct View *
 View_create (unsigned int len);
 
+
 /**
  * Change length of view
  *
  * If size is decreased, peers with higher indices are removed.
  *
+ * @param view The view that is changed
  * @param len the (maximum) length for the view
  */
 void
-View_change_len (unsigned int len);
+View_change_len (struct View *view,
+                 unsigned int len);
 
 /**
  * Get the view as an array
@@ -49,76 +54,90 @@ View_change_len (unsigned int len);
  * @return the view in array representation
  */
 const struct GNUNET_PeerIdentity *
-View_get_as_array ();
+View_get_as_array (const struct View *view);
+
 
 /**
  * Get the size of the view
  *
+ * @param view The view of which the size should be returned
  * @return current number of actually contained peers
  */
 unsigned int
-View_size ();
+View_size (const struct View *view);
+
 
 /**
  * Insert peer into the view
  *
+ * @param view The view to put the peer into
  * @param peer the peer to insert
  *
  * @return GNUNET_OK if peer was actually inserted
  *         GNUNET_NO if peer was not inserted
  */
 int
-View_put (const struct GNUNET_PeerIdentity *peer);
+View_put (struct View *view,
+          const struct GNUNET_PeerIdentity *peer);
+
 
 /**
  * Check whether view contains a peer
  *
+ * @param view The which is checked for a peer
  * @param peer the peer to check for
  *
  * @return GNUNET_OK if view contains peer
  *         GNUNET_NO otherwise
  */
 int
-View_contains_peer (const struct GNUNET_PeerIdentity *peer);
+View_contains_peer (const struct View *view,
+                    const struct GNUNET_PeerIdentity *peer);
+
 
 /**
  * Remove peer from view
  *
+ * @param view The view of which to remove the peer
  * @param peer the peer to remove
  *
  * @return GNUNET_OK if view contained peer and removed it successfully
  *         GNUNET_NO if view does not contain peer
  */
 int
-View_remove_peer (const struct GNUNET_PeerIdentity *peer);
+View_remove_peer (struct View *view,
+                  const struct GNUNET_PeerIdentity *peer);
+
 
 /**
  * Get a peer by index
  *
+ * @param view the view of which to get the peer
  * @param index the index of the peer to get
  *
  * @return peer to the corresponding index.
  *         NULL if this index is not known
  */
 const struct GNUNET_PeerIdentity *
-View_get_peer_by_index (uint32_t index);
+View_get_peer_by_index (const struct View *view,
+                        uint32_t index);
+
 
 /**
- * Clear the custom peer map
+ * Clear the view
  *
- * @param c_peer_map the custom peer map to look in
- *
- * @return size of the map
+ * @param view The view to clear
  */
 void
-View_clear ();
+View_clear (struct View *view);
+
 
 /**
- * Destroy peermap.
+ * Destroy view.
  *
- * @param c_peer_map the map to destroy
+ * @param view the view to destroy
  */
 void
-View_destroy ();
+View_destroy (struct View *view);
 
 /* end of gnunet-service-rps_view.h */
diff --git a/src/rps/test_service_rps_view.c b/src/rps/test_service_rps_view.c
index 16cf4b832..7418a16fc 100644
--- a/src/rps/test_service_rps_view.c
+++ b/src/rps/test_service_rps_view.c
@@ -22,114 +22,115 @@
 #include <platform.h>
 #include "gnunet-service-rps_view.h"
 
-#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); 
View_destroy(); return 1; }
+#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); 
View_destroy(view); return 1; }
 #define CHECK(c) { if (! (c)) ABORT(); }
 
 
 static int
 check ()
 {
+  struct View *view;
   struct GNUNET_PeerIdentity k1;
   struct GNUNET_PeerIdentity k2;
   const struct GNUNET_PeerIdentity *array;
-  int j;
+  unsigned int j;
 
-  View_create (3);
+  view = View_create (3);
   memset (&k1, 0, sizeof (k1));
   memset (&k2, 1, sizeof (k2));
-  CHECK (GNUNET_NO == View_contains_peer (&k1));
-  CHECK (GNUNET_NO == View_contains_peer (&k2));
-  CHECK (GNUNET_NO == View_remove_peer (&k1));
-  CHECK (GNUNET_NO == View_remove_peer (&k2));
-  CHECK (NULL == View_get_peer_by_index (0));
-  CHECK (NULL == View_get_peer_by_index (1));
-  View_clear (); /* See if assertions trigger */
-  CHECK (0 == View_size ());
-
-  CHECK (GNUNET_OK == View_put (&k1));
-  CHECK (1 == View_size ());
-  CHECK (GNUNET_NO == View_put (&k1));
-  CHECK (1 == View_size ());
-  CHECK (GNUNET_YES == View_contains_peer (&k1));
-  CHECK (GNUNET_OK == View_remove_peer (&k1));
-  CHECK (0 == View_size ());
-  CHECK (GNUNET_NO == View_contains_peer (&k1));
-  CHECK (GNUNET_NO == View_contains_peer (&k2));
-
-  CHECK (GNUNET_OK == View_put (&k1));
-  CHECK (1 == View_size ());
+  CHECK (GNUNET_NO == View_contains_peer (view, &k1));
+  CHECK (GNUNET_NO == View_contains_peer (view, &k2));
+  CHECK (GNUNET_NO == View_remove_peer (view, &k1));
+  CHECK (GNUNET_NO == View_remove_peer (view, &k2));
+  CHECK (NULL == View_get_peer_by_index (view, 0));
+  CHECK (NULL == View_get_peer_by_index (view, 1));
+  View_clear (view); /* See if assertions trigger */
+  CHECK (0 == View_size (view));
+
+  CHECK (GNUNET_OK == View_put (view, &k1));
+  CHECK (1 == View_size (view));
+  CHECK (GNUNET_NO == View_put (view, &k1));
+  CHECK (1 == View_size (view));
+  CHECK (GNUNET_YES == View_contains_peer (view, &k1));
+  CHECK (GNUNET_OK == View_remove_peer (view, &k1));
+  CHECK (0 == View_size (view));
+  CHECK (GNUNET_NO == View_contains_peer (view, &k1));
+  CHECK (GNUNET_NO == View_contains_peer (view, &k2));
+
+  CHECK (GNUNET_OK == View_put (view, &k1));
+  CHECK (1 == View_size (view));
   for (j = 0; j < 16; j++)
   {
-    CHECK (GNUNET_NO == View_put (&k1));
+    CHECK (GNUNET_NO == View_put (view, &k1));
   }
-  CHECK (1 == View_size ());
-  CHECK (GNUNET_OK == View_put (&k2));
-  CHECK (2 == View_size ());
+  CHECK (1 == View_size (view));
+  CHECK (GNUNET_OK == View_put (view, &k2));
+  CHECK (2 == View_size (view));
   for (j = 0; j < 16; j++)
   {
-    CHECK (GNUNET_NO == View_put (&k2));
+    CHECK (GNUNET_NO == View_put (view, &k2));
   }
-  CHECK (2 == View_size ());
+  CHECK (2 == View_size (view));
 
   /* iterate */
-  for (j = 0; j < View_size (); j++)
+  for (j = 0; j < View_size (view); j++)
   {
-    CHECK (NULL != View_get_peer_by_index (j));
+    CHECK (NULL != View_get_peer_by_index (view, j));
   }
-  CHECK ((0 == memcmp (View_get_peer_by_index (0),
+  CHECK ((0 == memcmp (View_get_peer_by_index (view, 0),
                        &k1, sizeof (k1))));
-  CHECK ((0 == memcmp (View_get_peer_by_index (1),
+  CHECK ((0 == memcmp (View_get_peer_by_index (view, 1),
                        &k2, sizeof (k2))));
-  CHECK (GNUNET_OK == View_remove_peer (&k1));
-  CHECK (1 == View_size ());
-  CHECK (GNUNET_NO == View_contains_peer (&k1));
-  CHECK (GNUNET_YES == View_contains_peer (&k2));
-  CHECK (NULL != View_get_peer_by_index (0));
-  CHECK (NULL == View_get_peer_by_index (1));
-
-  View_clear ();
-  CHECK (0 == View_size ());
-
-  CHECK (GNUNET_OK == View_put (&k1));
-  CHECK (1 == View_size ());
-  CHECK (GNUNET_YES == View_contains_peer (&k1));
-  CHECK (GNUNET_OK == View_put (&k2));
-  CHECK (2 == View_size ());
-  CHECK (GNUNET_YES == View_contains_peer (&k2));
-  array = View_get_as_array ();
+  CHECK (GNUNET_OK == View_remove_peer (view, &k1));
+  CHECK (1 == View_size (view));
+  CHECK (GNUNET_NO == View_contains_peer (view, &k1));
+  CHECK (GNUNET_YES == View_contains_peer (view, &k2));
+  CHECK (NULL != View_get_peer_by_index (view, 0));
+  CHECK (NULL == View_get_peer_by_index (view, 1));
+
+  View_clear (view);
+  CHECK (0 == View_size (view));
+
+  CHECK (GNUNET_OK == View_put (view, &k1));
+  CHECK (1 == View_size (view));
+  CHECK (GNUNET_YES == View_contains_peer (view, &k1));
+  CHECK (GNUNET_OK == View_put (view, &k2));
+  CHECK (2 == View_size (view));
+  CHECK (GNUNET_YES == View_contains_peer (view, &k2));
+  array = View_get_as_array (view);
   CHECK (0 == memcmp (&array[0], &k1, sizeof (k1)));
   CHECK (0 == memcmp (&array[1], &k2, sizeof (k2)));
-  View_clear ();
-  CHECK (0 == View_size ());
+  View_clear (view);
+  CHECK (0 == View_size (view));
 
   /*View_change_len () */
-  CHECK (GNUNET_OK == View_put (&k1));
-  CHECK (GNUNET_OK == View_put (&k2));
-  CHECK (2 == View_size ());
-  View_change_len (4);
-  CHECK (2 == View_size ());
-  CHECK (GNUNET_YES == View_contains_peer (&k1));
-  CHECK (GNUNET_YES == View_contains_peer (&k2));
-  array = View_get_as_array ();
+  CHECK (GNUNET_OK == View_put (view, &k1));
+  CHECK (GNUNET_OK == View_put (view, &k2));
+  CHECK (2 == View_size (view));
+  View_change_len (view, 4);
+  CHECK (2 == View_size (view));
+  CHECK (GNUNET_YES == View_contains_peer (view, &k1));
+  CHECK (GNUNET_YES == View_contains_peer (view, &k2));
+  array = View_get_as_array (view);
   CHECK (0 == memcmp (&array[0], &k1, sizeof (k1)));
   CHECK (0 == memcmp (&array[1], &k2, sizeof (k2)));
-  View_change_len (1);
-  CHECK (1 == View_size ());
-  CHECK (GNUNET_YES == View_contains_peer (&k1));
-  CHECK (GNUNET_NO  == View_contains_peer (&k2));
-  array = View_get_as_array ();
+  View_change_len (view, 1);
+  CHECK (1 == View_size (view));
+  CHECK (GNUNET_YES == View_contains_peer (view, &k1));
+  CHECK (GNUNET_NO  == View_contains_peer (view, &k2));
+  array = View_get_as_array (view);
   CHECK (0 == memcmp (&array[0], &k1, sizeof (k1)));
-  View_clear ();
-  CHECK (0 == View_size ());
+  View_clear (view);
+  CHECK (0 == View_size (view));
 
-  View_destroy ();
+  View_destroy (view);
 
   return 0;
 }
 
 
 int
-main (int argc, char *argv[])
+main ()
 {
   GNUNET_log_setup ("test_service_rps_peers", 
                    "WARNING",

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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