/**
- * (Re)Initialise given Sampler with random min-wise independent function.
+ * Create a sampler element and initialise it.
*
* In this implementation this means choosing an auth_key for later use in
* a hmac at random.
}
+/**
+ * Destroy a sampler element.
+ *
+ * @param sampler_elem the element to destroy
+ */
+void
+RPS_sampler_elem_destroy (struct RPS_SamplerElement *sampler_elem)
+{
+ #ifdef TO_FILE
+ if (NULL != sampler_elem->file_name)
+ {
+ GNUNET_free (sampler_elem->file_name);
+ }
+ #endif /* TO_FILE */
+ GNUNET_free (sampler_elem);
+}
+
+
/**
* Input an PeerID into the given sampler element.
*
s_elem->num_peers++;
+ #ifdef TO_FILE
to_file (s_elem->file_name,
"Got id %s",
GNUNET_i2s_full (other));
+ #endif /* TO_FILE */
if (0 == GNUNET_CRYPTO_cmp_peer_identity (other, &(s_elem->peer_id)))
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, " Got PeerID %s\n",
- GNUNET_i2s (other));
LOG (GNUNET_ERROR_TYPE_DEBUG, "Have already PeerID %s\n",
GNUNET_i2s (&(s_elem->peer_id)));
}
}
else if (0 > GNUNET_CRYPTO_hash_cmp (&other_hash, &s_elem->peer_id_hash))
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, " Got PeerID %s\n",
- GNUNET_i2s (other));
LOG (GNUNET_ERROR_TYPE_DEBUG, "Discarding old PeerID %s\n",
GNUNET_i2s (&s_elem->peer_id));
s_elem->peer_id = *other;
}
else
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, " Got PeerID %s\n",
- GNUNET_i2s (other));
LOG (GNUNET_ERROR_TYPE_DEBUG, "Keeping old PeerID %s\n",
GNUNET_i2s (&s_elem->peer_id));
}
}
s_elem->is_empty = NOT_EMPTY;
+ #ifdef TO_FILE
to_file (s_elem->file_name,
"Now holding %s",
GNUNET_i2s_full (&s_elem->peer_id));
+ #endif /* TO_FILE */
+}
+
+/**
+ * Initialise the min-wise independent function of the given sampler element.
+ *
+ * @param s_elem the sampler element
+ * @param auth_key the key to use
+ */
+void
+RPS_sampler_elem_set (struct RPS_SamplerElement *s_elem,
+ struct GNUNET_CRYPTO_AuthKey auth_key)
+{
+ s_elem->auth_key = auth_key;
+
+ #ifdef TO_FILE
+ /* Create a file(-name) to store internals to */
+ char *name_buf;
+ name_buf = auth_key_to_string (s_elem->auth_key);
+
+ s_elem->file_name = create_file (name_buf);
+ GNUNET_free (name_buf);
+ #endif /* TO_FILE */
}
/* end of gnunet-service-rps.c */