* production). The associated code should also probably be removed
* once we're done with experiments.
*/
-#define ENABLE_HISTOGRAM GNUNET_NO
+#define ENABLE_HISTOGRAM GNUNET_YES
/**
* Over how many values do we calculate the weighted average?
unsigned int idx;
peer_entry->th = NULL;
- if (buf == NULL)
+ if (NULL == buf)
{
/* client disconnected */
return 0;
}
GNUNET_assert (size >= sizeof (struct GNUNET_NSE_FloodMessage));
idx = estimate_index;
- if (peer_entry->previous_round == GNUNET_NO)
+ if (GNUNET_NO == peer_entry->previous_round)
{
idx = (idx + HISTORY_SIZE - 1) % HISTORY_SIZE;
peer_entry->previous_round = GNUNET_YES;
struct NSEPeerEntry *peer_entry = cls;
peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK;
+
GNUNET_assert (NULL == peer_entry->th);
peer_entry->th =
GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_NO, NSE_PRIORITY,
struct NSEPeerEntry *peer_entry = value;
struct GNUNET_TIME_Relative delay;
- if (peer_entry->th != NULL)
+ if (NULL != peer_entry->th)
{
peer_entry->previous_round = GNUNET_NO;
return GNUNET_OK;
}
- if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)
+ if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task)
{
GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
peer_entry->previous_round = GNUNET_NO;
{
/* still stuck in previous round, no point to update, check that
* we are active here though... */
- GNUNET_break (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK);
+ if (GNUNET_SCHEDULER_NO_TASK == peer_entry->transmit_task &&
+ NULL == peer_entry->th)
+ {
+ GNUNET_break (0);
+ }
return GNUNET_OK;
}
if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)
else if (ts.abs_value ==
current_timestamp.abs_value - gnunet_nse_interval.rel_value)
idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE;
- else if (ts.abs_value ==
- next_timestamp.abs_value - gnunet_nse_interval.rel_value)
+ else if (ts.abs_value == next_timestamp.abs_value)
{
if (matching_bits <= ntohl (next_message.matching_bits))
return GNUNET_OK; /* ignore, simply too early/late */
}
if (matching_bits < ntohl (size_estimate_messages[idx].matching_bits))
{
- if ((idx < estimate_index) && (peer_entry->previous_round == GNUNET_YES))
+ if ((idx < estimate_index) && (peer_entry->previous_round == GNUNET_YES)) {
peer_entry->previous_round = GNUNET_NO;
+ }
/* push back our result now, that peer is spreading bad information... */
if (NULL == peer_entry->th)
{
/* cancel transmission from us to this peer for this round */
if (idx == estimate_index)
{
+ /* Cancel transmission in the other direction, as this peer clearly has
+ up-to-date information already. Even if we didn't talk to this peer in
+ the previous round, we should no longer send it stale information as it
+ told us about the current round! */
+ peer_entry->previous_round = GNUNET_YES;
/* cancel any activity for current round */
if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)
{
/**
- * Method called whenever a peer connects.
+ * Method called whenever a peer connects. Sets up the PeerEntry and
+ * schedules the initial size info transmission to this peer.
*
* @param cls closure
* @param peer peer identity this notification is about
/**
- * Method called whenever a peer disconnects.
+ * Method called whenever a peer disconnects. Deletes the PeerEntry and cancels
+ * any pending transmission requests to that peer.
*
* @param cls closure
* @param peer peer identity this notification is about
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (peers, &peer->hashPubKey,
pos));
- if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK)
+ if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) {
GNUNET_SCHEDULER_cancel (pos->transmit_task);
+ pos->transmit_task = GNUNET_SCHEDULER_NO_TASK;
+ }
if (pos->th != NULL)
{
GNUNET_CORE_notify_transmit_ready_cancel (pos->th);
struct GNUNET_TIME_Absolute now;
struct GNUNET_TIME_Absolute prev_time;
- if (server == NULL)
+ if (NULL == server)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connection to core FAILED!\n");
GNUNET_SCHEDULER_shutdown ();
estimate_count = 0;
if (GNUNET_YES == check_proof_of_work (&my_public_key, my_proof))
{
+ int idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE;
prev_time.abs_value =
current_timestamp.abs_value - gnunet_nse_interval.rel_value;
- setup_flood_message (estimate_index, prev_time);
+ setup_flood_message (idx, prev_time);
+ setup_flood_message (estimate_index, current_timestamp);
estimate_count++;
}
flood_task =